Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Count and print in perl

by johngg (Canon)
on Apr 17, 2017 at 21:51 UTC ( [id://1188178]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Count and print in perl
in thread Count and print in perl

Assuming Anonymonk is actually kanikas16 who forgot to log in I'll take that as a yes, in which case something along these lines:-

johngg@shiraz:~/perl/Monks > perl -Mstrict -Mwarnings -E ' my $inFile = q{spw1188105.dat}; open my $inFH, q{<}, $inFile or die qq{open: < $inFile: $!\n}; while ( my $bytesRead = read $inFH, my $record, 18 ) { printf q{%-3d} x 18 . qq{%s\n}, map( ord, split m{}, $record ), q{x} x 35; } close $inFH or die qq{close: < $inFile: $!\n};' 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx 2 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx 3 1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx 4 1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx 5 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx 6 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx 7 1 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx 8 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx 9 1 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx 10 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx 11 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx 12 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx 13 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxx

I hope this is heading in the right direction.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^4: Count and print in perl
by kanikas16 (Initiate) on Apr 18, 2017 at 10:36 UTC
    hi, but this is not printing into binary format
    49 32 49 32 48 32 48 32 48 32 48 32 48 32 48 32 48 32+ +48 32 49 32 48 32 48 32 48 32 48 32 48 32 48 32 48 32+ +50 32 49 32 49 32 48 32 48 32 48 32 48 32 48 32 49 32+ +49 32 48 32 48 32 48 32 49 32 48 32 48 32 48 32 49 32+ +51 32 49 32 49 32 49 32 48 32 48 32 48 32 48 32 48 32+ +48 32 49 32 48 32 48 32 48 32 48 32 48 32 48 32 48 32+ +52 32 49 32 49 32 49 32 48 32 48 32 48 32 48 32 48 32+ +48 32 49 32 48 32 48 32 48 32 48 32 48 32 49 32 48 32+ +53 32 49 32 49 32 48 32 48 32 48 32 48 32 48 32 49 32 +49 32 48 32 48 32 48 32 49 32 48 32 48 32 48 32 49 32 +54 32 49 32 49 32 48 32 48 32 48 32 48 32 48 32 49 32 +49 32 48 32 48 32 48 32 49 32 48 32 48 32 48 32 49 32 +55 32 49 32 49 32 48 32 49 32 48 32 48 32 48 32 48 32 +48 32 49 32 48 32 48 32 48 32 48 32 48 32 48 32 48 32 +56 32 49 32 49 32 48 32 48 32 48 32 48 32 48 32 49 32 +49 32 48 32 48 32 48 32 49 32 48 32 48 32 48 32 49 32 +57 32 49 32 49 32 48 32 48 32 49 32 48 32 48 32 48 32 +48 32 49 32 48 32 48 32 48 32 48 32 48 32 48 32 48 32 +49 48 32 49 32 49 32 48 32 48 32 48 32 48 32 48 32 49 +32 49 32 48 32 48 32 48 32 49 32 48 32 48 32 48 32 49 +32 49 49 32 49 32 49 32 48 32 48 32 48 32 49 32 48 32 +48 32 48 32 49 32 48 32 48 32 48 32 48 32 48 32 48 32 +48 32 49 50 32 49 32 49 32 48 32 48 32 48 32 48 32 48 +32 49 32 49 32 48 32 48 32 48 32 49 32 48 32 48 32 48 +32 49 32 49 51 32 49 32 49 32 48 32 48 32 48 32 48 32 +49 32 49 32 49 32 49 32 48 32 48 32 48 32 48 32 48 32 +48 32 48 32 49 52 32 49 32 49 32 48 32 48 32 48 32 48 +32 48 32 49 32 49 32 48 32 48 32 48 32 49 32 48 32 48 +32 48 32 49 32 49 53 32 49 32 49 32 48 32 48 32 48 32 +48 32 48 32 48 32 48 32 49 32 49 32 48 32 48 32 48 32 +48 32 49 32 48 32 48 32 48 32 48 32 48 32 49 32 49 32 Argument "" isn't numeric in printf at counter.pl line 3 Missing argument in printf at counter.pl line 36.

      What do you mean by binary format? Please show us a hexdump -C of your input file inside <code> ... </code> tags, the code you used to produce this output inside <code> ... </code> tags and the output you are expecting, also inside <code> ... </code> tags. Your narrative should be inside <p> ... </p> tags.

      As things stand it is not clear what you are trying to achieve.

      Cheers,

      JohnGG

Re^4: Count and print in perl
by Anonymous Monk on Apr 18, 2017 at 17:07 UTC
    Did you run "Anonymonk's" code and compare to your own?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-20 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found