?
Solved

printing a hash

Posted on 2011-04-23
2
Medium Priority
?
262 Views
Last Modified: 2012-05-11
Hi Experts,

I have a hash that I wanted to print.  code snippet below.  This code works, but I want to print the contents
in a different order.

Now, it is printed like:

fileName  invalue1
   invalue2
   key

but, what I wanted is to print is as below.

fileName invalue
key
invalue2




sub storeUnique
  {
	my($inkey, $invalue1, $invalue2) = @_;
	push @ { $HashOfExceptions{$inkey}} , $invalue1, $invalue2;
  };

sub printHash
{
   my($filename) = @_;
   print "$filename\t";
   for $test (keys %HashOfExceptions )
	{		  
	     print "\t @{ $HashOfExceptions{$test}}\t$test\n";
	}
}

Open in new window

0
Comment
Question by:ambuli
2 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 35452141
sub storeUnique
  {
      my($inkey, $invalue1, $invalue2) = @_;
      push @ { $HashOfExceptions{$inkey}} , $invalue1, $inkey, $invalue2;
  };

sub printHash
{
   my($filename) = @_;
   print "$filename\t";
   for $test (keys %HashOfExceptions )
      {              
           print "\t @{ $HashOfExceptions{$test}}\n";
      }
}

0
 

Author Comment

by:ambuli
ID: 35452149
Thank you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question