[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Reading line by line into array variable?!



Tim A. Judd wrote:
> 
> I'm trying to get a script to read line-by-line text from a file into a
> variable..  say  @LineInfo
> 
> I then split that  @LineInfo  variable into ..  uh.  let's say  @LineData
> 
> I can get the @LineInfo -> @LineData split ok, but the file -> @LineInfo I
> can't get.  Do I have to basically do a "while <INPUT>" and put THAT info
> into a variable ($LineInfo[1], $LineInfo[2], $LineInfo[3]  etc) or is
> there an easier way?!!?  please tell me there is..  heehehe  :)

Yes, there is an easier way:

@LineInfo = <INPUT>;

When used in an array context, <> returns all the remaining lines in the
file.
-- 
Aaron Schrab <aarons@execpc.com>     http://www.execpc.com/~aarons/
Exec-PC Internet Systems Operator    info@execpc.com for automated info