Hi all.
Here is my code:
#!/usr/local/bin/perl
$var1 = "http://$ENV{'SERVER_NAME'}$ENV{'DOCUMENT_URI'}";
if ($ENV{'QUERY_STRING'} =~ /jump/) { &jump; }
else { &menu; }
###############################################################
# This is the section that reads the text file and puts #
# it in the option of pull down menu #
###############################################################
sub menu {
unless (open(MYFILE, "menu2.txt")) {
die ("cannot open input file file1\n");
}
# if the program gets this far, the file was
# opened successfully
print "Content-type: text/html", "\n\n";
$line = <MYFILE>;
($link_dest, $link_name) = split ("\@", $line);
print "<FORM METHOD=POST ACTION=\"http://www.test.ca/\~me/cgi-bin/menujump.cgi?jump\">";
print "<select name=\"url\" size=\"1\">";
while ($line ne ""){
print "<option value=\"$link_dest\"\> $link_name";
$line = <MYFILE>;
($link_dest, $link_name) = split ("\@", $line);
}
print "</select><input type=\"image\" src=\"../images/submit.gif\" border=\"0\"></form>";
}
sub jump {
# Read in all the variables set by the form
&parse_form;
$gotourl = $FORM{'url'};
print "Location: $gotourl\n\n";
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
}
}
...and here it is what i like to know:
how do i tell the program NOT to display $var1 in the pull down menu???
What i like to do is if line in text:
##########TEXT FILE LOOKS LIKE THIS#####
http://www.test.com@Test Page
http:///www.thispage.com@This Page
#########END OF TEXT FILE###############
is equal to $var1 i like the program to skip it and not put in pull down menu....any sugestions....
I try using seek function and chomp...but i think i didn't get it right..
P.S.
I'm just starting with PERL, so please go easy on me....
Thank you
Jarek
[This message has been edited by jarekg28 (edited February 16, 1999).]
Here is my code:
#!/usr/local/bin/perl
$var1 = "http://$ENV{'SERVER_NAME'}$ENV{'DOCUMENT_URI'}";
if ($ENV{'QUERY_STRING'} =~ /jump/) { &jump; }
else { &menu; }
###############################################################
# This is the section that reads the text file and puts #
# it in the option of pull down menu #
###############################################################
sub menu {
unless (open(MYFILE, "menu2.txt")) {
die ("cannot open input file file1\n");
}
# if the program gets this far, the file was
# opened successfully
print "Content-type: text/html", "\n\n";
$line = <MYFILE>;
($link_dest, $link_name) = split ("\@", $line);
print "<FORM METHOD=POST ACTION=\"http://www.test.ca/\~me/cgi-bin/menujump.cgi?jump\">";
print "<select name=\"url\" size=\"1\">";
while ($line ne ""){
print "<option value=\"$link_dest\"\> $link_name";
$line = <MYFILE>;
($link_dest, $link_name) = split ("\@", $line);
}
print "</select><input type=\"image\" src=\"../images/submit.gif\" border=\"0\"></form>";
}
sub jump {
# Read in all the variables set by the form
&parse_form;
$gotourl = $FORM{'url'};
print "Location: $gotourl\n\n";
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
}
}
...and here it is what i like to know:
how do i tell the program NOT to display $var1 in the pull down menu???
What i like to do is if line in text:
##########TEXT FILE LOOKS LIKE THIS#####
http://www.test.com@Test Page
http:///www.thispage.com@This Page
#########END OF TEXT FILE###############
is equal to $var1 i like the program to skip it and not put in pull down menu....any sugestions....
I try using seek function and chomp...but i think i didn't get it right..
P.S.
I'm just starting with PERL, so please go easy on me....
Thank you
Jarek
[This message has been edited by jarekg28 (edited February 16, 1999).]

