Hello Perl Monks,

So to begin, I have very little experience with Perl and was just handed an assignment for class.

What we need to accomplish is:
We are given a text document with some info in the form of <FIRST NAME> <LAST NAME> <NUMBERS>

We need to take this file and produce another that has simple
<first 4 of FIRSTNAME><last four of NUMBERS>

I've gotton as far as basic hello world in Perl and read some input from a file. I was wondering if someone out there could poit me to some brief tutorials that can help me to finish up how to do this, or if someone can explain a type of concept to complete this to me.

I was thinking putting each line into an array, and counting up to the 5th spot, and deleting until i reached the n-4th element and stopping... Since the data is already roughly in format.

One of the things i'm told Perl is great for is pattern matching and the sort, but how would I say "delete everything after the first 4 characters, until the 4th to last character? Any help or guidance or point to some good resource to help on this topic?


In reply to First Perl Assignment... First taste of Perl: File, String Edit by poken1151

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.