local $. in the <DATA>-block has no usage. What will perl do? it will copy the current value of $. to a temp variable, and reset it after the block.
It is not this block that it is messing up the results of $., it is the seeky-sub. What you could do is add a local $. in sub seeky, then you get the results you expect.
Since this means that at the start of the block it will copy $. to another variable, seek will set $. to another alias, and at the end of the block the value of $. is restored (by using the copy it made).
Update: another solution with which you would get the same result is to create a new block in your code, and localising $. in there. Something like:
while (<DATA>) { chomp; my $line = $.; warn "Pre match: Line $. == $line\n"; next if /match/; { local $.; seeky(); } warn "Postmatch: Line $. != $line\n"; }
In reply to Re: Localization gotcha?
by Animator
in thread Localization gotcha?
by benizi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |