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0,0,1, +1,1,0,1,1,1,0,0,0,1,0,0,1,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1 +,1,0,1,0,1,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,0,0,0,1,1,1,0,0,0,0,1,0,0,0, +0,0,1,0,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,0,1,0,1,1,1,0,1,1,1,0,1 +,0,1,0,0,1,0,1,0,0,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,0,1,1,0, +0,1,0,0,0,1,1,0,1,1,0,0,1,0,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,0,1,1,1,0 +,0,1,0,1,1,0,0,1,1,0,1,1,0,1,0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1, +0,0,1,0,0,0,1,1,1,0,1,0,0,1,1,0,0,0,1,0,1,1,1,0,1,0,1,1,1,0,1,0,0,0,0 +,1,0,0,0,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1,0,1,1,1,1,1,1,1,1, +1,1,0,1,1,0,0,0,1,1,1,0,1,0,1,0,1
That assumes you want each binary record terminated with a newline. (Remove the 'l' from the shebang line if not.)
For the second part you'll have to describe the format of the second file in more detail?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Bit handling in Perl
by vaidhy_m (Novice) on Oct 11, 2014 at 05:30 UTC | |
by BrowserUk (Patriarch) on Oct 11, 2014 at 07:00 UTC | |
by vaidhy_m (Novice) on Oct 11, 2014 at 08:25 UTC | |
by BrowserUk (Patriarch) on Oct 11, 2014 at 09:43 UTC | |
by Anonymous Monk on Oct 11, 2014 at 09:53 UTC | |
by vaidhy_m (Novice) on Oct 11, 2014 at 10:30 UTC | |
by vaidhy_m (Novice) on Oct 25, 2014 at 11:37 UTC | |
|