sub do_it { my ($str,$numb) = @_; print "got $str\n" if $str; print "got $numb\n" if $numb; return 42; } # and you call it like so: do_it('Hello World'); do_it('lucky number',7); print "the answer is ", do_it(), "\n";