Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: First Perl Assignment... First taste of Perl: File, String Edit

by JavaFan (Canon)
on Oct 04, 2010 at 13:17 UTC ( [id://863337]=note: print w/replies, xml ) Need Help??


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.
  • Comment on Re: First Perl Assignment... First taste of Perl: File, String Edit
  • Download Code

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

    Indeed:

    print "$1 things\n" if "The point of the exercise here isn't deleting. It's selecting. +" =~ m/(select)ing/;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://863337]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-26 04:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found