Dear Monks, why would I need to check for the length of the string? Is it not enough to check for the "definedness"?
use strict; use warnings; my $dir = '/etc'; while (1) { print "Enter pattern> "; chomp( my $pattern = <STDIN> ); ## I'm talking about this line last unless defined $pattern and length $pattern; my @matched = eval { grep { /$pattern/ } glob "$dir/*"; }; print "Error: $@" if $@; print map { "$_\n" } @matched; }
And like that ... he's gone. -- Verbal
In reply to Can a defined value be of zero length? by reisinge
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |