Situation1:
when I tried to associate with the write function another filehandle than STDOUT to make it write the report to a file it tells me the filehandle isn't defined, uncomment the lines 32 and 33 to see that.
####
Situation2:
for every run of the report I wanted to make the program start a new episode on another page (i.e it starts a new episode at page 3 if it stopped at page 2)
####
#!/usr/local/bin/perl
use strict;
use warnings;
my($title,$num1, $num2, $result);
format report_TOP=
@||||||||||||||@>>>>>>>>
$title , "Page $%"
---------------------------------
NUMBER1 || NUMBER2 || ADDITION
---------------------------------
.
format report=
@###@#########@############
$num1, $num2, $result
.
$~="report";
$^="report_TOP";
$title = "Some Report";
START:
print "Please Enter a text containing pairs of numbers\n";
while(<>){
if(/^(exit|quit)$/){exit;}
($num1, $num2) = (/(\d+)/g) for ($_);
add($num1, $num2);
}
sub add{
# open FILE,'>REPORT.txt' or die "could not open it $!\n";
# select FILE;
for(my $index=0;$index<100;$index++){
$result = $num1 + $num2;
write;
$num1++;
$num2++;
}
print "another Pair of numbers? Y N\n";
if(<> =~ /^N$/i){
exit;
}else{
print "Please Enter a text containing pairs of numbers\n";
"START";
}
}