Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 taking refuge in the Monastery: (8)
As of 2014-08-21 18:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (141 votes), past polls