Re: only one of two hash keys

2006-04-05 Thread Jay Savage
On 4/4/06, Lawrence Statton <[EMAIL PROTECTED]> wrote: > > Is there a nice clean perl way to test to see if only one key of a hash > > has data? > > > > %some_hash = ( key1 => 1, key2 => 2 ); should fail the test > > %some_hash = ( key2 => 2 ); should pass the test > > %some_hash = ( key1 => 1 ); s

Re: only one of two hash keys

2006-04-05 Thread John Ackley
perl wrote: Is there a nice clean perl way to test to see if only one key of a hash has data? %some_hash = ( key1 => 1, key2 => 2 ); should fail the test %some_hash = ( key2 => 2 ); should pass the test %some_hash = ( key1 => 1 ); should pass the test Thank you print keys(%some_hash) == 1

Re: only one of two hash keys

2006-04-04 Thread Lawrence Statton
> Is there a nice clean perl way to test to see if only one key of a hash > has data? > > %some_hash = ( key1 => 1, key2 => 2 ); should fail the test > %some_hash = ( key2 => 2 ); should pass the test > %some_hash = ( key1 => 1 ); should pass the test > %some_hash = ( key1 => 1, key2 => 2, key3 =>

Re: only one of two hash keys

2006-04-04 Thread perl
On Wed, 2006-04-05 at 09:35 +0800, Jeff Pang wrote: > Hello, > > [EMAIL PROTECTED] ~/app]$ perl -le '%some_hash=(aa=>'bb');scalar keys > %some_hash == 1 ? print "true" : print "false"' > true > [EMAIL PROTECTED] ~/app]$ perl -le '%some_hash=(aa=>'bb',cc=>'dd');scalar > keys %some_hash == 1 ? pri

Re: only one of two hash keys

2006-04-04 Thread Jeff Pang
some_hash == 1 ? print "true" : print "false"' false Is it useful for you? -Original Message- >From: perl <[EMAIL PROTECTED]> >Sent: Apr 5, 2006 9:26 AM >To: beginners@perl.org >Subject: only one of two hash keys > >Is there a nice clean perl way to

only one of two hash keys

2006-04-04 Thread perl
Is there a nice clean perl way to test to see if only one key of a hash has data? %some_hash = ( key1 => 1, key2 => 2 ); should fail the test %some_hash = ( key2 => 2 ); should pass the test %some_hash = ( key1 => 1 ); should pass the test Thank you -- To unsubscribe, e-mail: [EMAIL PROTECTED]