Festus Hagen has asked for the wisdom of the Perl Monks concerning the following question:
Hey y'all
Seeking wisdom of those that are wiser then I in the Perl world!
To skip the fmi ramble GOTO _MEAT_
A project I work on hasn't been taught how to wipe up after itself and always leaves a mess behind. Very annoying! (unfortunately that responsibility falls on a deaf (and possibly dumb) individual)
So I whipped up batch file for Win and a script for *nix, then got the brainy idea to multi platform it with Perl, considering Perl is required on the systems anyways it'll always be there!
However I find a peculiar difference that prevents me at my current Perl level to get past.
*nix Perl version 5.16.0
Strawberry Perl version 5.16.1
OS's various!
_MEAT_
It appears "-f" fails with wildcards, should it ??
It's always NOT found even though files meeting the criteria are in fact there.
I have tested the strings for line feeds and the like, they look perf.
Example:
#!/usr/bin/perl use strict; use warnings; # File location: projects/myproj/ # File names: myproj.a, myproj_c.a # This script is in the 'projects' directory. my $Element = 'myproj/*.a'; # Actual use is like: # next if not (-f "$Element"); # Test use: if (-f "$Element") { print "Found!\n"; } else { print "NOT Found!\n"; }
# FreeBSD script works ... #!/bin/sh Element='myproj/*.a' if [ -f "$Element" ]; then echo Found! else echo NOT Found! fi
rem Windows batch (cmd) works ... @echo off if exist "myproj\*.a" ( echo Found! ) else ( echo NOT Found! )
Ideas ??
Workarounds ??
Thanks all
-Enjoy
fh : )_~
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File existance check failure
by toolic (Bishop) on Nov 10, 2012 at 20:59 UTC | |
by Festus Hagen (Acolyte) on Nov 11, 2012 at 01:34 UTC | |
by Athanasius (Archbishop) on Nov 11, 2012 at 04:11 UTC | |
by Festus Hagen (Acolyte) on Nov 11, 2012 at 04:38 UTC | |
by graff (Chancellor) on Nov 12, 2012 at 03:05 UTC | |
|
Re: File existance check failure
by itnomad (Scribe) on Nov 10, 2012 at 22:39 UTC | |
|
Re: File existance check failure
by Festus Hagen (Acolyte) on Nov 17, 2012 at 11:35 UTC | |
|
Re: File existance check failure
by Festus Hagen (Acolyte) on Nov 17, 2012 at 17:22 UTC |