Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Storing Info

by nandeya (Monk)
on Jan 22, 2002 at 01:06 UTC ( #140492=note: print w/ replies, xml ) Need Help??


in reply to Storing Info

Lunchtime homework is always fun when you are learning all of this stuff (like I am), and dvergin has already done all of the hard work / taken us 90% of the way there. So here is a pass at with most of what he did then just played with the grep statement to get it to work as discussed in the thread:

#!/usr/bin/perl -w use strict; open(DATA,"D:/JUNK/commafile.csv"); my @friends; my @raw_list = <DATA>; chomp @raw_list; for (@raw_list) { my @bits = split(/,/, $_); my $sucker= {FIRSTNAME => $bits[0], LASTNAME => $bits[1], HAIRCOLOR => $bits[2]}; push @friends, $sucker; } my @real_friends = grep { lc(substr($_->{FIRSTNAME},0,1)) eq "j" && $_->{HAIRCOLOR} eq "brown" } @friends; foreach (@real_friends) { print "Only real friends have \'$_->{HAIRCOLOR}\' hair "; print " and names which begin with 'j' like my friend "; print "\'$_->{FIRSTNAME} $_->{LASTNAME}\'\n"; if (($_->{FIRSTNAME} eq "John") && ($_->{LASTNAME} eq "Kennedy")) { print " Hey 'nandaya' you Novice level chump, "; print "I know John Kennedy, \n"; print " I worked with John Kennedy, and 'nandeya', "; print "you're no friend of John Kennedy.\n"; } } __DATA__ John,Brown,red Fred,Flintstone,black Jane,Brown,blond Betty, Rubble,black John,Kennedy,brown Jodi,Brown,brown Bill,Black,blond June,Green,brown John,McEnroe,brown Erin,White,brown

nandeya


Comment on Re: Storing Info
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2014-07-30 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (241 votes), past polls