>>>>> Any ideas?
>>>>
>>>> Wrap the use() statement in an if block.
>>>>
>>>> if ( $^O eq 'darwin' ) {
>>>> use POSIX;
>>>> } else {
>>>> use POSIX qw(:sys_wait_h);
>>>> }
>>>>
>>>> Will that work?
>
> No.
>
>>> Only if you wrap that in a BEGIN block.
>
> And not even then.
>
>>> Remember, 'use' happens at
>>> compile not run time.
>
> This is true, but BEGIN happens at compile time too so you've not gained
> much.
>
>> Here's what I tried:
>>
>> **************************************
>> BEGIN {
>> if ( $^O eq 'darwin' ) { use POSIX; }
>> else { use POSIX qw(setsid nice :sys_wait_h); } # line 14
>> }
>>
>> ... but it still errors out:
>
>> Any other ideas?
>
> "perldoc -f use" reminds us that "use Module LIST" is exactly
> equivalent to
>
> BEGIN { require Module; import Module LIST; }
>
> so:
>
> BEGIN
> {
> require POSIX;
> POSIX->import($^O ne "darwin" ? qw(setsid nice :sys_wait_h) : ())
> }
That seems to work, and there's *no way* I'd have ever figured that out on
my own.
Thanks Paul!
- Bryan
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>