Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Transitive aliases

by JadeNB (Chaplain)
on Dec 27, 2009 at 23:56 UTC ( [id://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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-18 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found