Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: A maybe rather silly question...

by kennethk (Monsignor)
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.


Comment on Re: A maybe rather silly question...
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2014-12-27 16:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls