Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Using glob in file test gives "Use of uninitialized value in -e" warning.

by afoken (Chancellor)
on Dec 06, 2017 at 21:47 UTC ( [id://1205057]=note: print w/replies, xml ) Need Help??


in reply to [SOLVED]: Using glob in file test gives "Use of uninitialized value in -e" warning.

glob returns a list of file names. Combine it with grep:

/etc>ls pa* passwd passwd- passwd~ /etc>perl -E 'say for grep { -e $_ } glob "pa*"' passwd passwd- passwd~ /etc>

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^2: Using glob in file test gives "Use of uninitialized value in -e" warning.
by choroba (Cardinal) on Dec 07, 2017 at 13:20 UTC
    What glob returns depends on the context. In scalar context (which -e imposes) it iterates over the matching files, and returns undef when there are no more files. If nothing matches the glob, it returns undef directly.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      What glob returns depends on the context.

      I must admit I never even thought of using glob in a non-list context, so I learned something new today. Great!

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-03-19 10:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found