Re: How to check empty hash value properly?

2008-10-08 Thread Rob Dixon
Rob Dixon wrote: > > I don't think so. $#array returns the index of the last existent element of > the > array. The one which pop() will delete and return, and the one after which > push() will add an element. > > I'm not sure what you mean about 'while', but an array evaluates as true if it > h

Re: How to check empty hash value properly?

2008-10-08 Thread Lawrence Statton
> This distinction between canonical existence and logical existence--or > perhaps more properly the distinction between the existence of an > element and of a position--is important because, while useful, the > distinction does have implications for the value of $#array, the > return value of scal

Re: How to check empty hash value properly?

2008-10-08 Thread Rob Dixon
Jay Savage wrote: > On Wed, Oct 8, 2008 at 11:24 AM, Rob Dixon <[EMAIL PROTECTED]> wrote: >> >> The return value of exists() is the definition of whether an array or hash >> elements exists. It does exactly what it is documented to do and does not >> lie. >> >> The idea of non-existent mid-range a

Re: How to check empty hash value properly?

2008-10-08 Thread John W. Krahn
Jay Savage wrote: On Wed, Oct 8, 2008 at 11:24 AM, Rob Dixon <[EMAIL PROTECTED]> wrote: Jay Savage wrote: On Tue, Oct 7, 2008 at 4:09 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: John W. Krahn wrote: Incorrect, delete does not remove array elements: $ perl -le'use Data::Dumper; my @a = "a".."d";

Re: How to check empty hash value properly?

2008-10-08 Thread Jay Savage
On Wed, Oct 8, 2008 at 11:24 AM, Rob Dixon <[EMAIL PROTECTED]> wrote: > Jay Savage wrote: >> On Tue, Oct 7, 2008 at 4:09 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: >>> John W. Krahn wrote: Incorrect, delete does not remove array elements: $ perl -le'use Data::Dumper; my @a = "a"..

Re: How to check empty hash value properly?

2008-10-08 Thread Rob Dixon
Jay Savage wrote: > On Tue, Oct 7, 2008 at 4:09 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: >> John W. Krahn wrote: >>> >>> Incorrect, delete does not remove array elements: >>> >>> $ perl -le'use Data::Dumper; my @a = "a".."d"; delete $a[1]; print >>> Dumper [EMAIL PROTECTED]' >>> $VAR1 = [ >>>

Re: How to check empty hash value properly?

2008-10-07 Thread Mr. Shawn H. Corey
On Tue, 2008-10-07 at 22:01 -0400, Jay Savage wrote: > On Tue, Oct 7, 2008 at 4:09 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > > John W. Krahn wrote: > [snip] > >> Incorrect, delete does not remove array elements: > >> > >> $ perl -le'use Data::Dumper; my @a = "a".."d"; delete $a[1]; print > >> Dump

Re: How to check empty hash value properly?

2008-10-07 Thread Jay Savage
On Tue, Oct 7, 2008 at 4:09 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > John W. Krahn wrote: [snip] >> Incorrect, delete does not remove array elements: >> >> $ perl -le'use Data::Dumper; my @a = "a".."d"; delete $a[1]; print >> Dumper [EMAIL PROTECTED]' >> $VAR1 = [ >>'a', >>

Re: How to check empty hash value properly?

2008-10-07 Thread Mr. Shawn H. Corey
On Tue, 2008-10-07 at 21:09 +0100, Rob Dixon wrote: > Incorrect, delete does not remove array elements: > > > > $ perl -le'use Data::Dumper; my @a = "a".."d"; delete $a[1]; print > > Dumper [EMAIL PROTECTED]' > > $VAR1 = [ > >'a', > >undef, > >'c', > >

Re: How to check empty hash value properly?

2008-10-07 Thread Rob Dixon
John W. Krahn wrote: > Rob Dixon wrote: >> loody wrote: if( exists $data{$key} ){ print "\t\$data{$key} exists\n"; >>> thanks for your kind help. >>> Could I get the conclusion that exists is only used for determining >>> the element of hash and arrays? >>> appreciate your help, >> Co

Re: How to check empty hash value properly?

2008-10-07 Thread John W. Krahn
Rob Dixon wrote: loody wrote: if( exists $data{$key} ){ print "\t\$data{$key} exists\n"; thanks for your kind help. Could I get the conclusion that exists is only used for determining the element of hash and arrays? appreciate your help, Consider this program. use strict; use warning

Re: How to check empty hash value properly?

2008-10-07 Thread Rob Dixon
loody wrote: >> if( exists $data{$key} ){ >>print "\t\$data{$key} exists\n"; > > thanks for your kind help. > Could I get the conclusion that exists is only used for determining > the element of hash and arrays? > appreciate your help, Consider this program. use strict; use warnings;

Re: How to check empty hash value properly?

2008-10-06 Thread Jeff Pang
tails see: http://perldoc.perl.org/functions/exists.html > Message du 07/10/08 05:05 > De : "loody" > A : "Mr. Shawn H. Corey" > Copie à : "Raymond Wan" , "Perl beginners" > Objet : Re: How to check empty hash value properly? > > &g

Re: How to check empty hash value properly?

2008-10-06 Thread loody
> if( exists $data{$key} ){ >print "\t\$data{$key} exists\n"; Hi: thanks for your kind help. Could I get the conclusion that exists is only used for determining the element of hash and arrays? appreciate your help, miloody -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands,

Re: How to check empty hash value properly?

2008-10-06 Thread John W. Krahn
loody wrote: Dear all: Hello, I want to use hash to keep my records. But before using it, I want to determine whether the value of the key exist? perldoc -q "What.s the difference between .delete. and .undef. with hashes" John -- Perl isn't a toolbox, but a small machine shop where you ca

Re: How to check empty hash value properly?

2008-10-06 Thread Mr. Shawn H. Corey
On Mon, 2008-10-06 at 22:35 +0900, Raymond Wan wrote: > Try: > > if (defined $hash{$key}) { > ... > Defined is not the same as exists. #!/usr/bin/perl use strict; use warnings; my %data = ( b => undef, c => 1, ); for my $key ( qw( a b c ) ){ print "\$key = $key\n"; if( exists $data{$

Re: How to check empty hash value properly?

2008-10-06 Thread Raymond Wan
Hi Miloody, Try: if (defined $hash{$key}) { ... Ray loody wrote: Dear all: I want to use hash to keep my records. But before using it, I want to determine whether the value of the key exist? Below is my source code: if($hash{$key} eq "") { print "the value of the $key is empty\n";

Re:How to check empty hash value properly?

2008-10-06 Thread Jeff Pang
> Message du 06/10/08 15:25 > De : "loody" > A : "Perl beginners" > Copie à : > Objet : How to check empty hash value properly? > > > Dear all: > I want to use hash to keep my records. > But before using it, I want to determine whether the value

How to check empty hash value properly?

2008-10-06 Thread loody
Dear all: I want to use hash to keep my records. But before using it, I want to determine whether the value of the key exist? Below is my source code: if($hash{$key} eq "") { print "the value of the $key is empty\n"; $hash{$key}=1; } else { $hash{$key}++; } It works but I wi

Re: Check empty hash

2005-11-16 Thread John W. Krahn
Suvajit Sengupta wrote: > Hi, Hello, > How can I test whether a hash is empty or not ? > For e.g: I have reference to a hash , say $preCommand and I get > $preCommands as {} , > Its an empty hash, but it exists and is also defined. > I need to check whether the hash is

Re: Check empty hash

2005-11-16 Thread Suvajit Sengupta
Thanx, Beau ..it worked !! Regards, Suvajit Beau E. Cox wrote: Hi Suvajit Sengupta - At 2005-11-16, 01:32:31 you wrote: Hi, How can I test whether a hash is empty or not ? For e.g: I have reference to a hash , say $preCommand and I get $preCommands as {} , Its an

Re: Check empty hash

2005-11-16 Thread Beau E. Cox
Hi Suvajit Sengupta - At 2005-11-16, 01:32:31 you wrote: >Hi, > How can I test whether a hash is empty or not ? >For e.g: I have reference to a hash , say $preCommand and I get > $preCommands as {} , > Its an empty hash, but it exists and is also defined. >I need to ch

Re: Check empty hash

2005-11-16 Thread Suvajit Sengupta
); If the output is VAR1= {}; Then there are no entries in the has tables HTH Regards, Shaman -Original Message- From: Suvajit Sengupta [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 16, 2005 4:33 PM To: Perl Beginners List Subject: Check empty hash Hi, How can I test whether a

Check empty hash

2005-11-16 Thread Suvajit Sengupta
Hi, How can I test whether a hash is empty or not ? For e.g: I have reference to a hash , say $preCommand and I get $preCommands as {} , Its an empty hash, but it exists and is also defined. I need to check whether the hash is empty or not. Does anyone has any clue ? Re