in reply to First Perl Assignment... First taste of Perl: File, String Edit
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...This is Perl, not C. In Perl, strings are first class citizens. Do not think of strings as arrays of integers.
delete everything after the first 4 characters, until the 4th to last character?The point of the exercise here isn't deleting. It's selecting. Selecting based on character count. Use substr for that. And since it's a class assignment, I leave it to this.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: First Perl Assignment... First taste of Perl: File, String Edit
by jettero (Monsignor) on Oct 04, 2010 at 13:21 UTC |