<?xml version="1.0" encoding="windows-1252"?>
<node id="1003275" title="File existance check failure" created="2012-11-10 15:18:22" updated="2012-11-10 15:18:22">
<type id="115">
perlquestion</type>
<author id="988782">
Festus Hagen</author>
<data>
<field name="doctext">
&lt;p&gt;Hey y'all&lt;/p&gt;

&lt;p&gt;Seeking wisdom of those that are wiser then I in the Perl world!&lt;/p&gt;

&lt;p&gt;To skip the fmi ramble GOTO _MEAT_&lt;/p&gt;

&lt;p&gt;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)&lt;/p&gt;

&lt;p&gt;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!&lt;/p&gt;

&lt;p&gt;However I find a peculiar difference that prevents me at my current Perl level to get past.&lt;/p&gt;

&lt;p&gt;
*nix Perl version 5.16.0&lt;br&gt;
Strawberry Perl version 5.16.1&lt;br&gt;
OS's various!
&lt;/p&gt;

&lt;p&gt;_MEAT_&lt;/p&gt;

&lt;p&gt;It appears "-f" fails with wildcards, should it ??&lt;br&gt;
It's always NOT found even though files meeting the criteria are in fact there.&lt;/p&gt;

&lt;p&gt;I have tested the strings for line feeds and the like, they look perf.&lt;/p&gt;

&lt;p&gt;Example:
&lt;code&gt;
#!/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";
}
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
# FreeBSD script works ...
#!/bin/sh
Element='myproj/*.a'

if [ -f "$Element" ]; then
  echo Found!
else
  echo NOT Found!
fi
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;
rem Windows batch (cmd) works ...
@echo off

if exist "myproj\*.a" (
  echo Found!
) else (
  echo NOT Found!
)
&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
Ideas ??&lt;br&gt;
Workarounds ??
&lt;/p&gt;

&lt;p&gt;Thanks all&lt;/p&gt;

&lt;p&gt;-Enjoy&lt;br&gt;fh &lt;b&gt;&lt;font color="#FF0000"&gt;:&lt;/font&gt;&lt;/b&gt; )_~&lt;/p&gt;
</field>
</data>
</node>
