Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Comparing two arrays

by Athanasius (Archbishop)
on Feb 21, 2015 at 04:35 UTC ( [id://1117396]=note: print w/replies, xml ) Need Help??


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,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1117396]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-24 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found