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

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

by derby (Abbot)
on Jul 21, 2011 at 21:57 UTC ( [id://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

Replies are listed 'Best First'.
Re^2: Attempt to parse a line with odd characters is unsuccessful.
by jwkrahn (Abbot) 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
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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-24 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found