Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing whitespace question

Status
Not open for further replies.

Xenocon

Programmer
Dec 27, 2004
4
CA
I have a website that lists files in a <select> list. My problem is that when it is passed to my perl CGI program, if a file is more than one work [/home/user/hello goodbye.txt] only the first part of the name is passed [/home/user/hello]. I am fairy new to perl and CGI. Help would be appreciated.
My code is fairly simple, I have tried $query->param, and read(STDIN...)


--Xenocon
=|
 
I should add that this works fine when I have a pre generated html file, but the page with the form is generated from another Perl script, might that be the problem?

Sorry for replying to my own post
 
the page with the form is generated from another Perl script, might that be the problem?"

Possibly.. make sure that the html syntax used in the <select> matches the <select> syntax used in the pre generated html file.

 
what syntax? all i have in the perl generated form is
--------
print "<form method=post action=\"/cgi-bin/view.pl\">";
print "<select name=\"loc\">;
for(@dirlist)
{
print "<option value=$_>$_";
}


the original static form just is a text box that is used to determine the directory.
 
thanks for your help, once i removed value=$_ from <option... it worked
 
Hmm.. not sure what the problem is.. use this function to parse incoming data.
Code:
use CGI;
my $q = new CGI;

sub param_all {
        my $input = {};
        foreach my $key ($q->param) {
                my @values = $q->param($key);
                my $value = join (", ", @values);
                $input->{$key} = "$value";
        }
        return $input; # Returns a hashref of params
}

 
Code:
print "<option value=\"$_\">$_</option>\n";
When the select is passed if there's spaces you'll only get the first atom, unless it's enclosed in quotes

HTH
--Paul


cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top