Hi Rick, Regarding "local":
$| is a global* variable so you use local to isolate this change to only where you need it. To see what I mean, run this: print "step1: $| \n"; { local $| = 1; print "step2: $| \n"; } print "step3: $| \n"; and you'll get output: step1: 0 step2: 1 step3: 0 while removing the 'local' you'll get step1: 0 step2: 1 step3: 1 Does that answer your question? Regarding autoflushing - that just means that it won't store the output in a buffer and wait until the buffer is full (or until the process is complete) before outputting it. This is a helpful description: https://stackoverflow.com/questions/6303515/perl-1-what-is-this <https://app.mailtag.io/link-event-v2?mt__id=c6c5700a-5861-11e8-824e-06cf19e8c68c&mt__url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F6303515%2Fperl-1-what-is-this> Sorry I can't think of an easy way to replicate buffering in a short script, but it certainly makes sense when responding to an HTTP request. Andrew * It's more accurate to say that $| is a package variable of the main package, but "global" is close enough for this discussion :-) On Tue, May 15, 2018 at 5:34 PM, Rick T <p...@reason.net> wrote: > I’m very much a novice — familiar with Learning Perl but finding > Intermediate Perl an uphill slog. > > The few lines below are from a subroutine that calls Template Toolkit. The > commented out line I simply copied from Perl Template Toolkit (PTT); the > line after it is what I replaced it with after seeing Perl Best Practices > (PBP) show the auto flush variable handled this way. Both lines work, > though I worry that the first one may not always work or else the use of > local would not be recommended. > > I vaguely understand that local restricts the auto flushing, though I’m > not sure how. Does local go out of scope when the TT is called? More > broadly, do I actually need local? Do I actually need auto flushing? The > authors of PTT and PBP assumed that persons reading their books would be > fairly accomplished programmers — but I’m not. So can you educate me? > > # $| = 1; > local $| = 1; # autoflush output > > print "Content-Type: text/html\n\n"; > my $tt = Template->new( > ect. > > Many thanks! > Rick Triplett > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- Andrew Solomon Perl Trainer, Geekuni http://geekuni.com/ and...@geekuni.com // +44 7931 946 062