Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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!


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.


#!/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

fh : )_~

In reply to File existance check failure by Festus Hagen

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (1)
    As of 2018-02-23 07:36 GMT
    Find Nodes?
      Voting Booth?
      When it is dark outside I am happiest to see ...

      Results (300 votes). Check out past polls.