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

Re: [MacPerl] How files are read in (was: for loops)



As for the why, if you've opened a file with filehandle TXT, and do <TXT>
on it, it reads *one* line from that file. What Perl considers to be a
line, at that point, is dictated by the predefined variable $/, which is
newline (\n) by default. Using MacPerl, it's actually CR, or \r.

Normally you'd set $/ to undef to slurp in the whole file.

Be that as it may, whatever is going on with your text file and $/, if all
of it got read by one use of <>, then whatever variable, $text if you
like, that you read it into is a *scalar*, not an array. If you happened
to have @text on the left, as in

@text = <TXT>;

and ONE use of <> gets you the whole file, then you're initializing
$text[0] and nothing else. So it's really a $/ issue.

Hope this makes some kind of sense. What you should look at is 'perlvar'
and 'perlop', to read about <> and $/.

Arved




***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch