Home > Archive > PERL CGI Beginners > September 2005 > STDIN and $ENV{'CONTENT_LENGTH'}
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
STDIN and $ENV{'CONTENT_LENGTH'}
|
|
| Bart Van der Donck 2005-09-21, 6:55 pm |
| Hello,
This is an HTML file:
<html>
<body>
<form method=post action=script.pl>
<input type=checkbox value=yes name=1><br>
<input type=radio value=yes name=2><br>
<input type=text value=myvalue name=3><br>
<select size=1 name=4>
<option></option>
<option value=x>x</option>
</select><br>
<textarea name=5>mytextarea</textarea><br>
<input type=submit>
</form>
</body>
</html>
This is a Perl file:
#!/usr/bin/perl
print "Content-Type: text/html;\n\n";
print "<html><body>\npassed names:<br>";
read(STDIN,$s,$ENV{'CONTENT_LENGTH'});
@p=split(/&/,$s);
for (@p) {
my @r=split/=/,$_; print $r[0]."<br>"; }
print "\n</body></html>";
When checkbox and radio are both checked, script.pl says:
passed names:
1
2
3
4
5
When checkbox and radio are not checked, script.pl says:
passed names:
3
4
5
I'm looking for a way to read out all passed names in Perl, regardless
of their values or whether or not they were checked. Is this possible ?
Thanks,
--
Bart
| |
| Bart Van der Donck 2005-09-23, 3:56 am |
| Bart Van der Donck wrote:
> Hello,
>
> This is an HTML file:
>
> <html>
> <body>
> <form method=post action=script.pl>
> <input type=checkbox value=yes name=1><br>
> <input type=radio value=yes name=2><br>
> <input type=text value=myvalue name=3><br>
> <select size=1 name=4>
> <option></option>
> <option value=x>x</option>
> </select><br>
> <textarea name=5>mytextarea</textarea><br>
> <input type=submit>
> </form>
> </body>
> </html>
>
> This is a Perl file:
>
> #!/usr/bin/perl
> print "Content-Type: text/html;\n\n";
> print "<html><body>\npassed names:<br>";
> read(STDIN,$s,$ENV{'CONTENT_LENGTH'});
> @p=split(/&/,$s);
> for (@p) {
> my @r=split/=/,$_; print $r[0]."<br>"; }
> print "\n</body></html>";
>
> When checkbox and radio are both checked, script.pl says:
>
> passed names:
> 1
> 2
> 3
> 4
> 5
>
> When checkbox and radio are not checked, script.pl says:
>
> passed names:
> 3
> 4
> 5
>
> I'm looking for a way to read out all passed names in Perl, regardless
> of their values or whether or not they were checked. Is this possible ?
>
> Thanks,
>
> --
> Bart
In follow-up to my own post:
The question was solved in comp.lang.perl.misc.
--
Bart
|
|
|
|
|