in reply to RE: Re: read X number of lines?
in thread read X number of lines?

I'm missing something here. What does assigning $/=\10240 mean? Thanks,

--ZZamboni

Replies are listed 'Best First'.
RE: RE: RE: Re: read X number of lines?
by mikfire (Deacon) on May 26, 2000 at 17:37 UTC
    Something new and twisted they added in perl 5.005. To quote perldoc perlvar:
    Setting $/ to a reference to an integer, scalar containing an integer, or scalar that's convertable to an integer will attempt to read records instead of lines, with the maximum record size being the referenced integer. So this: $/ = \32768; # or \"32768", or \$var_containing_32768 open(FILE, $myfile); $_ = <FILE>; will read a record of no more than 32768 bytes from FILE. If you're not reading from a record-oriented file (or your OS doesn't have record-oriented files), then you'll likely get a full chunk of data with every read. If a record is larger than the record size you've set, you'll get the record back in pieces.

    mikfire