I don't know of any special variable that means 'the value from the last if test expression'. You could do:
if ( $name = get_name() ) {
print "\n My name is $name";
}
And that wouldn't even be hard for others to read and maintain.
Also, is there a reason you don't use return in sub get_name? I know you don't have to, but it makes it _much_ easier to detect bugs if you insert new lines at the end of the sub (or, someone else who isn't paying enough attention to your code does.) I'd generally consider always saying 'return' when you want to return a value as one of those habits of highly successful perl programmers.