#!/usr/local/bin/perl use Devel::Peek 'Dump'; sub foo { # this will create a new variable $s and copy first argument's contents right? my ($s) = @_; print "Dump inside trim():\n"; print "\$_[0] (this one is infact a 'synonym' to the actual variable; not it's copy :-) :\n"; Dump($_[0]);print"\n"; print "\$s (this is a copy of the 1-st argument:\n"; Dump($s);print"\n"; } sub bar(\$) { # this will create a new variable $s and copy first argument's contents as well, # however, it's much faster here compred to foo() since in this case only # a reference to the actual variable is copied, not the actual variable's # contents. my ($s) = @_; print "Dump inside bar(\\\$):\n"; print "\$_[0]:\n"; Dump($_[0]);print"\n"; print "\$s (this is a copy of the 1-st argument, which is nothing more but a reference..):\n"; Dump($s);print"\n"; } $s = "some text here "; print "Dump before:\n"; Dump($s);print"\n"; foo($s); bar($s); print "Dump after:\n"; Dump($s);print"\n";