in reply to Re^2: call perl subs in another directory?
in thread call perl subs in another directory?
In do-test2.pl:
In subdir/foo.pl:#!/usr/bin/perl use strict; use warnings; while (<subdir/*.pl>) { my $pkg = do $_; print "Loaded package $pkg\n"; { no strict 'refs'; &{"${pkg}::spew"}(); } }
subdir/bar.pl is similar to subdir/foo.pl, as above.package Foo; print "Executing foo.pl\n"; sub spew { print "This is package Foo\n"; } __PACKAGE__
Output of do-test2.pl:
Dynamic.Executing bar.pl Loaded package Bar This is package Bar Executing foo.pl Loaded package Foo This is package Foo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: call perl subs in another directory?
by guthrie (Novice) on Oct 17, 2007 at 18:54 UTC | |
by gamache (Friar) on Oct 17, 2007 at 20:13 UTC |