in reply to reading var from the file

Update: I think I initially misread what you what to do, so here's a different answer.

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:

What other kinds of lines are in your file? Would this work:
while (<>) { next unless m{(\d+)/$}; my $temp = $1; ...use $temp... }
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.

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; } }

Replies are listed 'Best First'.
Re^2: reading var from the file
by perlb (Initiate) on May 17, 2008 at 15:33 UTC
    Input file also an other varaible which ends on the one line. Only one varialbe has its value store in 2 lines ....