Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Transitive aliases

by JadeNB (Chaplain)
on Dec 27, 2009 at 23:56 UTC ( #814557=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub double {
        sub { \@_ }->($_[0], $_[0])
    ...
    @$r; # => ( 2, 2 );
    $r->[0] = 3;
    @$r; # => ( 3, 3 );
    
  2. or download this
    switch_var $r, $v, my $w;
    $w = 4;
    @$r; # => ( 4, 4 );
    
  3. or download this
    sub switch_var { $_[0] = double $_[2] }
    
  4. or download this
    sub switch_var {
        alias $_[1] = $_[2];
    ...
    switch_var $r, $v, my $w;
    $w = 4;
    @$r; # => ( 3, 3 );
    
  5. or download this
    sub switch_var {
        alias $_[0][0] = $_[2];
    ...
    switch_var $r, $v, my $w;
    $w = 4;
    @$r; # => ( 4, 3 )
    
  6. or download this
    my $x;
    my $fake_sub = fake_subroutine $x => sub { \@_ }->($x, $x);
    ...
    my $r = call $fake_sub, my $y;
    $y = 1;
    @$r; # => ( 1, 1 );
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://814557]
Approved by planetscape
Front-paged by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2020-06-01 15:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (3 votes). Check out past polls.

    Notices?