in reply to Re: Re: Increasing Buffer size of STDIN on PERL Program
in thread Increasing Buffer size of STDIN on PERL Program

The reason why I use local $/ instead of my $/ is the difference between how local and my work.

The keyword local has been around for a long time, way before the keyword my (which was introduced only after Perl 5).

The difference is that local is run-time scoping, while my is compile-time scoping. Local $/ will first push the value of current $/ onto the stack, and then when the code leave the scope, automatically restores its previous content. my $/ will not work here, it will give you a perl compilation error, any $-punctuation variable will have to be localized with local, it's a limitation (or feature?) of perl. local keyword reuses a variable already exists in the global context.

This method is not efficient if you have lots of data (hundreds of Mb) pumping out from another process, because it will have to allocate memory to hold the input.

  • Comment on Re: Re: Re: Increasing Buffer size of STDIN on PERL Program