Hi All, This is part of my question previously, when I have a pl that separates the files into each CITY based (separating every set of textline). The problem now is, I cannot reset the PAGE NUMBERS on each filenames. It just continues e.g.: file 1: has pages 1,2,3,4 file 2: has pages 5,6,7,8,9 (this should reset to 1)
***** 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
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:
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(); }
Thanks in Advance..

Edit by castaway - linkified


In reply to Issues on PAGE count and PageBreaks by jpavus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.