Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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!

_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

Title:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (12)
    As of 2014-12-18 18:04 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (59 votes), past polls