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:
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./perl -le 'print -e glob "/abc/def/ghi/test*"'
But when I use same in program like:
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.if (-e glob '/abc/def/ghi/test*') # line 4 { `sudo rm /abc/def/ghi/test*`; # Remove files if they already exist }
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!
In reply to [SOLVED]: Using glob in file test gives "Use of uninitialized value in -e" warning. by Perl300
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |