Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^8: foreach $1

by ikegami (Patriarch)
on Jun 09, 2020 at 17:57 UTC ( [id://11117877]=note: print w/replies, xml ) Need Help??


in reply to Re^7: foreach $1
in thread foreach $1

Where do you get this definition of "special" from

They are special in the sense that they are used by some Perl builtins, but the scalar itself is just an ordinary scalar. You can check using Devel::Peek's Dump. (As shown.)

So you agree that at least those vars should raise a warning in this case?

No. Warning when a magical var is used as the loop iterator would issue far too many incorrect warnings. Most of the time, the fact that the aliased variable doesn't have the original magic is a good thing.

sub g { for (qw( abc def )) { # $ENV{PATH} didn't get changed. } } sub f { for (@_) { # $_ now aliased to $ENV{PATH} g(); } } f($ENV{PATH}); # A magical var

Replies are listed 'Best First'.
Re^9: foreach $1
by LanX (Saint) on Jun 09, 2020 at 18:19 UTC

Log In?
Username:
Password:

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

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

    No recent polls found