G'day dobster936,
Welcome to the Monastery.
One potential problem is lines like
$fr="$dirtoget$f"; ... $fw="$dirwrite$f";
Do $fr and $fw evaluate to /some/dirname/somefilename or /some/dirnamesomefilename? Add print statements to find out. See the builtin File::Spec module to "portably perform operations on file names".
Another problem is performing I/O without checking whether it worked. See open for examples of how to do this. Alternatively, use the autodie pragma and let Perl do it for you.
And yet another issue is assuming everything, except "." and "..", is a normal file:
unless ( ($f eq ".") || ($f eq "..") ) {
See the file test operators. Given that unless block has no closing brace, you could just change those two lines to:
next unless -f $f;
Global (package) variables have all sorts of problems. Choose lexical variables and control their scope yourself. See "Private Variables via my()" for further discussion.
Finally, as others have already indicated, use the strict and warnings pragmata. There's really no value in spending time tracking down problems in your code when Perl will do it for you.
-- Ken
In reply to Re: Perl Script in Windows Works, but not in Unix
by kcott
in thread Perl Script in Windows Works, but not in Unix
by dobster936
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |