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
$,=qq.\n.;print q.\/\/____\/.,q./\ \ / / \\.,q. /_/__.,q..
Happy, sober, smart: pick two.
|