I have written the following program to create a file, and them pass the values to another program. However, the second program does not recognize the values and gives errors. Is it possible to pass values between program without query and files?
Program I with values:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<HTML><TITLE>LocalTime</TITLE>\n";
print "<BODY BGCOLOR=\"white\"><center>";
print "</center></BODY></HTML>";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
%FORM = ();
foreach $pair (@pairs) {
$pair =~ s/\+/ /g;
($name, $value) = split(/=/, $pair);
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/eg;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/eg;
$value =~ s/\n/ /g; # replace newlines with spaces
$value =~ s/\r//g; # remove hard returns
$value =~ s/\cM//g; # delete ^M's
$FORM{$name} = $value;
}
foreach $key ("amount","phone"
{
print "$key = $FORM{$key}<br>\n";
}
open(OUTF,">>test1.out" or dienice("Couldn't open survey.out for writing: $!"
flock(OUTF,2);
seek(OUTF,0,2);
print OUTF "$FORM{'amount'}|";
print OUTF "$FORM{'phone'}|";
close(OUTF);
print " <br><a href=\" Please click this </h3> </a>\n";
print <<EndHTML;
EndHTML
sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}
Program II to receive these values and assign them to another variable and ask for more:
#!/usr/bin/perl
print"<html><head><title>testc1</title></head>\n";
print"<body>\n";
print "<form method=\"post\" action=\"
$phone2=$phone;
$v =$amount;
print"<input type=\"hidden\" name=\"AMOUNT\" value=\"$v\">\n";
print"<input type=\"hidden\" name=\"TYPE\" value=\"A\">\n";
print"<table>\n";
print" <tr><td align=\"right\">Telephone Number:<input type=\"text\" name=\"phone\" value=\"$phone2\" size =\"30\"><br></td></tr>\n";
print" <tr><td align=\"right\"><input type=\"submit\" value=\"click here to submit\"></td></tr>\n";
print"</table></form></body></html>\n";
Program I with values:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<HTML><TITLE>LocalTime</TITLE>\n";
print "<BODY BGCOLOR=\"white\"><center>";
print "</center></BODY></HTML>";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
%FORM = ();
foreach $pair (@pairs) {
$pair =~ s/\+/ /g;
($name, $value) = split(/=/, $pair);
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/eg;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/eg;
$value =~ s/\n/ /g; # replace newlines with spaces
$value =~ s/\r//g; # remove hard returns
$value =~ s/\cM//g; # delete ^M's
$FORM{$name} = $value;
}
foreach $key ("amount","phone"
{
print "$key = $FORM{$key}<br>\n";
}
open(OUTF,">>test1.out" or dienice("Couldn't open survey.out for writing: $!"
flock(OUTF,2);
seek(OUTF,0,2);
print OUTF "$FORM{'amount'}|";
print OUTF "$FORM{'phone'}|";
close(OUTF);
print " <br><a href=\" Please click this </h3> </a>\n";
print <<EndHTML;
EndHTML
sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}
Program II to receive these values and assign them to another variable and ask for more:
#!/usr/bin/perl
print"<html><head><title>testc1</title></head>\n";
print"<body>\n";
print "<form method=\"post\" action=\"
$phone2=$phone;
$v =$amount;
print"<input type=\"hidden\" name=\"AMOUNT\" value=\"$v\">\n";
print"<input type=\"hidden\" name=\"TYPE\" value=\"A\">\n";
print"<table>\n";
print" <tr><td align=\"right\">Telephone Number:<input type=\"text\" name=\"phone\" value=\"$phone2\" size =\"30\"><br></td></tr>\n";
print" <tr><td align=\"right\"><input type=\"submit\" value=\"click here to submit\"></td></tr>\n";
print"</table></form></body></html>\n";