in reply to Global variable vs passing variable from sub to sub
This code will show that:
output:sub test1 { ++$_[0] ; print "T1 [@_]\n" ; test2($_[0]) ; } sub test2 { ++$_[0] ; print "T2 [@_]\n" ; test3($_[0]) ; } sub test3 { ++$_[0] ; print "T3 [@_]\n" ; print "end\n" ; } my $n = 10 ; test1($n) ; print "N: $n\n" ;
And forget the use of a global variable for any type of code and start learning OO. Take a look at perlobj, perltoot, perlboot and perltooc.T1 [11] T2 [12] T3 [13] end N: 13
For Object Orientation (OO) I use Class::HPLOO.
Graciliano M. P.
"Creativity is the expression of the liberty".
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Global variable vs passing variable from sub to sub
by kiat (Vicar) on Sep 14, 2004 at 07:11 UTC |