in reply to For loop and Sub Routines
It uses the global "$ssh", which gets nailed in at compile-time. (Using the term 'Compile-time' loosely).
I suggest taking the sub declaration outside the "for" loop, then passing in $ssh.
Update:Here is an illustration of the issue:
When the parameter is "2", then $z should be 22. This would be the case if $z were passed-in.>perl -E 'for (1..2){say "In loop $_"; my $z=$_+20; x($_); sub x{my $y +=$_[0]; say "In Sub. Param= $y. z=$z"}}' In loop 1 In Sub. Param= 1. z=21 In loop 2 In Sub. Param= 2. z=21
My goal ... to kill off the slow brain cells that are holding me back from synergizing my knowledge of vertically integrated mobile platforms in local cloud-based content management system datafication.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: For loop and Sub Routines
by nickt9999 (Acolyte) on Jul 04, 2013 at 17:51 UTC | |
by NetWallah (Canon) on Jul 05, 2013 at 05:17 UTC |