#!/usr/bin/perl print "Hello\n"; &ThisSub; exit(0); sub ThisSub { my $sub = (caller(0))[3]; $sub =~ s/.*:://; # remove the package name, comment out of you want it too print "I am now in sub $sub\n"; return 1; # or simply 1; }