perfluffle has asked for the wisdom of the Perl Monks concerning the following question:
My goals are:000: my $fname = $ARGV[0]; 001: open(FILE, $fname) or die "Can't open file!"; 002: 003: my $can_foo=1; 004: eval "use FOO::bar"; 005: if($@) { $can_foo=0; } #Don't try to use if unavailable 006: 007: #later on in the program, maybe multiple times. 008: 009: if ($can_foo) { 010: my $foobarzlot=sprintf("%d,",bar(FILE)->zlot); 011: print "FOOBARZLOT=".$foobarzlot."\n"; 012: }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Avoid using a module if it's not available
by linuxer (Curate) on Jun 12, 2008 at 18:23 UTC | |
|
Re: Avoid using a module if it's not available
by psini (Deacon) on Jun 12, 2008 at 18:27 UTC | |
|
Re: Avoid using a module if it's not available
by ww (Archbishop) on Jun 12, 2008 at 23:20 UTC | |
by akho (Hermit) on Jun 25, 2008 at 15:58 UTC | |
|
Re: Avoid using a module if it's not available
by jacques (Priest) on Jun 12, 2008 at 22:29 UTC | |
|
Re: Avoid using a module if it's not available
by ady (Deacon) on Jun 13, 2008 at 05:39 UTC | |
|
Re: Avoid using a module if it's not available
by QM (Parson) on Jun 13, 2008 at 15:08 UTC |