Text::ParseWords can help in splitting the string up into tokens, and it's really nice when getting rid of quotes that may or may not be there:
use Text::ParseWords; <DATA>; while (<DATA>) { chomp; my @words = shellwords($_); print "ID: $words[0]\tCourse: $words[1]\n"; } __END__ "ID" "Course" 9414 "Nutitional Epidemiology" 9414 "Nutritional assessment" 9414 "Undernutrition in the United States" 1371 "Health Politics and Policy" 1371 "Advanced Health Politics?" 1371 "Introduction to Health Policy & Management"
If you separate out the printing, it's probably best to return a reference to @records, then pass that to the printing subroutine. You can probably also pass a list of hash keys to print (use a hash slice or a subset):
my @keys = qw ( ID Dept Fax); print ul( map { li("$_: $data{$_}") } @keys);
I think that's what you mean.

In reply to Re: getting the right stuff by chromatic
in thread getting the right stuff by malaga

Title:
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, details, 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, summary, 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.