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 : )_~
In reply to File existance check failure by Festus Hagen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |