Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Attempt to parse a line with odd characters is unsuccessful.

by derby (Abbot)
on Jul 21, 2011 at 21:57 UTC ( #916006=note: print w/ replies, xml ) Need Help??


in reply to Attempt to parse a line with odd characters is unsuccessful.

\cI is the tab character and \cM\cJ is the dos newline. So ... splitting on whitespace and taking the third value should work.

my $value = (split( /\s+/, $a1[0] ))[2]
-derby


Comment on Re: Attempt to parse a line with odd characters is unsuccessful.
Download Code
Re^2: Attempt to parse a line with odd characters is unsuccessful.
by trailhounds (Initiate) on Jul 21, 2011 at 22:27 UTC
    Derby,
    Thanks for your answer.
    Will the linux perl interpret the whitespace from Windows correctly?
    My test did not work.
    It keeps coming back when I show the value in the interpreter as "undef".
      Whitespace is whitespace. Windows nor linux should matter (granted the eol delimiter is different but they're both whitespace). I'm guessing there's more to the code and/or data than the snippet you've shown. If you could give more details for 'It keeps coming back when I show the value in the interpreter as "undef"', we could track down the issue.
      -derby
      Check the input file really is what you expect with something like od -xc file.txt
Re^2: Attempt to parse a line with odd characters is unsuccessful.
by jwkrahn (Monsignor) on Jul 22, 2011 at 01:41 UTC
    splitting on whitespace and taking the third value should work.

      my $value = (split( /\s+/, $a1[0] ))[2]

    Unless there is leading whitespce.    This will work in either case:

    my $value = ( split ' ', $a1[ 0 ] )[ 2 ];
      true ... true .. but there's no leading whitespace in the OP.
      -derby

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2014-09-02 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (19 votes), past polls