Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: pushing similar lines into arrays

by jweed (Chaplain)
on Mar 18, 2004 at 05:02 UTC ( [id://337609]=note: print w/replies, xml ) Need Help??


in reply to pushing similar lines into arrays

Well, this smells like homework, but I'd do it like this:
use strict; my $head; my %hash; while (<>) { $head = (split)[0]; push @{$hash{$head}}, $_; }
Update: Sigh. I'm late.



Code is (almost) always untested.
http://www.justicepoetic.net/

Replies are listed 'Best First'.
Re: Re: pushing similar lines into arrays
by Phydro (Initiate) on Mar 18, 2004 at 05:18 UTC
    Thanks jweed, I will actually take that as a compliment (smells like homework). Actually, doing a project for work, and am but a wee yung'un in the Perl world...

Log In?
Username:
Password:

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

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

    No recent polls found