poken1151 has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: First Perl Assignment... First taste of Perl: File, String Edit
by marto (Cardinal) on Oct 04, 2010 at 13:19 UTC | |
Re: First Perl Assignment... First taste of Perl: File, String Edit
by JavaFan (Canon) on Oct 04, 2010 at 13:17 UTC | |
by jettero (Monsignor) on Oct 04, 2010 at 13:21 UTC | |
Re: First Perl Assignment... First taste of Perl: File, String Edit
by GrandFather (Saint) on Oct 04, 2010 at 20:18 UTC | |
Re: First Perl Assignment... First taste of Perl: File, String Edit
by Anonymous Monk on Oct 04, 2010 at 20:16 UTC |