in reply to Re^2: Comparing two arrays
in thread Comparing two arrays

Hello GrandFather,

This is an excellent point! In:

my $var; for $var (...) {...}

it’s as though there were an implicit for local $var (...) {...} — except (a) that syntax is illegal, and (b) local doesn’t create an alias (which in C++ would be called a reference) as the for loop does. But thinking of what’s going on as an implicit local does, perhaps, explain why the strict pragma is fooled into thinking $var has been declared:

14:27 >perl -Mstrict -wE "my $var; for $var (1 .. 3) { say $var; } say + $var;" 1 2 3 Use of uninitialized value $var in say at -e line 1. 14:28 >

Is there any way to get strict, warnings, or something similar to flag this as a probable error?

BTW, congratulations on your promotion to Sage!

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,