On 8/9/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
snip
> I would like to write it as,
>
> local $/;
> while(<>) {
> print $1 if /FROM(.*?)END/s;
> }
snip
I wouldn't like you to write it that way. What if the file is very
large? Reading entire files (especially ones where you have no
control over which file is going to be read) into memory is a bad
idea. It also breaks the magical nature of the <> operator. In slurp
mode <> will read only one file at a time:
#!/usr/bin/perl
print "line mode\n";
@ARGV = qw<t.pl t.pl t.pl>;
while (<>) {
print;
}
print "slurp mode\n";
@ARGV = qw<t.pl t.pl t.pl>;
local $/ = undef;
my $str = <>;
print $str;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/