Re: printing hash having undefined key

2014-06-23 Thread Shaji Kalidasan
nt if key exist . > > I guess it should not print value for undefined key , but it does . > > #!/usr/bin/perl -w > > @array = ("abc", 123, "dfg" ,456, "xsd",undef); > %hash = reverse @array; > > foreach $k (keys %hash){ > print "key $

printing hash having undefined key

2014-06-23 Thread Sunita Pradhan
array; foreach $k (keys %hash){ print "key $k value $hash{$k}\n" if(exists $hash{$k}); } And another issue is , I want to write one line code for printing hash like below: print "key $k value $hash{$k}\n" foreach $k (keys %hash); But it fails with error : syntax err

Re: Printing hash of hashes

2004-06-25 Thread Randal L. Schwartz
> "Lrmk" == Lrmk <[EMAIL PROTECTED]> writes: Lrmk> I used this code In a ASP code to display the entire content of hashes Lrmk> I did some changes to neke it pure perl it should be good for your job Instead of the core-module Data::Dumper? Why write your own? -- Randal L. Schwartz - Stone

Re: Printing hash outside of foreach loop

2004-06-25 Thread James Edward Gray II
On Jun 25, 2004, at 10:12 AM, Daniel Falkenberg wrote: Hi Wiggins, Thank you for your reply. I will go and use the Finance::Quote::ASX module. For now though this problem is really bugging me and for my own sake I would like to get it to work. I have declared all my variables and am using warning

Printing hash outside of foreach loop

2004-06-25 Thread Daniel Falkenberg
Hi Wiggins, Thank you for your reply. I will go and use the Finance::Quote::ASX module. For now though this problem is really bugging me and for my own sake I would like to get it to work. I have declared all my variables and am using warnings and strict. Unfortunarly I am still only able to print

RE: Printing hash of hashes

2004-06-25 Thread Bob Showalter
LRMK wrote: > if ($hash{$k} =~ m/=HASH/){ if (ref($hash{$k}) eq 'HASH') { perldoc -f ref -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Printing hash of hashes

2004-06-24 Thread LRMK
ix $k\t=\t$hash{$k}\n"; if ($hash{$k} =~ m/=HASH/){ my %th = %{$hash{$k}}; printIt($myfix . "\t", %th); } } } LRMK - Original Message - From: "Daniel Falkenberg" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, Ju

Re: Printing hash of hashes

2004-06-24 Thread Gunnar Hjalmarsson
Daniel Falkenberg wrote: I need to print my hash of hashes. For example... How can I print that in a readable format. Then I would like to be able to print for example... Simpsons, Lead, homer. Any ideas? http://www.perldoc.com/perl5.8.4/pod/perldsc.html -- Gunnar Hjalmarsson Email: http://www.gu

RE: Printing hash of hashes

2004-06-24 Thread Bob Showalter
Daniel Falkenberg wrote: > Hello All, > > I need to print my hash of hashes. For example... > > %HoH = ( > flintstones => { > lead => "fred", > pal => "barney", > }, > jetsons => { > lead => "george", >

Printing hash of hashes

2004-06-24 Thread Daniel Falkenberg
Hello All, I need to print my hash of hashes. For example... %HoH = ( flintstones => { lead => "fred", pal => "barney", }, jetsons => { lead => "george", wife => "jane",

RE: printing hash

2002-12-05 Thread Beau E. Cox
erl way to do what you want, hence the CPAN modules. Aloha => Beau. -Original Message- From: Duarte Cordeiro [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 05, 2002 4:16 AM To: [EMAIL PROTECTED] Subject: printing hash Hi, I have some data in a hash table, and I would like to pr

printing hash

2002-12-05 Thread Duarte Cordeiro
Hi, I have some data in a hash table, and I would like to print it in the same order as I created it. According to the user manual, "the result of foreach $key (keys %hash) is random-like". I tried it, and :) its true. Any way I can print it like I want ? Example: I need to print in the same or

Re: printing hash of a hash

2002-09-12 Thread david
Marija Silajev wrote: > Hi, > > I create a hash like following: > > > $Data{$KEYS} = { key1 => [@array1], > key2 => [@array2], > }; > > > with: > foreach $KEYS ( keys %Data){ > print "Key1 data : @{$Data{$KEYS}{key1}}\n"; > } > > I manage to print the w

RE: printing hash of a hash

2002-09-11 Thread NYIMI Jose (BMB)
A second loop: foreach $KEYS ( keys %Data){ print "Key1 data :\n"; map{ print $_,"\n" } @{$Data{$KEYS}{key1}}; } José. -Original Message- From: Marija Silajev [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 11, 2002 2:43 PM To: Perl Subject

Re: printing hash of a hash

2002-09-11 Thread Sudarshan Raghavan
On Wed, 11 Sep 2002, Marija Silajev wrote: > Hi, > > I create a hash like following: > > > $Data{$KEYS} = { key1 => [@array1], > key2 => [@array2], > }; > > > with: > foreach $KEYS ( keys %Data){ > print "Key1 data : @{$Data{$KEYS}{key1}}\n"; > } > > I

printing hash of a hash

2002-09-11 Thread Marija Silajev
Hi, I create a hash like following: $Data{$KEYS} = { key1 => [@array1], key2 => [@array2], }; with: foreach $KEYS ( keys %Data){ print "Key1 data : @{$Data{$KEYS}{key1}}\n"; } I manage to print the whole @array1 in one line like: Key1 data : 4321 432 76