in reply to Re^2: Pulling lines from file, noob style
in thread Pulling lines from file, noob style
It picked up exactly what you asked, but it printed even when it didn't pick anything up. as you use Perl, your mind will assimilate to a more perlish way of procedural thinking. for instance, the same snippet could be written as
while( <SMRT> ){ chomp; next unless /Power_On_Hours(.*)/i; $hours = $1; @time = split(' ',$hours); print "Power on hours = $time[7]\n"; }
although the overall effect is the same as using an if statement the intention is more explicit: you don't care about the line unless it matches the regex. as perl takes over you mind, you should notice a decrease in errors of this sort
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Pulling lines from file, noob style
by johngg (Canon) on Feb 17, 2010 at 22:56 UTC |