In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Dan Muey) writes:
>Howdy list!
>I was wondering...(imagine that!)
>
>If I have in my script:
>
>       #!/usr/bin/perl -w
>       use strict;
>       use ModuleWhatever;
>
>And ModuleWhatever has:
>
>       package ModuleWhatever;
>       $|++;
>
>Would that turn on autoflush for the rest of the script

Yes.

You can limit the scope of an assignment to $| with local:

{
  local $| = 1;
  ...
}

but be aware this is a dynamic scope and not a lexical one,
i.e., just wrapping that around a bunch of subs in a module
won't cause them to acquire a non-zero $| whenever something
outside calls them.

Assuming you're writing the module that wants to do this,
use local $| inside each and every subroutine in it that
wants to turn buffering on.

I've never felt the urge to do this. Perhaps you could share
what it is you're doing that makes you think you do?

-- 
Peter Scott
http://www.perldebugged.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to