I need to split the .bin file based on the combination of Unique Number, description and Page number (Page 1 of X) using Perl. As provided in the sample data for Unique number 111-111111 there are two pages of statement which starts from Page 1 of 1 and ends at Page 1 of 1 itself and the second Unique number is 222-222222 which starts from Page 1 of 3 and ends at Page 3 of 3. The sample input needs to be split up in two files. File 1 and File 2. Below is the code which I wrote,I am unable to understand how do I put the page validation in place with a combination of a unique account number My perl version v5.10.1. Appreciate any help and thanks in advance.
#!/usr/bin/perl
use strict;
use warnings;
my $input = do { local $/; <DATA> };
my @input = split /(?=\d+ Page)/, $input;
foreach (0 .. $#input) {
say "Record $_ is: $input[$_]";
}
Here is the sample Data
Page 1 of 1
Account Unique_Number Description
GENERAL 111-111111
This is the first line
I am learning perl
Page 1 of 3
Account Unique_Number Description
PERSONAL 222-222222
This is the first line
I am learning perl
Page 2 of 3
Account Unique_Number Description
Educational 222-222222
This is the second line
I am learning perl
Page 3 of 3
Account Unique Number Description
Educational 222-222222
This is the third line
I am learning perl
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.