Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: How to parse this file

by Sewi (Friar)
on Oct 19, 2011 at 15:02 UTC ( #932430=note: print w/replies, xml ) Need Help??

in reply to How to parse this file

Pointing someone into the right direction is better than providing the solution without explanation.

seek and tell are working on the filehandle, you could easily work on a variable after reading the line by using "substr" and maybe "length".

But most of the string manipulation in Perl is done using Perl regular expressions. Don't compare them to POSIX, Javascript or other regular expressions, all of them only have a small subset of the Perl RE's power.

\d is a char class for the numbers from 0 to 9, a basic regex for converting your line might be$line =~ s/[^\d]//g;It won't exactly do what you want (cut out too much), but it should be a good start for you. Try to use the Perl regex documentation to understand the expression shown above. Changing them to something really fitting your needs should be easy once you understood the regex.

For gurus: Yes, there is \D, but ^\d is a better learning start for this problem.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932430]
[Eily]: French sneeze "Atchoum", because we close our mouth when we're done :P
[erix]: Hatshepsut (no sneezing audio there)
choroba wipes the saliva from the cookies
[LanX]: scary Le Pen + Melonchon had over 40% ...
[vrk]: One good word for it in Finnish is pärskäys. A very wet connotation.
[Eily]: somehow when googling pärskäys I got a pageful of Finnish :P
[robby_dobby]: Can I go participate in an YAPC?
[Eily]: (I was trying to find a translation but google translate didn't help)
robby_dobby is not entirely serious
[LanX]: ... thank God France doesn't have an electoral college...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2017-04-24 15:50 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (442 votes). Check out past polls.