http://qs321.pair.com?node_id=761578


in reply to pattern matching to separate data

You need to set the record separator to '>', like this: $/='>'. That way each call to <FILE> will get a single record rather than just part of the record. By default $/ is set to the new line and so if you leave your code as is, you are only getting up to the end of each line. See perlvar for more information.

A useful debugging tip is to print out each $line with begin and end markers: print STDERR "##$line##\n". The source of the problem would have been immediately clear had you done that. You might also enjoy this link from someone else who forgot to do that. By pure coincidence, Unbelievably Obvious Debugging Tip just happened to be in today's random pick of Selected Best Nodes

Best, beth