Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: using wildcard character * in perlscript command line

by holli (Monsignor)
on Jan 28, 2005 at 15:41 UTC ( #425995=note: print w/ replies, xml ) Need Help??


in reply to Re: using wildcard character * in perlscript command line
in thread using wildcard character * in perlscript command line

I looked at this and thought, "no way, what if the script gets switches or other arguments that are not files (like script * -option), those arguments will get lost because they donīt match any filename.
But they donīt. Can you explain why?


holli, regexed monk


Comment on Re^2: using wildcard character * in perlscript command line
Re^3: using wildcard character * in perlscript command line
by shenme (Priest) on Jan 28, 2005 at 15:56 UTC
    Because glob() will simply pass-thru anything that doesn't need expansion, otherwise it would lose ordinary filenames. But if the 'option' might have the expandable characters '*' or '?' you will be in danger of losing _those_ options. glob('-f?') returns nothing (usually), though glob('-f') will simply return '-f'.
Re^3: using wildcard character * in perlscript command line
by BrowserUk (Pope) on Jan 28, 2005 at 15:57 UTC

    If the value passed to glob doesn't contain a wildcard, it is passed through untouched.

    P:\test>perl -wle" print for glob '-debug' " -debug

    As for the why, if there is no file of that name existing, you'll need someone with the historical perspective (merlyn?).

    Maybe, just so that it doesn't affect non-wildcard parameters?


    Examine what is said, not who speaks.
    Silence betokens consent.
    Love the truth but pardon error.
Re^3: using wildcard character * in perlscript command line
by Aristotle (Chancellor) on Jan 28, 2005 at 17:25 UTC

    Perl's glob was originally implemented in terms of csh's. From man csh:

    If a word contains any of the characters *, ?, [ or { or begins with the character ~ it is a candidate for filename substitution, also known as globbing.

    If you use the bsdglob function from File::Glob (which is how glob is implemented nowadays), you can pick behaviour as desired.

    Makeshifts last the longest.

Re^3: using wildcard character * in perlscript command line
by blazar (Canon) on Jan 29, 2005 at 08:29 UTC
    For the same reason for which (depending on an option, really) *NIX shells (well, at least bash that I know) pass through any unmatched item.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://425995]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2014-09-21 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (172 votes), past polls