in reply to Re: Look ahead and join if the line begins with a +
in thread Look ahead and join if the line begins with a +

You wrote:
while(chomp(my $line = <NETLIST>)){
What if the last line is missing its \n?

Since chomp will return 0 if no characters are removed, it's probably safer to go for the less fun

while(defined(my $line = <NETLIST>)){ chomp;

--
Mike

Edit:Forgot the defined, needed in case of last lines containing only perlish false values, like 0...

Replies are listed 'Best First'.
Re: What if last line has no LF?
by belg4mit (Prior) on Apr 11, 2002 at 14:07 UTC
    Simple, you don't do that ;-). Seriously, you have a valid point but I don't think it's unreasonable to know your data. It's also not unreasonable to code in a seemingly data independent manner either, but it may just be a throw away tool.

    You could also test to $_ upon exiting the loop, and act accordingly, probably undef'ing $_ withing the loop on each execution.

    --
    perl -pe "s/\b;([mnst])/'\1/mg"