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

Re: Problems with formatting the results of my regex

by monsoon (Pilgrim)
on Jul 07, 2012 at 06:18 UTC ( #980446=note: print w/ replies, xml ) Need Help??


in reply to Problems with formatting the results of my regex

I think you may have a carriage return character \r at the end of the lines in your input file. chomp doesn't remove it. So after $data with a \r gets printed the caret is at the beginning of the line and the beginning of the line is overwritten with whatever follows $data in the print statement. You can remove \r with this for example tr/\015//d;.


Comment on Re: Problems with formatting the results of my regex
Select or Download Code
Re^2: Problems with formatting the results of my regex
by superwombat (Initiate) on Jul 07, 2012 at 06:38 UTC

    Fantastic! Thanks for the quick response. I tested the new code and it's working perfectly now. I still can't understand why the \r was getting captured in $2, since that portion supposedly should end with \d* zero or more digits. In any case, I'm glad it's fixed now.

      .? in (\-?\d+.?\d*) matched \r

        Yes, most (all?) of those . characters in the regex should be changed to \. so that they match just "." not /[^\n]/. You can also use [.]

        - tye        

        Ah.... That's part of my problem then. I intended .? to mean literally "zero or one decimal points" That was a rookie mistake.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-08-23 18:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls