$out_file = out1; open (OUT, "< $out_file") or die "Cannot open $out_file for reading: $!"; while () { if (/Time: (..):(..):(..)/) { $hours = $1; $mins = $2; $secs = $3; } } close (OUT); print "hours =: $hours";