T
Tony
Hi
This is a small version that shows the problem.
If it stays in the while loop it only prints
the top format the first time around then dosen't
print the top format for the next sixty odd iterations
which seems normal but not quite what I need.
If the program exits and is re-started it does the same
top only first time around.
Each iteration it creates a new tempfile.
Tried setting $- = 0; had no effect.
Seems I need to se-set the top format after
each iteration through the while loop.
Is this possible?
In the past I just used print instead of write
for the headings or exited and re-started the
program but would like to stay in it this time.
This is perl, v5.6.1 built for i386-linux
#!/usr/bin/perl
use warnings;
use strict;
use Fcntl; # for temp file
use POSIX qw(tmpnam); # for temp file
while (1) {
print "Enter Name: ";
chomp( my $name = <STDIN> );
# -------------------------------------------------------------
my $tempfile;
do { $tempfile = tmpnam() }
until sysopen( FH, $tempfile, O_RDWR | O_CREAT | O_EXCL );
END { unlink($tempfile) or die "Couldn't unlink $tempfile : $!" }
# -------------------------------------------------------------
format FH_TOP =
Page @<<<
$%
Name
-----------+
..
format FH =
@<<<<<<<<<<
$name
..
write FH;
print FH "\n q to continue\n";
close FH;
# -------------------------------------------------------------
system("less $tempfile") && warn "Can't page tempfile";
print "\nquit (y|N): ";
chomp( my $quit = <STDIN> );
if ( $quit eq 'y' ) { exit; }
} # end while
exit;
This is a small version that shows the problem.
If it stays in the while loop it only prints
the top format the first time around then dosen't
print the top format for the next sixty odd iterations
which seems normal but not quite what I need.
If the program exits and is re-started it does the same
top only first time around.
Each iteration it creates a new tempfile.
Tried setting $- = 0; had no effect.
Seems I need to se-set the top format after
each iteration through the while loop.
Is this possible?
In the past I just used print instead of write
for the headings or exited and re-started the
program but would like to stay in it this time.
This is perl, v5.6.1 built for i386-linux
#!/usr/bin/perl
use warnings;
use strict;
use Fcntl; # for temp file
use POSIX qw(tmpnam); # for temp file
while (1) {
print "Enter Name: ";
chomp( my $name = <STDIN> );
# -------------------------------------------------------------
my $tempfile;
do { $tempfile = tmpnam() }
until sysopen( FH, $tempfile, O_RDWR | O_CREAT | O_EXCL );
END { unlink($tempfile) or die "Couldn't unlink $tempfile : $!" }
# -------------------------------------------------------------
format FH_TOP =
Page @<<<
$%
Name
-----------+
..
format FH =
@<<<<<<<<<<
$name
..
write FH;
print FH "\n q to continue\n";
close FH;
# -------------------------------------------------------------
system("less $tempfile") && warn "Can't page tempfile";
print "\nquit (y|N): ";
chomp( my $quit = <STDIN> );
if ( $quit eq 'y' ) { exit; }
} # end while
exit;