Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Hash problem

by Crian (Curate)
on Mar 06, 2004 at 23:42 UTC ( [id://334551]=note: print w/replies, xml ) Need Help??


in reply to Hash problem

I don't know exactly what your problem is, but perhaps this code could solve it? :)

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @lines; while (<DATA>) { my %line; ++$line{$_} for split /\s+/; push @lines, { %line }; } print Dumper \@lines; __DATA__ one two three three one two one one three


it prints

$VAR1 = [ { 'three' => 1, 'one' => 1, 'two' => 1 }, { 'three' => 1, 'one' => 1, 'two' => 1 }, { 'three' => 1, 'one' => 2 } ];

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found