B
Brad Walton
I would like the output of data to stop at a certain page number. This is
the test script I have been working on:
----
#!/usr/bin/perl
use strict;
use warnings;
my ($key, $value);
$= = 10; # Number of lines before new page
open (FILE, 'greatergreen.plr') or die "Cannot open: $!";
while (<FILE>) {
chomp;
if ($_ =~ /(.*)\=\"(.*)\".*/) {
$key = $1;
$value = $2;
write if $% < 2;
}
}
close (FILE);
format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
$key, $value
..
format STDOUT_TOP =
Page @<<
$%
Variable Setting
========================= =================
..
----
And this is the output:
----
Page 1
Variable Setting
========================= =================
Track File LOCATION
Track Description LongBeach
AI Database File LOCATION
Profile Vehicle File TEAMS\GT
Vehicle File TEAMS\GT
?
Page 2
Variable Setting
========================= =================
Sim Vehicle File TEAMS\GT
----
I would like it to stop at the end of Page 1, but it's leaking on to page 2.
I assume this is happening because the page counter isn't updated until
after it's called for write.
Thanks for any help,
Brad
the test script I have been working on:
----
#!/usr/bin/perl
use strict;
use warnings;
my ($key, $value);
$= = 10; # Number of lines before new page
open (FILE, 'greatergreen.plr') or die "Cannot open: $!";
while (<FILE>) {
chomp;
if ($_ =~ /(.*)\=\"(.*)\".*/) {
$key = $1;
$value = $2;
write if $% < 2;
}
}
close (FILE);
format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
$key, $value
..
format STDOUT_TOP =
Page @<<
$%
Variable Setting
========================= =================
..
----
And this is the output:
----
Page 1
Variable Setting
========================= =================
Track File LOCATION
Track Description LongBeach
AI Database File LOCATION
Profile Vehicle File TEAMS\GT
Vehicle File TEAMS\GT
?
Page 2
Variable Setting
========================= =================
Sim Vehicle File TEAMS\GT
----
I would like it to stop at the end of Page 1, but it's leaking on to page 2.
I assume this is happening because the page counter isn't updated until
after it's called for write.
Thanks for any help,
Brad