Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Not able to print out hash contents correctly

by poolpi (Hermit)
on Mar 24, 2009 at 15:50 UTC ( #752905=note: print w/ replies, xml ) Need Help??


in reply to Not able to print out hash contents correctly

I would like to place each of these in a hash and increment a count

Your code could be simplified and fit your needs :

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my ( %h, $count ); while (<DATA>) { next unless /^>(\d+)/; $count++; defined $1 and $h{$1} = $count; } print Dumper \%h; __DATA__ >34513 -------------------------------MVAIIFDMDGVLYRG -----N-RAIPGVRELIEF-------LKE-R--------G------ >22476 ------------------------------ALKAVLVDLNGTLHI- --------AVPGAQEALKR--------------------------- >56832 ------MARCERLRGA-----ALRDVLG--RAQGVLFDCDGVLWNG- ----E-RAVPGAPELLER-------LAR------------------- >12543 ---------------------------E--QFDILLLDLDGVVYVG- ----D-RLLPGARRALRR----------------------------G >29078 ---------------------------------AVLFDIDGVLVLS- ----W-RAIPGAAETVRQ-------LTH-R--------G--------


hth,
PooLpi

'Ebry haffa hoe hab im tik a bush'. Jamaican proverb


Comment on Re: Not able to print out hash contents correctly
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://752905]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2015-07-07 07:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls