J
jhavero
The 'use' command below tries to run when this is executed from Unix
so I get an error that it cannot find the Win32::File module. If I
comment out this 'use' line the script works in Unix and the 'print
"Unix"' statement runs and the 'print "Windows"' statement never runs.
How can I stop it from running the 'use' command when run from Unix.
# Main
..
..
..
my %FINDOPTIONS = (
'wanted' => \&entry,
'no_chdir' => 1
);
..
..
..
find(\%FINDOPTIONS,@COMPONENTS);
sub entry {
if($^O eq 'MSWin32') {
#Windows
use Win32::File qw/ GetAttributes SetAttributes /;
print "Windows\n";
}
} else {
#unix
print "Unix\n";
}
} #end sub entry
so I get an error that it cannot find the Win32::File module. If I
comment out this 'use' line the script works in Unix and the 'print
"Unix"' statement runs and the 'print "Windows"' statement never runs.
How can I stop it from running the 'use' command when run from Unix.
# Main
..
..
..
my %FINDOPTIONS = (
'wanted' => \&entry,
'no_chdir' => 1
);
..
..
..
find(\%FINDOPTIONS,@COMPONENTS);
sub entry {
if($^O eq 'MSWin32') {
#Windows
use Win32::File qw/ GetAttributes SetAttributes /;
print "Windows\n";
}
} else {
#unix
print "Unix\n";
}
} #end sub entry