in reply to Re: Reading Multiple lines
in thread Reading Multiple lines

Thanks for your input but unfortunately it has not worked.

I have appended the code from the second part below.

I think the problem is in the next phase. I can't understand though why it only processes the files that have the carriage returns using this preprocessing phase

It processes a line (that has not being in the if statement)once and closes the filehandle but only on the lines that have not being processed in the if statement

It could be a bug in my code(more than likely :) ) or a bug with perl.

Replies are listed 'Best First'.
Re^3: Reading Multiple lines
by gone2015 (Deacon) on Oct 15, 2008 at 23:49 UTC

    You've lost me.

    I assume that in the code in 717191 the PROCESSEDFILE is the file produced by stitching the CSV stuff together. I pushed the bits of code together, as best as I can, to get it to run. The $end variable was undefined and the $nameF variable was missing its my -- but apart from that it runs.

    First time through the while (<PROCESSEDFILE>) loop: $num will be set to 1, so if ($file{$key}{num} > 1) will fail, so no file will be opened. I cannot figure out what this is trying to do, but I suspect it's trying not to open a file in the '(column not present)' case -- and making a mess of it.

    Incidentally, the first time it gets a '(column not present)' case it will pass the unless ($file{$key}) test and promptly set my $nameF = $c[$field], although $c[$field] is already known to be undefined. Not sure I see the point of that, either.

    Finally, under all conditions -- including '(column not present)' and when it has failed to open a file -- it gets to the print {$file{$key}{name}} @c; line. What is this intended to do ? Under strict it gives me

      Can't use string ("/somewhere/data.END") as a symbol ref while "strict refs" in use ...
    
    but for all I know it does something wonderful in non-strict. I note however that you set $file{$key}{fh} which looks like a dead ringer for somewhere to output to ?

    Between you and me this looks like a bit of a train wreck. I suggest putting in the odd print statement here and there so that you can tell what's going on at each stage in the process... that may show you where things are and are not working as you expect.

    BTW: I recommend Markup in the Monastery