in reply to extracting number from middle of string
You need to add an or die to the file open to ensure that it opened correctly. You also need to add angle brackets around the filehandle to read it. There also needs to be a comma after the filehandle in the open (and not a period).
$out_file = out1; open (OUT, "< $out_file") or die "Cannot open $out_file for reading: $ +!"; while (<OUT>) { if (/Time: (..):(..):(..)/) { $hours = $1; $mins = $2; $secs = $3; } } close (OUT); print "hours =: $hours";
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|