Jenda Krynicky [JK], on Friday, February 04, 2005 at 13:58 (+0100)
wrote these comments:

JK> Don't shell out (start external programs) for things you may do in
JK> Perl easily:

JK> Eg.
JK>         my @files = do {open my $IN, '<', 'filelist.txt'; <$IN>};

for 'test' purposes is shorter my @files = `cat filelist.txt`;#)

in my real aplication I use:

for scalar:
open(my($fh), "<", 'filelist.txt') or die "$!\n";
my $content = do { local $/; <$fh> };
close $fh;

but as I can see, I can use yours suggestion with scalar, too.
I guess it can be written as:

my $content = do { local $/; open(my($fh), "<", 'filelist.txt) or die "$!\n"; 
<$fh>};

-- 

 ...m8s, cu l8r, Brano.

["Hey, Lowell, need a lozange?" - Sheriff Buck]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to