Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: The @_ array and the lexical variables

by G4143 (Novice)
on Apr 16, 2018 at 11:15 UTC ( [id://1212982]=note: print w/replies, xml ) Need Help??


in reply to Re: The @_ array and the lexical variables
in thread The @_ array and the lexical variables

Could you demonstrate that behaviour with a normal array or how I would arrive at that behaviour? Something like:
my @arr = (my $one, my $two, my $three);

Replies are listed 'Best First'.
Re^3: The @_ array and the lexical variables
by choroba (Cardinal) on Apr 16, 2018 at 11:52 UTC
    No, it's the magic behind @_ and calling a subroutine that causes the aliasing. Normal arrays don't alias.

    Another aliasing construct if for:

    my $x = 1; for my $y ($x) { $y++; } print $x; # 2

    See also Data::Alias .

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      OK. Thanks for the clarification.
Re^3: The @_ array and the lexical variables
by ikegami (Patriarch) on Apr 16, 2018 at 13:27 UTC
    our @arr; local *arr = sub { \@_ }->( my $one, my $two, my $three );
    or
    use Data::Alias qw( alias ); alias my @arr = ( my $one, my $two, my $three );
    or
    use feature qw( refaliasing ); my @arr; \$arr[@arr] = \my $one; \$arr[@arr] = \my $two; \$arr[@arr] = \my $three;

Log In?
Username:
Password:

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

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

    No recent polls found