(Sorry for the short e-mail. Let's try that again... - Dan)<br><br>I have a file that has a number of lines in it. Two lines contain data
I want, the rest are unimportant. These two lines can appear most
anywhere and in any order.<br><br>What I'm currently doing is this:<br>$val1 = 0;<br>$val2 = 0;<br>while (<FILEHANDLE>) {<br><font color="#888888">
</font>$val1 = $1 if /^COUNT:\s*(\d*)$/;<br> $val2 = $1 if /^SIZE:\s*(\d*)$/;<br> last if ($val1 and $val2);<br>}<br><br>The "last if" statement is my attempt to exit sooner rather than working through the entire file.<br>
<br>I had tried to setup a map function something like this:<br>($val1, $val2) = map { <br> return ($1, $val2) if /^COUNT:\s*(\d*)$/;<br> return ($val1, $2) if /^SIZE:\s*(\d*)$/;<br> } <FILEHANDLE>;<br><br>
...but I get a "can't return outside of subroutine.<br><br>Am I better off with my while loop? It passes the "3AM readability test" in my opinion.<br><br>Dan<br clear="all"><br><br>-- <br>"Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal<br>
"I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author)<br>** *** ***** ******* *********** *************<br>