M
Marko Riedel
Hi folks,
it seems that "exists" does not work on hash keys that begin with a
backslash, but grep on the keys finds the key. (These keys occur
e.g. when working with IMAP message flags.)
Would someone explain, please?
[PROMPT]> perl -e '%h=qw/A 1 B 2/; print "yes\n" if exists($h{B});'
yes
[PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{\B});'
[PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if grep('\B', keys %h);'
yes
perl -v
This is perl, v5.8.0 built for i586-linux-thread-multi
Copyright 1987-2002, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
Best regards,
it seems that "exists" does not work on hash keys that begin with a
backslash, but grep on the keys finds the key. (These keys occur
e.g. when working with IMAP message flags.)
Would someone explain, please?
[PROMPT]> perl -e '%h=qw/A 1 B 2/; print "yes\n" if exists($h{B});'
yes
[PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{\B});'
[PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if grep('\B', keys %h);'
yes
perl -v
This is perl, v5.8.0 built for i586-linux-thread-multi
Copyright 1987-2002, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
Best regards,