jpavus has asked for the wisdom of the Perl Monks concerning the following question:
I tried the local and have sub to restore a static values but it never worked. Maybe there's simpler way to do it. ALSO: Do I just need to insert a SPECIAL CHAR in order to have PAGE breaks? Here's the code below:***** FILE 1 Orlando ***** FLORIDA Inventory Report CITY: Orlando Page1 111 Item1 $1000 222 Item2 $2000 449 Item3 $9999 ***** FILE 2 Miami ******** Should RESET the Page # to 1 ***** FLORIDA Inventory Report CITY: Miami Page2 349 Item1 $3050 FLORIDA Inventory Report CITY: Miami Page3 349 Item1 $3050 224 Item2 $2340 982 Item3 $9029
Thanks in Advance..my ($file); my $time = time; use POSIX 'strftime'; my $runtime = strftime '%Y/%m/%d %H:%M:%S', localtime; print $runtime; my $page_count = 0; while (<FILE>){ chomp($_); if ( /CITY/ ... /FLORIDA/ ) { my $county=0; if ( ($file) = $_ =~ m/CITY:\s+(\w+)/ ) { close(FH); dynamic(); if ($file != $var) { $page_count = 0; } $file .= '.txt'; open(FH, ">> CORAGN$file"); ++$page_count; print FH "RUN DATE/TIME: $runtime DE +PT OF INFO SYSTEM REPORT: COSRAGIN\ +n"; print " STATEWIDE D +AILY REPORT PAGE: $page_count\n"; } print FH "$_\n" unless $_ =~ m/FLORIDA/; } } close FILE; closedir DIR; sub visible { print "\nvar has value $var"; print "\nfile has value $file"; } sub dynamic { local $var = $file; visible(); }
Edit by castaway - linkified
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Issues on PAGE count and PageBreaks
by sh1tn (Priest) on Mar 14, 2005 at 23:42 UTC | |
by jpavus (Novice) on Mar 15, 2005 at 03:49 UTC | |
by jpavus (Novice) on Mar 15, 2005 at 20:36 UTC |