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

Re^3: One-liner only checking the first line of the input file

by stevieb (Canon)
on Nov 11, 2015 at 14:41 UTC ( #1147457=note: print w/replies, xml ) Need Help??


in reply to Re^2: One-liner only checking the first line of the input file
in thread One-liner only checking the first line of the input file

Do this:

perl -anE '/(\R)/; say unpack("H*", $1);' input.txt

It appears as your file is being read as one long string. If you're on *nix, your output should be 0a per line for as many lines you have in the file. Post what the output shows.

Replies are listed 'Best First'.
Re^4: One-liner only checking the first line of the input file
by TJCooper (Beadle) on Nov 11, 2015 at 14:51 UTC
    Outputs 0d only once.

      That's a MacOS line ending \r, aka a carriage return. See if this works:

      perl -012 -lane 'print "$F[2]\t$F[7]" if $F[7] > 0' < input.txt

      The -0 flag sets the input record separator (line ending) to \r in octal form.

        Same output as before unfortunately.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2021-10-23 15:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (88 votes). Check out past polls.

    Notices?