It seems you want to collect lines until the next line that begins with Temp:. The pattern for this is:
my $temp; while (<>) { chomp; if (s/^Temp:\s*//) { if (defined($temp)) { ...use $temp... }; $temp = $_; } else { $temp .= $_; } } if (defined($temp)) { ...use $temp... }
My original answer:
This just looks for lines that end in a string of digits followed by a slash and assumes it's the information you're looking for.while (<>) { next unless m{(\d+)/$}; my $temp = $1; ...use $temp... }
If it is necessary to find the Temp: prefix on the same line or the line before, then this should work:
while (<>) { next unless /^Temp:/; my $temp; if (m{(\d+)/$}) { $temp = $1; } else { $_ = <>; # read the next line next unless m{(\d+)/$}; $temp = $1; } }
In reply to Re: reading var from the file
by pc88mxer
in thread reading var from the file
by perlb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |