http://www.perlmonks.org?node_id=1205053

Perl300 has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I know this might be something basic that I am unable to see.

On Linux with perl v5.24.0, I want to check if any files exist whose names start with a specific string. So first I tested it on command line and it seemed working fine there:

/perl -le 'print -e glob "/abc/def/ghi/test*"'
It prints 1 if any file exist with name starting with "test" under /abc/def/ghi directory and blank if such file doesn't exist.

But when I use same in program like:

if (-e glob '/abc/def/ghi/test*') # line 4 { `sudo rm /abc/def/ghi/test*`; # Remove files if they already exist }
I get warning (I think it's warning) when I run the program as: Use of uninitialized value in -e at ./script_name.pl line 4.

Which variable is uninitialized here? Is it $_?
I tried replacing single quotes with double quotes, using -f instead of -e but still get same warning.
Am I missing something here? Is it possible to remove the warning by correcting/changing something?

Thank you for your time!

EDIT: Changed subject line to solved!