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

Hi, This is working for me but what if i change no of bits to (13 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0). i removed two bits ,then <my $template1 = 'A2' x 18; my $template10 = 'A3' . 'A2' x 17; my $it = natatime 18, unpack( $template1 x 9 . "($template10)".'*' , $ > ,then its no working for me . i need generlised code which work for every input given whatever it is 18 bits or 19 bits or 20 bits .it will produce Table in aligned format from 1 to 13 iteration.

Replies are listed 'Best First'.
Re^3: Count and print in perl
by BillKSmith (Monsignor) on Apr 21, 2017 at 17:20 UTC
    Given only what you have told us so far, that task is impossible! We need a specification (not just an example) of your input 'file' format. Your original post implied that your file is an ASCII (not 'binary') file of fixed length records without separators. The only way to tell the end of a line was by its length. That is definitely a job for unpack. Note: I intentionally wrote the input in my example in a way that made every character (especially whitespace) explicit. If your lines are separated by an INPUT_RECORD_SEPARATOR (e.g. newline) unpack is probably overkill. Without a specification, we have to guess how to parse your file. That has not been going well for you.
    Bill