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

Re^3: Hash checking

by kyle (Abbot)
on Apr 25, 2007 at 21:01 UTC ( [id://612095]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Hash checking
in thread Hash checking

I think maybe we're misunderstanding each other somehow. I think the reason the OP's search loop is not finding anything in the array is because each of the array keys has an extraneous newline at the end. Take that off (with chomp), and it should be fine.

use Test::More 'tests' => 4; my $line; my %faclist; $line = "17\n"; $faclist{$line} = ""; $line = "23\n"; chomp $line; $faclist{$line} = ""; ok( ! exists $faclist{17}, 'number 17 does not exist' ); ok( ! exists $faclist{'17'}, 'string 17 does not exist' ); ok( exists $faclist{23}, 'number 23 exists' ); ok( exists $faclist{'23'}, 'string 23 exists' );

Replies are listed 'Best First'.
Re^4: Hash checking
by shigetsu (Hermit) on Apr 25, 2007 at 21:23 UTC

    I think maybe we're misunderstanding each other somehow.

    Yes, indeed we did. I'm inclined to say I misunderstood the intent that the Anonymous Monk was trying to put in effect.

    To elaborate a bit: I thought he wanted to clear the hash element and have exists yield failure when applied to the peculiar hash element; thus all the explanatory fuss.

    You did otherwise and were obviously right according to his follow-ups.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-03-29 11:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found