Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: A maybe rather silly question...

by kennethk (Abbot)
on Feb 27, 2014 at 16:58 UTC ( #1076420=note: print w/replies, xml ) Need Help??

in reply to A maybe rather silly question...

There are 3 general approaches to parsing out strings:
  1. Regular expressions; obviously, this is out based on the spec. It's possible however that the intent is to use split, which might not be considered a regular expression for the purposes of your assignment. Split on \s+, and the second term is your target.

  2. unpack works for fixed-width formats, which this appears to be. Your template would consist of a series of A#, where each # would be the appropriate field width. The results will truncate trailing whitespace automatically. Again, grab the second term.

  3. substr and index. This could work for either fixed-width fields or variable width fields. The most obvious choice would be to grab from the 6th character on, use index on the result to find the first space, and then truncate in a second step.

Good luck on your assignment, and good luck in your class.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1076420]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2018-03-17 20:37 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (226 votes). Check out past polls.