I want something like..
all_objects.pl
my $sub = $ARGV[1];
...
@objs = get_all_objects();
for my $obj (@objs) {
// invoke subroutine $sub with param as $obj.
}
now if I say
all_objects.pl "print 'x '"
all_objects.pl "print '$_ '"
I should get
obj1 obj2 obj3 ...
i.e. the command line arg act as a subroutine in some way. Can this be achieved?
eval ""is bad. Use something like the following, if it fulfills your needs:Update: For debugging purposes, Perl has a debugger:
perldoc perldebug