in reply to call perl subs in another directory?
In do-test.pl:
In subdir/foo.pl:#!/usr/bin/perl use strict; use warnings; while (<subdir/*.pl>) { do $_; } Foo::spew(); Bar::spew();
In subdir/bar.pl:package Foo; print "Executing foo.pl\n"; sub spew { print "This is package Foo\n"; }
Finally, the output of do-test.pl:package Bar; print "Executing bar.pl\n"; sub spew { print "This is package Bar\n"; }
(Edited to provide more instructive example)Executing bar.pl Executing foo.pl This is package Foo This is package Bar
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: call perl subs in another directory?
by guthrie (Novice) on Oct 17, 2007 at 02:06 UTC | |
by gamache (Friar) on Oct 17, 2007 at 13:58 UTC | |
by guthrie (Novice) on Oct 17, 2007 at 18:54 UTC | |
by gamache (Friar) on Oct 17, 2007 at 20:13 UTC |