|P is for Practical|
Reading a text file collapsing line continuationsby skx (Parson)
|on Mar 09, 2009 at 15:37 UTC||Need Help??|
skx has asked for the
wisdom of the Perl Monks concerning the following question:
I've written some code for parsing input files which is working happily on one machine, but failing on another.
Although not necessary I've added support for the input to be broken across multiple lines - via "\" character at the end of line. The following is a cut-down version of the code (and identical to recipe 8.1 from the perl cookbook):
On one machine that works perfectly:
On another it gives errors:
I would expect that the while loop wouldn't run if there was an undefined line - so I'm unclear on why the chomp is giving the uninitialized variable warning.
For the moment I've just reworked my input into non-split lines, but I'm confused as to what I've done wrong!