uninitialized error for hash printing

2014-06-22 Thread Sunita Pradhan
I have following code for printing a simple hash.

#!/usr/bin/perl -w
 

%hash = (abc = 123, dfg = 456, xsd = 34);

foreach $k (keys %hash){
 print key $k:: value $hash{$k}\n;
 }


It does not print keys and displays following warnings:

--
Use of uninitialized value $k:: in concatenation (.) or string at hash_test2.pl
line 7.
key  value 34
Use of uninitialized value $k:: in concatenation (.) or string at hash_test2.pl
line 7.
key  value 123
Use of uninitialized value $k:: in concatenation (.) or string at hash_test2.pl
line 7.
key  value 456


Never happened like this with hash . I am not sure where I am going wrong .





-Sunita































































  

Re: uninitialized error for hash printing

2014-06-22 Thread John Delacour

On 22 Jun 2014, at 21:01, Sunita Pradhan sunita.pradhan.2...@hotmail.com 
wrote:

 I have following code for printing a simple hash.
 
 #!/usr/bin/perl -w
 %hash = (abc = 123, dfg = 456, xsd = 34);
 foreach $k (keys %hash){
  print key $k:: value $hash{$k}\n;
  }
 --
 Use of uninitialized value $k:: in concatenation (.) or string at 
 hash_test2.pl

Try this:

#!/usr/bin/perl -w
use strict;
my %hash = (
abc = 123,
dfg = 456,
xsd = 34
);
foreach my $k (keys %hash){
print key $k\:: value $hash{$k}\n;
}

#JD



Re: uninitialized error for hash printing

2014-06-22 Thread Uri Guttman

On 06/22/2014 04:01 PM, Sunita Pradhan wrote:

I have following code for printing a simple hash.

#!/usr/bin/perl -w


%hash = (abc = 123, dfg = 456, xsd = 34);

foreach $k (keys %hash){
  print key $k:: value $hash{$k}\n;
  }


It does not print keys and displays following warnings:

--
Use of uninitialized value $k:: in concatenation (.) or string at hash_test2.pl
line 7.


your bug is putting ::after the $k. that makes it a package variable in 
the k:: namespace and there is nothing there. remove the :: or use some 
other marker or a space before the ::.


uri


--
Uri Guttman - The Perl Hunter
The Best Perl Jobs, The Best Perl Hackers
http://PerlHunter.com

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: uninitialized error for hash printing

2014-06-22 Thread Shaji Kalidasan
Hi Sunita,

As per Uri's suggestions, here's one way to make it work by surrounding the
variable with curly braces

[code]
%hash = (abc = 123, dfg = 456, xsd = 34);

foreach $k (keys %hash){
 print key ${k}:: value $hash{$k}\n;
 }
[/code]

[output]
key abc:: value 123
key dfg:: value 456
key xsd:: value 34
[/output]

Hope it helps.


On Mon, Jun 23, 2014 at 1:31 AM, Sunita Pradhan 
sunita.pradhan.2...@hotmail.com wrote:

 I have following code for printing a simple hash.

 #!/usr/bin/perl -w


 %hash = (abc = 123, dfg = 456, xsd = 34);

 foreach $k (keys %hash){
  print key $k:: value $hash{$k}\n;
  }


 It does not print keys and displays following warnings:

 --
 Use of uninitialized value $k:: in concatenation (.) or string at
 hash_test2.pl
 line 7.
 key  value 34
 Use of uninitialized value $k:: in concatenation (.) or string at
 hash_test2.pl
 line 7.
 key  value 123
 Use of uninitialized value $k:: in concatenation (.) or string at
 hash_test2.pl
 line 7.
 key  value 456


 Never happened like this with hash . I am not sure where I am going wrong .





 -Sunita


































































-- 
best,
Shaji
--
Your talent is God's gift to you. What you do with it is your gift back to
God.
--


Re: Traversing Hash printing two times

2010-09-03 Thread Uri Guttman
 JD == Jatin Davey jasho...@cisco.com writes:

   but it isn't as good as my code. don't use $_ unless you have to (as in
   map/grep). it is much better to use named variables.
  JD Any reason to use named variables than to use the default variable ($_) ?

yes, you can read the code and see what the variable is for. $_ is
useful in some situations but not for foreach loops and similar
things. names are important in code and $_ has no name. you lose the
opportunity to tell the reader of the code what the variable contains
and what it is used for.

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Traversing Hash printing two times

2010-09-03 Thread Jatin Davey



yes, you can read the code and see what the variable is for. $_ is
useful in some situations but not for foreach loops and similar
things. names are important in code and $_ has no name. you lose the
opportunity to tell the reader of the code what the variable contains
and what it is used for.

uri


Thank Uri , I will keep that in mind.

Thanks
Jatin

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Traversing Hash printing two times

2010-09-03 Thread Jim Gibson

At 11:29 AM +0530 9/3/10, Jatin Davey wrote:


Any reason to use named variables than to use the default variable ($_) ?


Two reasons that I know:

1. If you use a named variable, you and everybody else reading your 
code will know what it is for. While it doesn't matter much for 
3-line loops, short programs tend to turn into longer ones, and then 
you really should be using named variables.


2. The default variable $_ can get clobbered by some operations. If 
you use $_, you have to be careful to avoid such operations. It is 
much better not to have to worry.


Quiz for extra credit: Uri's program has a misleadingly-named 
variable. Can you figure out what it is?


--
Jim Gibson
j...@gibson.org

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Traversing Hash printing two times

2010-09-03 Thread John W. Krahn

Uri Guttman wrote:

JD == Jatin Daveyjasho...@cisco.com  writes:


 but it isn't as good as my code. don't use $_ unless you have to (as in
 map/grep). it is much better to use named variables.
   JD  Any reason to use named variables than to use the default variable ($_) 
?

yes, you can read the code and see what the variable is for. $_ is
useful in some situations but not for foreach loops and similar
things. names are important in code and $_ has no name. you lose the
opportunity to tell the reader of the code what the variable contains
and what it is used for.


Yes, and using $month for the keys 'english' and 'french' does not 
really do that.  Perhaps using $language would have been better?




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Traversing Hash printing two times

2010-09-03 Thread Uri Guttman
 JWK == John W Krahn jwkr...@shaw.ca writes:

  JWK Uri Guttman wrote:
   JD == Jatin Daveyjasho...@cisco.com  writes:
   
 but it isn't as good as my code. don't use $_ unless you have to (as in
 map/grep). it is much better to use named variables.
  JD Any reason to use named variables than to use the default variable ($_) ?
   
   yes, you can read the code and see what the variable is for. $_ is
   useful in some situations but not for foreach loops and similar
   things. names are important in code and $_ has no name. you lose the
   opportunity to tell the reader of the code what the variable contains
   and what it is used for.

  JWK Yes, and using $month for the keys 'english' and 'french' does not
  JWK really do that.  Perhaps using $language would have been better?

my bad. i was seeing months all over the code so that stuck.

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Traversing Hash printing two times

2010-09-03 Thread Uri Guttman
 JG == Jim Gibson jimsgib...@gmail.com writes:

  JG At 11:29 AM +0530 9/3/10, Jatin Davey wrote:
   Any reason to use named variables than to use the default variable ($_) ?

  JG Two reasons that I know:

  JG 1. If you use a named variable, you and everybody else reading your
  JG code will know what it is for. While it doesn't matter much for 3-line
  JG loops, short programs tend to turn into longer ones, and then you
  JG really should be using named variables.

  JG 2. The default variable $_ can get clobbered by some operations. If
  JG you use $_, you have to be careful to avoid such operations. It is
  JG much better not to have to worry.

  JG Quiz for extra credit: Uri's program has a misleadingly-named
  JG variable. Can you figure out what it is?

and john pointed it out already so no cheating. a brainfart on my part.

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Traversing Hash printing two times

2010-09-02 Thread Jatin Davey

 Hi

I am a newbie to Perl , I have this piece of code :

*CODE:*

#!/usr/bin/perl
use warnings;
use strict;

my @english = qw(january february march april may june july);
my @french = qw(janvier fverier mars avril mai juin juily);

my %months;
my $eng_ref;
my $fre_ref;

$eng_ref = \...@english;
$fre_ref = \...@french;

$months{english} = $eng_ref;
$months{french} = $fre_ref;

for (keys %months) {
print Months in english : @{$months{english}} \n;
print Months in french : @{$months{french}} \n;
}


*OUTPUT:*

Months in english : january february march april may june july
Months in french : janvier fverier mars avril mai juin juily
Months in english : january february march april may june july
Months in french : janvier fverier mars avril mai juin juily


*Question*

Why do i get the array that i wanted two times ?
i have just added two keys into the hash then why do i get the values 
two times.


Please explain me this.

Thanks
Jatin


Re: Traversing Hash printing two times

2010-09-02 Thread Uri Guttman
 JD == Jatin Davey jasho...@cisco.com writes:

  JD #!/usr/bin/perl
  JD use warnings;
  JD use strict;

very good to see those.

  JD my @english = qw(january february march april may june july);
  JD my @french = qw(janvier fverier mars avril mai juin juily);

  JD my %months;
  JD my $eng_ref;
  JD my $fre_ref;

  JD $eng_ref = \...@english;
  JD $fre_ref = \...@french;

no need for that. you can assign the refs directly into the hash.

  JD $months{english} = $eng_ref;
  JD $months{french} = $fre_ref;

  JD for (keys %months) {

that is assigning each key to $_. you never use $_. so this will loop
TWO times as there are two keys.

  JD print Months in english : @{$months{english}} \n;
  JD print Months in french : @{$months{french}} \n;

so both lines get printed twice.

what you want is more likely this:

foreach my $month (keys %months) {

print Months in $month : @{$months{$month}}\n;
}

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Traversing Hash printing two times

2010-09-02 Thread Jatin Davey

 Changed it to:

#!/usr/bin/perl
use warnings;
use strict;

my @english = qw(january february march april may june july);
my @french = qw(janvier fverier mars avril mai juin juily);
my %months;

$months{english} = \...@english;
$months{french} = \...@french;

for (keys %months) {
print Months in $_ : @{$months{$_}} \n;
}

and it worked fine.

Thanks Uri.

Thanks
Jatin

On 9/3/2010 10:47 AM, Uri Guttman wrote:

JD == Jatin Daveyjasho...@cisco.com  writes:

   JD  #!/usr/bin/perl
   JD  use warnings;
   JD  use strict;

very good to see those.

   JD  my @english = qw(january february march april may june july);
   JD  my @french = qw(janvier fverier mars avril mai juin juily);

   JD  my %months;
   JD  my $eng_ref;
   JD  my $fre_ref;

   JD  $eng_ref = \...@english;
   JD  $fre_ref = \...@french;

no need for that. you can assign the refs directly into the hash.

   JD  $months{english} = $eng_ref;
   JD  $months{french} = $fre_ref;

   JD  for (keys %months) {

that is assigning each key to $_. you never use $_. so this will loop
TWO times as there are two keys.

   JD  print Months in english : @{$months{english}} \n;
   JD  print Months in french : @{$months{french}} \n;

so both lines get printed twice.

what you want is more likely this:

foreach my $month (keys %months) {

print Months in $month : @{$months{$month}}\n;
}

uri



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Traversing Hash printing two times

2010-09-02 Thread Uri Guttman
 JD == Jatin Davey jasho...@cisco.com writes:

  JD for (keys %months) {
  JD print Months in $_ : @{$months{$_}} \n;
  JD }

  JD and it worked fine.

but it isn't as good as my code. don't use $_ unless you have to (as in
map/grep). it is much better to use named variables. 


  JD On 9/3/2010 10:47 AM, Uri Guttman wrote:
   JD == Jatin Daveyjasho...@cisco.com  writes:
  JD #!/usr/bin/perl
  JD use warnings;
  JD use strict;

and please learn to edit quoted emails and to bottom post. you can google for
what that means. i don't need to see (nor does anyone else) my entire
email again.

thanx,

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Traversing Hash printing two times

2010-09-02 Thread Jatin Davey



but it isn't as good as my code. don't use $_ unless you have to (as in
map/grep). it is much better to use named variables.

Any reason to use named variables than to use the default variable ($_) ?

and please learn to edit quoted emails and to bottom post. you can google for
what that means. i don't need to see (nor does anyone else) my entire
email again.

Sure , I ll learn to do so. Hope this reply is fine.

thanx,

uri


Thanks
Jatin

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: HASH PRINTING

2003-04-04 Thread [EMAIL PROTECTED]
I started to write it but didn't reach to finish it.
Any way, the main idea is
unless (ref = scalar) {
  if (ref = hash) {
enter another layer
  }
  elsif (ref = array) {
print @Array
  }
}
print $HASH{$KEY}

HTH,
Yargo!


Original Message:
-
From: R. Joseph Newton [EMAIL PROTECTED]
Date: Thu, 03 Apr 2003 18:04:43 -0800
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Re: HASH PRINTING


Eric Walker wrote:

 I have a HASH with a mixture of single, double and triple layers.
 exampl hash of hash of array's etc
 I try to dump and see values of the entire db but I get pointers and
 memory addresses.  Below is my code  Please help.

 foreach my $item (keys %hData){
 print ($item: $hData{$item}\n);
 }

 Thanks
 Eric

Stay tuned on this list.  I am creating this some plumbing facilites for
such structures on another thread.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



mail2web - Check your email from the web at
http://mail2web.com/ .



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: HASH PRINTING

2003-04-04 Thread Eric Walker
[EMAIL PROTECTED] wrote:

 I started to write it but didn't reach to finish it.
 Any way, the main idea is
 unless (ref = scalar) {
   if (ref = hash) {
 enter another layer
   }
   elsif (ref = array) {
 print @Array
   }
 }
 print $HASH{$KEY}

 HTH,
 Yargo!

 Original Message:
 -
 From: R. Joseph Newton [EMAIL PROTECTED]
 Date: Thu, 03 Apr 2003 18:04:43 -0800
 To: [EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject: Re: HASH PRINTING

 Eric Walker wrote:

  I have a HASH with a mixture of single, double and triple layers.
  exampl hash of hash of array's etc
  I try to dump and see values of the entire db but I get pointers and
  memory addresses.  Below is my code  Please help.
 
  foreach my $item (keys %hData){
  print ($item: $hData{$item}\n);
  }
 
  Thanks
  Eric

 Stay tuned on this list.  I am creating this some plumbing facilites for
 such structures on another thread.

 Joseph

 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

 
 mail2web - Check your email from the web at
 http://mail2web.com/ .

 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

Sorry for the ignorance but I think I am able to pull the first layer of
the hash but the values that are also hashes or arrays I get memory
pointers out .

For example:

TEMP: 2.0
TEMP5: ARRAY(0xdb660)
TEMP6: HASH(0xa2058)

Any suggestions on how to access the array and or hash at that point?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: HASH PRINTING

2003-04-04 Thread Wiggins d'Anconia


Eric Walker wrote:

Sorry for the ignorance but I think I am able to pull the first layer of
the hash but the values that are also hashes or arrays I get memory
pointers out .
For example:

TEMP: 2.0
TEMP5: ARRAY(0xdb660)
TEMP6: HASH(0xa2058)
Any suggestions on how to access the array and or hash at that point?

Welcome to the world of references... now for some bedtime reading...

perldoc -f ref
perldoc UNIVERSAL::isa
perldoc perldsc
perldoc perlreftut
perldoc perlref
After you have digested some of the above (don't worry you won't get it 
all the first time through) give it another shot and then ask more 
questions

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: HASH PRINTING

2003-04-04 Thread R. Joseph Newton
Eric Walker wrote:


 Sorry for the ignorance but I think I am able to pull the first layer of
 the hash but the values that are also hashes or arrays I get memory
 pointers out .

Not exactly.  Those are references.  The difference in some ways is suble, but
the upshot is that you shold never try to do pointer aritmetic on references.

 For example:

 TEMP: 2.0
 TEMP5: ARRAY(0xdb660)
 TEMP6: HASH(0xa2058)

 Any suggestions on how to access the array and or hash at that point?

To access a hash element from a reference to the hash:
$hash_ref-{$key} or $hash_ref-{'My_literal_key_name'}

To access an array element from a reference to the array:
$array_ref-[0] or $array_ref-[$n]

See the list of perldoc references sent by Wiggins d'Anconia
.
Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



HASH PRINTING

2003-04-03 Thread Eric Walker
I have a HASH with a mixture of single, double and triple layers.
exampl hash of hash of array's etc
I try to dump and see values of the entire db but I get pointers and
memory addresses.  Below is my code  Please help.

foreach my $item (keys %hData){
print ($item: $hData{$item}\n);
}

Thanks
Eric


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

RE: HASH PRINTING

2003-04-03 Thread David Olbersen
Eric,

Use Data::Dumper, it'll do this very well if it's just for debugging purposes.

Check out the documentation on cpan.org:

http://search.cpan.org/author/JHI/perl-5.8.0/ext/Data/Dumper/Dumper.pm

or `man Data::Dumper` if you're on a UNIX machine.

--
David Olbersen 
iGuard Engineer
11415 West Bernardo Court 
San Diego, CA 92127 
1-858-676-2277 x2152


 -Original Message-
 From: Eric Walker [mailto:[EMAIL PROTECTED]
 Sent: Thursday, April 03, 2003 11:37 AM
 To: [EMAIL PROTECTED]
 Subject: HASH PRINTING
 
 
 I have a HASH with a mixture of single, double and triple layers.
 exampl hash of hash of array's etc
 I try to dump and see values of the entire db but I get pointers and
 memory addresses.  Below is my code  Please help.
 
 foreach my $item (keys %hData){
 print ($item: $hData{$item}\n);
 }
 
 Thanks
 Eric
 
 
 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: HASH PRINTING

2003-04-03 Thread Eric Walker
David Olbersen wrote:

 Eric,

 Use Data::Dumper, it'll do this very well if it's just for debugging purposes.

 Check out the documentation on cpan.org:

 http://search.cpan.org/author/JHI/perl-5.8.0/ext/Data/Dumper/Dumper.pm

 or `man Data::Dumper` if you're on a UNIX machine.

 --
 David Olbersen
 iGuard Engineer
 11415 West Bernardo Court
 San Diego, CA 92127
 1-858-676-2277 x2152

  -Original Message-
  From: Eric Walker [mailto:[EMAIL PROTECTED]
  Sent: Thursday, April 03, 2003 11:37 AM
  To: [EMAIL PROTECTED]
  Subject: HASH PRINTING
 
 
  I have a HASH with a mixture of single, double and triple layers.
  exampl hash of hash of array's etc
  I try to dump and see values of the entire db but I get pointers and
  memory addresses.  Below is my code  Please help.
 
  foreach my $item (keys %hData){
  print ($item: $hData{$item}\n);
  }
 
  Thanks
  Eric
 
 
 

 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

I don't know if I am reading the data dumper help code right but it seems you
have to provide a list of the hash keys to get the values.  I need a way to
just print out all keys and values no matter how many levels of hierachy there
may be in the hash.

Thanks
Eric

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: HASH PRINTING

2003-04-03 Thread Pete Emerson
Data::Dumper works for me. You don't need to provide a list of the hash 
keys.

#!/usr/bin/perl -w

use strict;
use Data::Dumper;

my %hash;

$hash{one}=1;
$hash{two}{one}=2.1;
$hash{three}{one}{one}=3.11;

print Dumper(%hash);

###

$VAR1 = 'one';
$VAR2 = 1;
$VAR3 = 'three';
$VAR4 = {
  'one' = {
 'one' = '3.11'
   }
};
$VAR5 = 'two';
$VAR6 = {
  'one' = '2.1'
};


###

Apr 3, 2003 at 1:53pm from Eric Walker:

EW I don't know if I am reading the data dumper help code right but it seems you
EW have to provide a list of the hash keys to get the values.  I need a way to
EW just print out all keys and values no matter how many levels of hierachy there
EW may be in the hash.

-- 
http://emerson.wss.yale.edu/perl
Pete Emerson
WSS AMT Yale University


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: HASH PRINTING

2003-04-03 Thread Jenda Krynicky
From: Eric Walker [EMAIL PROTECTED]
 David Olbersen wrote:
   From: Eric Walker [mailto:[EMAIL PROTECTED]
  
   I have a HASH with a mixture of single, double and triple layers.
   exampl hash of hash of array's etc I try to dump and see
   values of the entire db but I get pointers and memory addresses. 
   Below is my code  Please help.
  
   foreach my $item (keys %hData){
   print ($item: $hData{$item}\n);
   }
  Eric,
 
  Use Data::Dumper, it'll do this very well if it's just for debugging
  purposes.
 
  Check out the documentation on cpan.org:
 
  http://search.cpan.org/author/JHI/perl-5.8.0/ext/Data/Dumper/Dumper.
  pm
 
  or `man Data::Dumper` if you're on a UNIX machine.
 
 I don't know if I am reading the data dumper help code right but it
 seems you have to provide a list of the hash keys to get the values. 
 I need a way to just print out all keys and values no matter how many
 levels of hierachy there may be in the hash.
 
 Thanks
 Eric

No you are not reading it correctly.
Just try and see.

print Dumper(\%hData);

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: HASH PRINTING

2003-04-03 Thread Eric Walker
Jenda Krynicky wrote:

 From: Eric Walker [EMAIL PROTECTED]
  David Olbersen wrote:
From: Eric Walker [mailto:[EMAIL PROTECTED]
   
I have a HASH with a mixture of single, double and triple layers.
exampl hash of hash of array's etc I try to dump and see
values of the entire db but I get pointers and memory addresses.
Below is my code  Please help.
   
foreach my $item (keys %hData){
print ($item: $hData{$item}\n);
}
   Eric,
  
   Use Data::Dumper, it'll do this very well if it's just for debugging
   purposes.
  
   Check out the documentation on cpan.org:
  
   http://search.cpan.org/author/JHI/perl-5.8.0/ext/Data/Dumper/Dumper.
   pm
  
   or `man Data::Dumper` if you're on a UNIX machine.
 
  I don't know if I am reading the data dumper help code right but it
  seems you have to provide a list of the hash keys to get the values.
  I need a way to just print out all keys and values no matter how many
  levels of hierachy there may be in the hash.
 
  Thanks
  Eric

 No you are not reading it correctly.
 Just try and see.

 print Dumper(\%hData);

 Jenda
 = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
 When it comes to wine, women and song, wizards are allowed
 to get drunk and croon as much as they like.
 -- Terry Pratchett in Sourcery

 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

Thanks. I am getting output now.  lets just hope I can pick it up the right
way and print to file in formatted output.

Thanks
E

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: HASH PRINTING

2003-04-03 Thread R. Joseph Newton
Eric Walker wrote:

 I have a HASH with a mixture of single, double and triple layers.
 exampl hash of hash of array's etc
 I try to dump and see values of the entire db but I get pointers and
 memory addresses.  Below is my code  Please help.

 foreach my $item (keys %hData){
 print ($item: $hData{$item}\n);
 }

 Thanks
 Eric

Stay tuned on this list.  I am creating this some plumbing facilites for such 
structures on another thread.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]