if ( my $t = shift ) { $t =~ s/change_something/to_something_else/; } print "$t\n"; # out of scope here #### print $t if (my $t = shift);