Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: The "<" in the grep block

by Marshall (Prior)
on Sep 23, 2012 at 16:36 UTC ( #995215=note: print w/ replies, xml ) Need Help??


in reply to The "<" in the grep block

This statement seems odd to me:

@ARGV = map{glob} @ARGV;
glob what? map what? What did you intend for this statement to do?


Comment on Re: The "<" in the grep block
Download Code
Re^2: The "<" in the grep block
by BrowserUk (Pope) on Sep 23, 2012 at 17:10 UTC

    It does something analogous to the type of wild-card expansion that *nix shells do:

    @ARGV = '*.pl';; @ARGV = map{glob} @ARGV;; print for @ARGV;; 1.pl 100GB.pl 1gbdb.pl 24to32.pl ...

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

Re^2: The "<" in the grep block
by vagabonding electron (Hermit) on Sep 23, 2012 at 17:15 UTC
    This statement allows to use glob in cmd (Win32). Without this line the script if run as:
    C:\perl\bin>perl script.pl N:/TEMP/*
    throws the following message:
    Use of uninitialized value in numeric lt (<) at script.pl line 8. N:/TMP/*
    I have found this line by BrowserUK some time ago (cannot find the original node now) and I am very grateful for it.

    Update: Did not see the post from BrowserUK before I sent my message.

      I agree that

      @ARGV = map{glob} @ARGV; ....
      does work, however, I think since "glob" can do the expansion, why not use
      my @smaller_than_1000 = grep { -s $_ < 1000 } glob("@ARGV"); ....
      see glob for detail.

      If you tell me, I'll forget.
      If you show me, I'll remember.
      if you involve me, I'll understand.
      --- Author unknown to me

        That works for this application, but wouldn't for the more common uses:

        BEGIN{ @ARGV = map glob, @ARGV } while( <> ) { ... }

        And

        perl -eBEGIN{@ARGV=map{glob}@ARGV} -nle"1" a*.pl b*.pl

        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        RIP Neil Armstrong

Re^2: The "<" in the grep block
by Anonymous Monk on Sep 23, 2012 at 22:26 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2015-07-04 21:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls