Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by NetWallah (Canon)
on Dec 06, 2017 at 21:31 UTC ( [id://1205055]=note: print w/replies, xml ) Need Help??


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

Congrats on 'use warnings'!

The error is coming from:

if (-e glob '/abc/def/ghi/test*') # line 4
For the case where the 'glob' returns an empty array undef (i.e. test* does not exist).

You should break that into two tests:

my @tests; if (@tests = glob '/abc/def/ghi/test*' and -e $tests[0]) {# line 4

                All power corrupts, but we need electricity.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-19 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found