in reply to Declaring Variables

With a simple clause I do:
my $var = ( $test =~ m/regex/ ) ? "true value" : "false value";
With more complex clauses, or multiple variables on one clause, I predeclare:
my $var1; my $var2; if( $clause ) { $var1 = "blah"; $var2 = "deblah"; } else { $var1 = "foo"; $var2 = "bar"; }
As for getting variables out of subroutines, either have the routine return the variable, or pass the variable into the subroutine. Either way, scope the variable in the namespace where you want to use it, and if you are setting it else where, then pass it around.