Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Scalar refs, aliasing, and recursion weirdness.

by !1 (Hermit)
on Feb 04, 2005 at 23:38 UTC ( #428248=note: print w/replies, xml ) Need Help??


in reply to Re^2: Scalar refs, aliasing, and recursion weirdness.
in thread Scalar refs, aliasing, and recursion weirdness.

Even better example:

#! perl -slw use strict; sub recurse { print ">> '${ $_[ 0 ] }'"; (my $depth=$_[1])--; if ($depth) { recurse( \ substr( ${ $_[ 0 ] }, 1, -1 ), $depth ); } else { ${$_[0]} = "XX"; } print "<< '${ $_[ 0 ] }'"; return; } my $str = 'abcdefghi'; recurse \$str, 3; print $str; recurse \$str, 2; print $str; __END__ >> 'abcdefghi' >> 'bcdefgh' >> 'cdefg' << 'XX' << 'bcdefgh' << 'abcdefghi' abcdefghi >> 'abcdefghi' >> 'bcdefgh' << 'XXi' << 'aXXi' aXXi

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2021-07-29 05:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?