Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: How do I read the files in @ARGV one by one

by Masem (Monsignor)
on Mar 19, 2001 at 20:54 UTC ( #65455=note: print w/replies, xml ) Need Help??

in reply to How do I read the files in @ARGV one by one

Right now, you have no file handles to those data files to speak of, so it's odd how you are getting even that data. The way you want to do it is:
foreach my $file (@ARGV) { if ( -e $file ) { # double check existence push @data, $file; open FILE , '<'.$file or die $!; while( <FILE> ) { push @data, $_; } close FILE; } }

Dr. Michael K. Neylon - || "You've left the lens cap of your mind on again, Pinky" - The Brain

Replies are listed 'Best First'.
Re: Re: How do I read the files in @ARGV one by one
by isotope (Chaplain) on Mar 19, 2001 at 23:46 UTC
    It's not odd because he's using the <> operator, which returns all the data from all the files listed in @ARGV, all in one pass, line by line. It doesn't let you break it up by file, though.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://65455]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2018-02-22 13:56 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (293 votes). Check out past polls.