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

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1076420]
help
Chatterbox?
[Discipulus]: italian doc says to modify somehow the initial SVG before using it with D3.js
[Discipulus]: LanX the fact is that my js ability is even poorer than my Perl one..
[LanX]: oh its negative? ;P
[Discipulus]: my warmest comprehension karlgoethebier ;=(
[Discipulus]: yes LanX.. is so good to be appreciated (I fortunately have a big self estimation that compensate)
[LanX]: you can manipulate a html tree by addressing and replacing so called document objects (DOM) and from my experience the same methods can be used with any XML, though I didn't test all browsers yet
LanX just joking, playing "ego judo"
[marto]: good morning all

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2017-03-23 09:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (285 votes). Check out past polls.