http://www.perlmonks.org?node_id=916006


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