in reply to Declaring Variables
I am NOT suggesting this, but I thought I would chime in. You
can modify the stack paramaters directly:
You can also encapsulate a my'd variable and make it semi global via subroutine calls, but this is sort of silly also:
That is just silly though. Use the 'vars' method mentioned above or just have your subs return a value instead of setting a global variable if that is possible.use strict; sub test { if( $_[0] =~ /regex/ ) { $_[1] = "match"; } else { $_[1] = "no match"; } } my $bool; test( "foo", $bool ); print "foo: $bool\n"; test( "regex", $bool ); print "regex: $bool\n";
You can also encapsulate a my'd variable and make it semi global via subroutine calls, but this is sort of silly also:
use strict; { my $foo; sub setFoo{ $foo = shift; } sub getFoo{ return $foo; } }
In Section
Seekers of Perl Wisdom