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"; #### use strict; { my $foo; sub setFoo{ $foo = shift; } sub getFoo{ return $foo; } }