I noticed this while looking at another question...
If I have a script like this:
while (<>) {
print if 5 .. undef;
}
It skips lines 1..4 then prints the rest of the file. However if I try this:
my $start_line = 5;
while (<>) {
print if $start_line .. undef;
}
It prints from line 1. Can anyone explain why?
Actually I'm not even sure why the first one works.
Hmmm looking further into this I found that this works:
my $start = 5;
while (<>) {
print if $. == $start .. undef;
}
So the first version magically uses $.
which is the line number. But I don't know why it fails with a variable.