in reply to Finding out how you were called...
Either way, I think the functionality you are looking for is something like:my $my_path = $0; foreach my $path (split(/:/, $ENV{PATH})) { $my_path = "$path/$0" if (-f "$path/$0"); }
my ($called_name) = $0 =~ m#/([^/]+)$#; { no strict; &{"mode_$called_name"}() if (defined &{"mode_$called_name"}); } sub mode_foo { # If program is called as "foo" } sub mode_moo { # If program is called as "moo" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Finding out how you were called...
by suaveant (Parson) on Aug 07, 2001 at 04:35 UTC | |
by tye (Sage) on Aug 07, 2001 at 10:16 UTC | |
by tadman (Prior) on Aug 07, 2001 at 04:45 UTC |