in reply to Re^2: Segregate data based on Page number and account combination
in thread Segregation with Perl
Open a new file at each Page 1 line.
poj#!/usr/bin/perl use strict; my $fileno = 0; my $fh; while (<DATA>){ if (/^ *Page 1/){ close $fh if $fileno; ++$fileno; print "Opening file $fileno\n"; open $fh,'>',"$fileno.txt" or die "Could not open $fileno.txt"; } print $fh $_; } close $fh; __DATA__ Page 1 of 1 Account Account_Number Beginning_Value GENERAL 111-111111 $88,0853.95 Page 1 of 3 Account Account_Number Beginning Value PERSONAL 222-222222 $88,0853.95 Page 2 of 3 Account Account_Number Beginning Value Educational 222-222222 Page 3 of 3 Account Account Number Beginning Value Educational 222-222222
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Segregate data based on Page number and account combination
by Johndow (Novice) on Nov 17, 2018 at 01:29 UTC | |
by hippo (Archbishop) on Nov 17, 2018 at 09:44 UTC | |
by AnomalousMonk (Archbishop) on Nov 17, 2018 at 21:51 UTC |