in reply to Avoid using a module if it's not available
This works for me without a bad message:
#!/usr/bin/perl # vi:ts=4 sw=4 et: use strict; use warnings; my $fname = $ARGV[0]; my $scan_foo = 1; eval "use File::stat"; if ( $@ ) { $scan_foo = 0; } if ( $scan_foo ) { my $foobarzlot = sprintf("%d", File::stat::stat($fname)->size ); print "FOOBARZLOT=" . $foobarzlot . $/; } __END__
update1: 1st answer removed due to bad reading of OP
update2: adjusted code to better match original code example
|
|---|