[31225] in Perl-Users-Digest
Perl-Users Digest, Issue: 2470 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 10 14:14:25 2009
Date: Wed, 10 Jun 2009 11:14:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 10 Jun 2009 Volume: 11 Number: 2470
Today's topics:
reading a select form from perl <FiNaR76@gmail.com>
Re: reading a select form from perl <nn@nn.com>
Re: reading a select form from perl <tadmc@seesig.invalid>
Re: reading a select form from perl <tadmc@seesig.invalid>
Re: reading a select form from perl <FiNaR76@gmail.com>
Re: reading a select form from perl <tadmc@seesig.invalid>
Re: reading a select form from perl <glennj@ncf.ca>
Re: sendmail doesn't work, but no error on the screen.. <tadmc@seesig.invalid>
Re: Strawberry and Vanilla Perl <ben@morrow.me.uk>
Re: understanding \Q \E <ben@morrow.me.uk>
Re: What happened to perl doc <tadmc@seesig.invalid>
Re: What happened to perl doc <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 10 Jun 2009 03:13:22 -0700 (PDT)
From: Vit <FiNaR76@gmail.com>
Subject: reading a select form from perl
Message-Id: <4ba74747-72ec-4289-abd1-1ad54c953ef4@f19g2000yqo.googlegroups.com>
Hi All,
I was just trying to read a webform to send an email.. (using
sendemail)
in the webform I have a selection form like that:
<select name="interest" style="height: 109px; width: 484px"
multiple="multiple">
<option selected="selected"><--- Select One or More ---></
option>
<option>Option 1</option>
<option>Option 2</option>
</select>
I have notice that my perl code it breaks on this select form...
the perl code is the following:
#!/usr/bin/perl
use CGI;
# Create the CGI object
my $query = new CGI;
# Output the HTTP header
print $query->header ( );
# Capture the form results
my $company = $query->param("company");
my $enquiry = $query->param("enquiry");
my $interest = $query->param("interest");
# Filter the form results
$email_address = filter_header_field ( $email_address );
$enquiry = filter_field ( $enquiry );
#$interest = filter_field ( $interest );
# Email the form results
open ( MAIL, "| /usr/sbin/sendmail -t" );
print MAIL "From: $email_address\n";
print MAIL "To: test\@domain.com\n";
print MAIL "Subject: Web Request\n\n";
print MAIL "Comment: $enquiry\n";
#print MAIL "Interest: $interest\n"
print MAIL "\n.\n";
close ( MAIL );
# Thank the user
print <<END_HTML;
<html>
<head></head>
<body>Thanks for filling in our form!</body>
</html>
END_HTML
# Functions for filtering user input
sub filter_field
{
my $field = shift;
$field =~ s/From://gi;
$field =~ s/To://gi;
$field =~ s/BCC://gi;
$field =~ s/CC://gi;
$field =~ s/Subject://gi;
$field =~ s/Content-Type://gi;
return $field;
}
sub filter_header_field
{
my $field = shift;
$field =~ s/From://gi;
$field =~ s/To://gi;
$field =~ s/BCC://gi;
$field =~ s/CC://gi;
$field =~ s/Subject://gi;
$field =~ s/Content-Type://gi;
$field =~ s/[\0\n\r\|\!\/\<\>\^\$\%\*\&]+/ /g;
return $field;
}
how can I "read" the select form value??? how can I read if it is
multivalue???
thanks all
Vit
------------------------------
Date: Wed, 10 Jun 2009 12:46:13 +0200
From: ace <nn@nn.com>
Subject: Re: reading a select form from perl
Message-Id: <h0o2tp$g77$1@ss408.t-com.hr>
Vit wrote:
> how can I "read" the select form value??? how can I read if it is
> multivalue???
use Data::Dumper;
my $multival = $query->param("multival");
print Dumper $multival;
------------------------------
Date: Wed, 10 Jun 2009 06:34:31 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: reading a select form from perl
Message-Id: <slrnh2v6i7.q4r.tadmc@tadmc30.sbcglobal.net>
Vit <FiNaR76@gmail.com> wrote:
> #!/usr/bin/perl
#!/usr/bin/perl
use warnings;
use strict;
> my $query = new CGI;
my $query = CGI->new;
but that is a horrid choice of variable name IMO, so I'd do
my $cgi = CGI->new;
instead.
> # Capture the form results
I usually grab all of them into a hash, and then use them from there:
my %param = $cgi->Vars;
> my $enquiry = $query->param("enquiry");
> $enquiry = filter_field ( $enquiry );
$param{enquiry} = filter_field( $param{enquiry} );
> open ( MAIL, "| /usr/sbin/sendmail -t" );
You should always, yes *always*, check the return value from open().
> print MAIL "From: $email_address\n";
> print MAIL "To: test\@domain.com\n";
> print MAIL "Subject: Web Request\n\n";
> print MAIL "Comment: $enquiry\n";
> #print MAIL "Interest: $interest\n"
> print MAIL "\n.\n";
print MAIL <<ENDMAIL;
From: $email_address
To: test\@domain.com
Subject: Web Request
Comment: $enquiry
.
ENDMAIL
> $field =~ s/From://gi;
> $field =~ s/To://gi;
> $field =~ s/BCC://gi;
> $field =~ s/CC://gi;
> $field =~ s/Subject://gi;
> $field =~ s/Content-Type://gi;
$field =~ s/(From|To|BCC|CC|Subject|Content-Type)://gi;
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Wed, 10 Jun 2009 06:44:58 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: reading a select form from perl
Message-Id: <slrnh2v75q.qng.tadmc@tadmc30.sbcglobal.net>
Vit <FiNaR76@gmail.com> wrote:
> how can I read if it is
> multivalue???
What happened when you searched for "multivalue" in the documentation
for the module that you are using?
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Wed, 10 Jun 2009 06:04:34 -0700 (PDT)
From: Vit <FiNaR76@gmail.com>
Subject: Re: reading a select form from perl
Message-Id: <040bcb03-f17d-4538-9507-cbf499a04239@n8g2000vbb.googlegroups.com>
On 10 Giu, 18:46, ace <n...@nn.com> wrote:
> Vit wrote:
> > how can I "read" the select form value??? how can I read if it is
> > multivalue???
>
> use Data::Dumper;
> my $multival = $query->param("multival");
> print Dumper $multival;
thanks.. it seems to work... but unfortunatelly it's going to give me
just the first selected....
use Data::Dumper;
my $interest = $query->param("interest")
print MAIL Dumper $interest;
I get the following:
$VAR1 = '1';
how can I list all the option and show if they are selected or not...
thanks
Vit
------------------------------
Date: Wed, 10 Jun 2009 08:12:49 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: reading a select form from perl
Message-Id: <slrnh2vcah.rpf.tadmc@tadmc30.sbcglobal.net>
Vit <FiNaR76@gmail.com> wrote:
> On 10 Giu, 18:46, ace <n...@nn.com> wrote:
>> Vit wrote:
>> > how can I "read" the select form value??? how can I read if it is
>> > multivalue???
>>
>> use Data::Dumper;
>> my $multival = $query->param("multival");
>> print Dumper $multival;
>
> thanks.. it seems to work... but unfortunatelly it's going to give me
> just the first selected....
Because that is what it is *supposed* to do.
> my $interest = $query->param("interest")
The docs for the module that you are using has a section with this heading:
FETCHING THE VALUE OR VALUES OF A SINGLE NAMED PARAMETER
wherein it says:
If the parameter is multivalued
...
you can ask to receive an array. Otherwise
the method will return a single value.
You did not ask to receive an array, so you got a single value
just like it said it would do.
> how can I list all the option and show if they are selected or not...
^^^^^^^^^^^^^^
I dunno.
But it is easy enough to get a list of the ones that are selected,
which is what I thing you meant to ask rather than what you actually
asked, just ask to receive an array:
my @selected_options = $query->param("interest");
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: 10 Jun 2009 14:00:46 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: reading a select form from perl
Message-Id: <slrnh2vf4f.bl0.glennj@smeagol.ncf.ca>
At 2009-06-10 09:04AM, "Vit" wrote:
> use Data::Dumper;
> my $interest = $query->param("interest")
> print MAIL Dumper $interest;
>
> I get the following:
> $VAR1 = '1';
Are you actually debugging by sending yourself email? The mind boggles...
use the CGI::Carp module,
--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous
------------------------------
Date: Wed, 10 Jun 2009 05:51:37 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: sendmail doesn't work, but no error on the screen...
Message-Id: <slrnh2v41p.q4r.tadmc@tadmc30.sbcglobal.net>
Andrzej Adam Filip <Andrzej.Filip@gmail.com> wrote:
> Vit <FiNaR76@gmail.com> wrote:
>> open(MAIL, "|/usr/sbin/sendmail");
>
> open(MAIL, '|-', '/usr/sbin/sendmail -t -oi') or die;
>> close (MAIL);
If the filehandle is connected to a pipe, it is a Really Good Idea
to check the return value from close() too:
close(MAIL) or die "sendmail failed";
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Wed, 10 Jun 2009 17:13:09 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Strawberry and Vanilla Perl
Message-Id: <ll25g6-ol1.ln1@osiris.mauzo.dyndns.org>
Quoth sisyphus <sisyphus359@gmail.com>:
> On Jun 10, 6:53 am, Ben Morrow <b...@morrow.me.uk> wrote:
>
> > though AS do include a somewhat half-
> > hearted hack to try and make it work with gcc if you've got that
> > installed.
>
> That "half-hearted hack" means that *any* perl extension that builds
> on Strawberry Perl, can also be built in exactly the same way on
> ActivePerl, using the MinGW port of the gcc compiler. (You could even
> set things up to use Strawberry Perl's MinGW with ActivePerl if you
> wanted.)
Try installing Perl.pm. At least last time I tried, their %Config
override didn't override enough, and it ended up passing MSVC switches
to GCC.
Yes, I am a little annoyed here :). I spent rather more time than I
would have liked trying to figure out what on Earth was going on, and
why some people seemed to have an ActivePerl that kind-of worked with
GCC whereas mine absolutely didn't (I have MSVC6, and it was in my
PATH).
More generally, having %Config (which is supposed to be Configure-time
information) randomly changing based on which of several programs are
found first in your %PATH% isn't exactly a sane idea. Having a Start
menu option 'Switch my perl over to using GCC' that completely replaces
Config_heavy.pl with a version that is *correctly* configured for GCC
would have been much better (or even installing like that, and having
the option to switch back).
> If you 'ppm install MinGW' (rather than use Strawberry's MinGW),
> you'll even be able to build some extensions (eg PGPLOT and various
> PDL components) on ActivePerl that can't be built on Strawberry Perl -
> because the MinGW that you 'ppm install' includes the g77 fortran
> compiler, whereas the MinGW that ships with Strawberry Perl does not.
> (At least, it didn't last time I checked - apologies if this omission
> has since been rectified.)
I don't know. I presume you've reported this in the appropriate place
(which appears to be the Perl-Dist-Strawberry RT queue, AFAICS)? It
seems like a trivial thing to fix, if it's causing real problems.
Ben
------------------------------
Date: Wed, 10 Jun 2009 17:24:41 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: understanding \Q \E
Message-Id: <9b35g6-ol1.ln1@osiris.mauzo.dyndns.org>
Quoth Tad J McClellan <tadmc@seesig.invalid>:
>
> Does Strawberry Perl install "perldoc" and the PODs?
Yes. (perldoc is actually installed as perldoc.bat, of course, since
Windows doesn't do #! lines. It can still be invoked as 'perldoc',
though things like piping to and from perldoc probably won't work very
well.)
Generally the aim of Strawberry is to get as close to a typical Unix
perl install as possible, which is why I tend to recommend it to people.
Ben
------------------------------
Date: Wed, 10 Jun 2009 06:21:28 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: What happened to perl doc
Message-Id: <slrnh2v5po.q4r.tadmc@tadmc30.sbcglobal.net>
brian d foy <brian.d.foy@gmail.com> wrote:
> In article <Xns9C207DAB5ED62asu1cornelledu@127.0.0.1>, A. Sinan Unur
><1usa@llenroc.ude.invalid> wrote:
>
>> perl man <klausfpga@gmail.com> wrote in
>> news:80ddda9c-27b3-4346-b59c-5630341b15ad@f10g2000vbf.googlegroups.com:
>>
>> > I use perldoc.perl.org a lot to browse perl documentation
>> > interactively
>> > Loosing this capability would be a real pity :-(
>>
>> Why??? The documentation for your version of Perl is on your computer.
>
> I find a web browser much more convenient. I even look at
> search.cpan.org instead of reading module docs locally.
I usually grab an unformatted version of the docs when I'm
in "reference mode", where I just want to look something up, eg:
perldoc -u CGI >CGI.pod
grep ^= CGI.pod | grep -i cookie
vi '+/=head1 HTTP COOKIES' CGI.pod
But when I'm in "learning mode", as with a new module for instance,
I too view the docs in a browser so that they can be prettily printed.
Then I put the printout in the smallest room in my house for when
I have to... um... errr... study.
:-)
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Wed, 10 Jun 2009 15:45:44 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: What happened to perl doc
Message-Id: <Xns9C2677A95D126asu1cornelledu@127.0.0.1>
brian d foy <brian.d.foy@gmail.com> wrote in
news:100620090327593449%brian.d.foy@gmail.com:
> In article <Xns9C207DAB5ED62asu1cornelledu@127.0.0.1>, A. Sinan Unur
> <1usa@llenroc.ude.invalid> wrote:
>
>> perl man <klausfpga@gmail.com> wrote in
>> news:80ddda9c-27b3-4346-b59c-
5630341b15ad@f10g2000vbf.googlegroups.com
>> :
>>
>> > I use perldoc.perl.org a lot to browse perl documentation
>> > interactively
>> > Loosing this capability would be a real pity :-(
>>
>> Why??? The documentation for your version of Perl is on your
>> computer.
>
> I find a web browser much more convenient. I even look at
> search.cpan.org instead of reading module docs locally. You don't have
> to do it that way, but I like it.
I do use HTML docs a lot as well. However, the files are on my hard
drive. Why would one want to do development with a constant connectivity
requirement?
The OP was complaining that if perldoc.perl.org did not work, then he
would lose the ability to browse Perl documentation interactively. My
reaction was to that: He is on Windows, he seems to be using
ActiveState, the link to the HTML documentation is installed in his
start menu. There is no reason for him to lose 'this capability'!
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 2470
***************************************