I'm brand new at PERL and really have no idea what I'm doing. The professor of my class just threw us this program to write and I don't even know PERL syntax and I'm scrambling to get it done. Basically we have to read in a file that has fake student information on it and then convert it to HTML. The file looks something like this: 123456,Susie_Smith,Computer_Science,ssmith@usomewhere.edu 234567,John_Smith,Computer_Engineering,jsmith@usomewhere.edu

Where the first number is the student ID,then name, major, and email address.

After opening the file it is suppose to look like this as an output:

ID: 123456

Name: Susie Smith

Major: Computer Science

Email: ssmith@usomewhere.edu

etc.

I've got to the point where I can open the file and read it out but it looks like this:

ID: 123456

ID: Susie Smith

ID: Computer Science

ID: ssmith@usomewhere.edu

How do I break up each sentence on the .txt file (without changing it) so that it displays what it needs to? My code looks like this:

#!/usr/bin/perl use strict; use warnings; open FILE, "/home/ajb004/Paradigms/roster.txt" or die $!; while ( <FILE> ) { $_; my @word = split(','); foreach my $word (@word) { $_ = $word; s/_/ /g; print "ID: $_\n"; } }

Am I even on the right track?


In reply to Help Me! by ajbrewe

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.