in reply to Re: use, require, import and use arguments
in thread use, require, import and use arguments
This:package Mod; sub foo { my ($pkg, %options) = @_; my $dir = $options{arg} || "/default"; die "$dir not found" unless -d $dir; print "$dir found"; } # this is to make foo run when module is require'd { foo(); } sub import { my ($pkg, %options) = @_; __PACKAGE__->foo(arg => $options{-arg}); }
Dies - I don't want this. I want foo to run with both "require" and "foo" and properly run without dying when the use" pragma gives it an argument.perl -e "use Mod -arg => '$HOME';"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: use, require, import and use arguments
by Anonymous Monk on Feb 26, 2011 at 14:06 UTC | |
by djihed (Novice) on Feb 26, 2011 at 15:16 UTC | |
by Anonymous Monk on Feb 26, 2011 at 15:28 UTC |