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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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


In reply to Re: Storing Info by nandeya
in thread Storing Info by sickboy

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (5)
    As of 2020-01-18 23:37 GMT
    Find Nodes?
      Voting Booth?