note
johngg
<p>Skipping the header in a for loop (implied with a statement modifier) is quite flexible as you can skip one, two or many lines with equal facility. It also has the advantage that the scalar receiving the readline only exists within the loop.</p>
<code>
my $discard = <$fh> for 1 .. 1;
# $discard no longer in scope here.
</code>
<p>I hope this is of interest.</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-401112">
<p>Cheers,</p><p>JohnGG</p>
</div></div>
<p><b>Update: </b>Fixed typo.</p>
<p><b>Update 2: </b>[ikegami] has [id://771119|pointed out] that this code is invalid and [id://771287|explained why] so don't do this.</p>
770971
770971