David K. Wall said:
Good thing the OP is using winXP and not win98.
A friend of mine recently wanted a copy of a little utility program I had
written. He didn't have Perl (and didn't want or need it), so I packaged
the program with PAR under winXP and sent him the executable. When he ran
the exe on his win98 system, all he got from glob() was "Bad command or
filename", so I had to rewrite that portion of the program to use readdir()
and 'next unless ...'.
Maybe if I'd had a win98 system with which to create the exe it might have
worked?
Dear David,
Actually, it wouldn't have made a difference which Win OS you
created it on; if the system the executable runs on doesn't have
ActiveState Perl, the glob() function probably won't work. Here's
why:
When a glob() function is encountered in a Perl script, ActiveState
Perl will run the "perlglob.exe" executable using the backtick
operator. The perlglob.exe program is usually installed in the
Perl\bin directory, so if ActiveState ActivePerl was never installed,
chances are that the perlglob.exe executable doesn't exist, causing
the backtick operator (and, later, the glob() function) to fail (which
is why you got the error: "Bad command or file name"). It will run
perfectly on the machine that created the PAR executable (because
perlglob.exe exists there), misleading people to believe that their
PAR executable only works on their operating systems.
We actually encountered this problem just a few days ago, and the
way that we got around this problem was to add the line:
use File::Glob ':glob';
and change all "glob" calls to "bsd_glob". After that, globbing
worked perfectly.
I suppose another simple solution would be to just copy the
perlglob.exe executable into a directory included in the $PATH of your
friend's computer.
So be careful when you run Perl code that uses the backtick
operator; if the executable (that you're running inside backticks)
doesn't exist on the machine that you run the script on, the script
certainly won't function correctly.
Hope this helps,
Jean-Luc Romano