[17067] in Perl-Users-Digest
Perl-Users Digest, Issue: 4479 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 1 00:06:46 2000
Date: Sat, 30 Sep 2000 21:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <970373112-v9-i4479@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 30 Sep 2000 Volume: 9 Number: 4479
Today's topics:
ANNOUNCE: Lingua::EN::VerbTense <jdb@wcoil.com>
Re: AppConfig <tzz@iglou.com>
Re: arrays in formats (Daniel Chetlin)
Re: Arrogant kid takes on huge group of programmers (wa (Keith Calvert Ivey)
automatic email attachments <dave@marballs.co.uk>
Re: automatic email attachments <reedfish@ix.netcom.com>
Bacic Log file script - Calling it from my HTML page <dave@marballs.co.uk>
Re: Bacic Log file script - Calling it from my HTML pag <simonis@myself.com>
Re: CGI trouble <sxm124@po.cwru.edu>
Re: CGI trouble Rand25@juno.com
Re: CGI trouble Rand25@juno.com
Re: CGI trouble <godzilla@stomp.stomp.tokyo>
Re: CGI trouble <ron@savage.net.au>
Re: DBI and MS-Access <jeff@vpservices.com>
Re: different handling of = on unix and windows (in cha <bwalton@rochester.rr.com>
Re: Executing exe from webpage (Craig Berry)
Re: File upload testing if it's there <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Sep 2000 06:48:00 GMT
From: "Josiah" <jdb@wcoil.com>
Subject: ANNOUNCE: Lingua::EN::VerbTense
Message-Id: <std6kbd6i3pk09@corp.supernews.com>
Greetings all,
Announcing the release of:
Lingua::EN::VerbTense, v3.00
Derived from demo script by Chris Meyer.
Recomended download URL:
http://www.josiah.countystart.com/modules/get.pl?verb_tense:announce
This file has also entered the CPAN as:
file: $CPAN/authors/id/J/JB/JBRYAN/Lingua-EN-VerbTense-3.00.zip
size: 14479 bytes
md5: e9f8738d402b73dd61509a3c3ef7239f
**NAME:
Linga::EN::VerbTense - Parses verb structures into modal, tense, &
infinitive.
** SYNOPSIS:
use Lingua::EN::VerbTense;
my $string = 'I am going home now.'
my ($modality, $tense, $inf) = verb_tense($string);
# Gives:
# $modality='None', $tense='Present Progressive', $inf='go'
$string = 'He really did eat the cookie.';
($modality, $tense, $inf) = verb_tense($string);
# Gives:
# $modality='Affirmative', $tense='Present', $inf='eat'
$string = 'How could she have done that???';
($modality, $tense, $inf) = verb_tense($string);
# Gives:
# $modality='Subjective Ability', $tense='Perfect', $inf='do'
** DESCRIPTION:
This is a simple Perl module designed to parse english verb structures
using a finite state machine into the verb tense and infinitive, as well
as the type of infinitive in the structure. This was originally written
by Chris Meyer <chris@mytechs.com>. Josiah Byran <jdb@wcoil.com> added
multiple tweaks and twists, POD docs, and CPAN packaging.
Cheers!
--
Josiah Bryan <jdb@wcoil.com>
------------------------------
Date: 30 Sep 2000 18:45:52 -0500
From: Ted Zlatanov <tzz@iglou.com>
Subject: Re: AppConfig
Message-Id: <970353536.18302@iglou.com>
In article <8r31k7$iv0$1@nnrp1.deja.com>, fsconzo@my-deja.com wrote:
>Does anyone know what I am doing wrong?
Sure!
1) use the -w flag to perl:
#!/usr/local/bin/perl -w
2) use the strict pragma
use strict;
3) import the argcount constants from AppConfig
use AppConfig qw/:argcount/;
4) use Data::Dumper to see if things are OK, rather than writing your own
(possibly wrong) loops
use Data::Dumper;
...
print Dumper $config->groupcode();
With (1) and (2), you would have had warnings about (3) and you would have
found the problem. Following these recommendations will make your life much,
much easier.
(4) is my personal preference, as it is simpler and easier to see a complex
structure with Data::Dumper than doing it yourself, especially for nested data
structures.
--
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais
------------------------------
Date: 30 Sep 2000 21:14:32 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: arrays in formats
Message-Id: <8r5l3o1q9i@news1.newsguy.com>
On Sat, 30 Sep 2000 03:50:13 -0500,
Daniel Zepeda <dzepeda@cs.utsa.edu> wrote:
>Hi,
> I'm trying to print out an array in a format. I expected this to
>work but it only gave me the first line in the array. I've pored over the
>documentation but can't find what I need to help.
>
>format MYFORMAT=
><html>
> <title>This is HTML</title>
> <body bgcolor="white">
>
> @*
> @input
>
>
> </body>
></html>
>.
If this is really exactly what you're trying to do, formats are
overkill. However, assuming there's a little more to it, what you want
to do is print the top and bottom parts, which appear to be static,
directly to the file using print, and then loop over the array. E.g.:
my $input;
format MYFORMAT =
@*
$input
.
...
for $input (@input) { write MYFORMAT }
-dlc
------------------------------
Date: Sat, 30 Sep 2000 23:21:34 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Arrogant kid takes on huge group of programmers (was Re: How to get length of scalar?)
Message-Id: <39d872fb.81818286@news.newsguy.com>
"Mark Carruth" <mcarruth@talk21.com> wrote:
>I know I am getting boring now, but I really don't see why the huge group of
>programmers are literally taking the piss out of me. I am new to newsgroups
>so instead of slagging me off because I post HTML, someone could just tell
>me not to, and then I would willingly turn off HTML posting which I have now
>done.
You didn't sound very willing to me. You started this whole
argument about how posting HTML was just fine, even if everyone
else trashed you for it. And now you're doing the same thing
about your nonstandard quoting style.
>And as for the quoting, I will quote whatever I like. There is no English
>rule against it.
But there's a Usenet rule against it, and certainly a c.l.p.misc
rule against it. Not that it matters much what you do anymore,
since few people who can give you useful answers will see
anything you write now. You've taken the fast track into
people's killfiles, I'm afraid.
I don't understand the point of coming into a newsgroup and
pissing off the inhabitants as quickly as possible.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Sun, 1 Oct 2000 02:23:09 +0100
From: "Dave" <dave@marballs.co.uk>
Subject: automatic email attachments
Message-Id: <8r63i3$llu$1@newsg2.svr.pol.co.uk>
Hello,
Sorry if this is a basic question but I have scanned for similar and have
not managed to find one.
Does anybody know how I can code Perl to automatically send an email with an
attachment.
My understanding is that the sendmail command can not have attachments and
commands like Pine cannot but run from the command line with out user
interaction.
Therefore does anyone know what I should do. I am looking for the most
simple solution possible as I would like users of my web site to be able to
enter their email address and be sent an email with the attachment right
away.
Please help me with this matter and if a better solution lies not in PERL
then please suggest.
Thanks in advance
Dave
--
------------------------------
Date: Sat, 30 Sep 2000 21:26:40 -0400
From: "Brian Kelly" <reedfish@ix.netcom.com>
Subject: Re: automatic email attachments
Message-Id: <8r642t$drn$1@slb6.atl.mindspring.net>
Try the Mail::Sender module in CPAN.
Dave <dave@marballs.co.uk> wrote in message
news:8r63i3$llu$1@newsg2.svr.pol.co.uk...
> Hello,
>
> Sorry if this is a basic question but I have scanned for similar and have
> not managed to find one.
>
> Does anybody know how I can code Perl to automatically send an email with
an
> attachment.
>
> My understanding is that the sendmail command can not have attachments and
> commands like Pine cannot but run from the command line with out user
> interaction.
>
> Therefore does anyone know what I should do. I am looking for the most
> simple solution possible as I would like users of my web site to be able
to
> enter their email address and be sent an email with the attachment right
> away.
>
> Please help me with this matter and if a better solution lies not in PERL
> then please suggest.
>
> Thanks in advance
>
> Dave
>
> --
>
>
>
------------------------------
Date: Sun, 1 Oct 2000 02:57:21 +0100
From: "Dave" <dave@marballs.co.uk>
Subject: Bacic Log file script - Calling it from my HTML page
Message-Id: <8r65io$7uc$1@newsg3.svr.pol.co.uk>
Ok, another basic question but I am just trying to grasp this stuff.
I have my basic cgi/perl log file script that logs the details of my
visitors.
But how do I automatically call this script without having a submit button
that is pressed.
Looking through tutorials I cannot seem to find how this is done.
Is there no way of just writing a line in my web page that will run the cgi
script but still carry on displaying the page.
I hope that makes sense
Thanks in advance.
Dave
--
------------------------------
Date: 01 Oct 2000 03:21:03 GMT
From: Drew Simonis <simonis@myself.com>
Subject: Re: Bacic Log file script - Calling it from my HTML page
Message-Id: <39D6AB10.56ADBAF1@myself.com>
SSI, but thats not Perl...
------------------------------
Date: Sat, 30 Sep 2000 20:30:03 -0400
From: Sid Malhotra <sxm124@po.cwru.edu>
Subject: Re: CGI trouble
Message-Id: <39D6858B.3C072784@po.cwru.edu>
Since you are running win98, try comp.infosystems.www.servers.ms-windows
this is the newsgroup for apache on win32. I'm sure someone here will be able
to solve your problem.
Sid.
Drew Simonis wrote:
> Rand25@juno.com wrote:
> >
> > I just installed Apache Server for Win32, and it seems to work fine,
> > but I cant access my cgi-bin directory to test a cgi script (test.cgi).
> > I tried http://localhost/cgi-bin/test.cgi, but I got an internal error.
> > What url should I use, and is there a way to browse my new "IntraNet"
> > without having to type localhost....its kinda long, and I'm really lazy.
> > I'm running Windows 98 and Apache 1.3.12.
> > Thanks
>
> You'd be best suited by asking a question about your web server
> configuration in a NG dedicated to the discussion of such things.
>
> comp.infosystems.www.servers.misc
------------------------------
Date: Sun, 01 Oct 2000 01:45:52 GMT
From: Rand25@juno.com
Subject: Re: CGI trouble
Message-Id: <8r650f$p65$1@nnrp1.deja.com>
In article <slrn8tccna.21b.tim@degree.ath.cx>,
tim@degree.ath.cx (Tim Hammerquist) wrote:
> First, this is not Perl. But...
>
> Rand25@juno.com <Rand25@juno.com> wrote:
> > I just installed Apache Server for Win32, and it seems to work fine,
> > but I cant access my cgi-bin directory to test a cgi script
> >(test.cgi).
> > I tried http://localhost/cgi-bin/test.cgi, but I got an internal
> >error.
> > What url should I use,
>
> Apache usually has the following setup (on Win32):
>
> D:\$DOCUMENT_ROOT\htdocs\ maps to http://localhost/
> D:\$DOCUMENT_ROOT\cgi-bin\ maps to http://localhost/cgi-bin/
>
> ...where D:\$DOCUMENT_ROOT\ is the directory where the Apache document
> tree begins. This is set with the DocumentRoot directive in your
> httpd.conf or httpd_conf file.
>
> Assuming all this is correct and permissions are set correctly, you
> should be able to access your script, provided it's in the correct
> directory.
I read the httpd.conf file and got all that, but assuming I'm a newbie
you can be assured my permissions are not set correctly and it is in
the correct directory, I created it there....
>
> What you failed to mention is _which_ server error. Apache should
> give
> you a 3-digit error code. The most common codes are 403, 404, and 500.
> 404 indicates you have a server configuration error, or your script
> just
> isn't there. 500 means you're half-way to success; it usually means
> your script isn't conforming to CGI protocol, often due to errors in
> the
> script.
Error 500 (in the title bar, I didn't look up there before)
>
> Check your error.log (aka error_log) to figure out what's causing the
> error and if it's a script problem, THEN it's a Perl question. (Are
> you
> sending a Content-Type header?) If it's a configuration problem, you
> need to tinker with httpd.conf.
I got the script out of a book teaching Perl and CGI (Visual Quickstart
Guide Perl and CGI for the World Wide Web)
#!(I've tried everything here)
print "Content-type:text/html\n\n";
print "Hellow World";
>
> Check the server documentation that
> comes with your server at http://localhost/manual on my box.
I looked at all the stuff they had for CGI and tried all the things it
suggested, but I may have gotten something wrong...
>
> > and is there a way to browse my new "IntraNet"
> > without having to type localhost....its kinda long, and I'm really
> >lazy.
>
> No.
>
> Unless you're a client on another intranet and your computer's name is
> something other than 'localhost'. However, since you _can_ view your
> server via 'localhost', this is most likely not the case, and you can
> just deal with it or move to *nix where you can choose your machine's
> name.
>
> > I'm running Windows 98 and Apache 1.3.12.
>
> My condolences. I know what you're going through, but there _is_
hope.
> My savior appeared as a penguin, but yours may just come from
> Berkeley instead.[*] ;)
My other computer has Red Hat Linux 6.1 on it, I like the Matrix like
screen saver with the falling text....waz berkley?
>
> [*] http://www.freebsd.org/
> http://www.linux.org/
>
> --
> -Tim Hammerquist <timmy@cpan.org>
>
> People get annoyed when you try to debug them.
> -- Larry Wall, 1999
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 01 Oct 2000 02:02:06 GMT
From: Rand25@juno.com
Subject: Re: CGI trouble
Message-Id: <8r65us$pv1$1@nnrp1.deja.com>
In article <39D62C1B.84DD260C@stomp.stomp.tokyo>,
Anonymous <anonymous@anonymous.anonymous> wrote:
> Rand25@juno.com wrote:
>
> > I just installed Apache Server for Win32, and it seems to work fine,
>
> You are indicating you have a problem. Your system setup
> does not work fine, yes?
I mean it works when I test to see if the server is running and all
that, but my CGI settings are not set correctly and since this is a
Perl forum (CGI is usually written in Perl) I thought that someone who
went through this before could help. I also started a thread similar
to this in another forum...
>
> > but I cant access my cgi-bin directory to test a cgi script
> > (test.cgi).
>
> A good start would be to read this extensive documentation which
> comes with an Apache install. Doing so, will provide answers to
> almost all problems you encounter.
True, but English is easier to read than Yoda's ramblings.
>
> > I tried http://localhost/cgi-bin/test.cgi, but I got an internal
> > error.
>
> Then your system does not work fine. Is this not true?
My "system" works as fine as Windows will allow
>
> > What url should I use,
>
> None of us are Internet Mind Readers. Use an URL which
> is appropriate for your system.
I was hoping that you would be able to infer some basic things about my
system in order to logically deduce a URL that would be appropriate to
my system
>
> > and is there a way to browse my new "IntraNet" without
> > having to type localhost....its kinda long, and I'm really lazy.
>
> Laziness is a personal problem only you can resolve.
It is not a problem, it is my greatest ally
>
> Anonymous Godzilla!
> --
> Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
> UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
> BumScrew, South of Egypt ¦ HTML Programming Class
>
> --
>
> --------== Posted Anonymously via Newsfeeds.Com ==-------
> Featuring the worlds only Anonymous Usenet Server
> -----------== http://www.newsfeeds.com ==----------
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 30 Sep 2000 20:20:52 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: CGI trouble
Message-Id: <39D6AD94.392E9F66@stomp.stomp.tokyo>
Rand25@juno.com wrote:
> Anonymous Godzilla! wrote:
> > Rand25@juno.com wrote:
> > > I just installed Apache Server for Win32, and it seems to work fine,
> > You are indicating you have a problem. Your system setup
> > does not work fine, yes?
> I mean it works when I test to see if the server is running and all
> that, but my CGI settings are not set correctly and since this is a
> Perl forum (CGI is usually written in Perl) I thought that someone who
> went through this before could help. I also started a thread similar
> to this in another forum...
Clarity in communication is important. Clarity in thinking
is more important. However, imagination is more important
than knowledge, according to Albert Einstein. I have no
reason to doubt his word.
Rest assured, many here have experienced what you describe.
However, none of them are nice enough to help you. They
couldn't be bothered.
Fortunately for me, unfortunately for you, I have sense
enough to not install Perl on my home system. What a
mess this must make.
> > > but I cant access my cgi-bin directory to test a cgi script
> > > (test.cgi).
> > A good start would be to read this extensive documentation which
> > comes with an Apache install. Doing so, will provide answers to
> > almost all problems you encounter.
> True, but English is easier to read than Yoda's ramblings.
I wouldn't pay typical documentation this much of a compliment.
Have you tried reading Perl documentation? Good. Don't bother.
Reading Perl documentation will leave you stupefied and knowing
less about Perl than when you started reading.
Your Yoda secret is in your server configuration, specifically
your access configuration documentation. Hmm... Yoda might
speak very clearly if you look at Add Handler in your docs,
then read up on srm.conf file and httpd.conf file. Trust me.
> My "system" works as fine as Windows will allow
Too bad Redmond didn't stick with Win 3.x series. This is
the most powerful graphical user interface ever written.
I still use my Win 3.x DOS 6.x system to perform powerful
tasks my Win 98 system cannot do.
> I was hoping that you would be able to infer some basic things about my
> system in order to logically deduce a URL that would be appropriate to
> my system
You set your own path or paths, according to your
Apache documentation. You could shorten your path
with effective use of following symbolic links.
It's in your docs.
> > Laziness is a personal problem only you can resolve.
> It is not a problem, it is my greatest ally
Hard work has future rewards. Laziness pays off right now.
However, the second mouse gets the cheese.
Godzilla!
--
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class
------------------------------
Date: Sun, 1 Oct 2000 14:20:06 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: CGI trouble
Message-Id: <t4yB5.14282$O7.193862@ozemail.com.au>
See my posting on comp.lang.perl.modules a few moments ago.
Or visit: http://savage.net.au/Perl-tutorials.html
--
Cheers
Ron & Pen Savage
ron@savage.net.au pen@savage.net.au
http://savage.net.au/index.html
<Rand25@juno.com> wrote in message news:8r58n6$510$1@nnrp1.deja.com...
> I just installed Apache Server for Win32, and it seems to work fine,
> but I cant access my cgi-bin directory to test a cgi script (test.cgi).
> I tried http://localhost/cgi-bin/test.cgi, but I got an internal error.
> What url should I use, and is there a way to browse my new "IntraNet"
> without having to type localhost....its kinda long, and I'm really lazy.
> I'm running Windows 98 and Apache 1.3.12.
> Thanks
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Sat, 30 Sep 2000 20:00:24 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: DBI and MS-Access
Message-Id: <39D6A8C8.27F788C4@vpservices.com>
James Vahn wrote:
>
> Jeff Zucker wrote:
> > Here's my suggestion: put "Ms-Access Linux" in the search box at
> > http://www.deja.com/usenet/ and read some of the 400 previously
> > discussed messages on this topic.
>
> I found no answers to the poster's question there.
I did. Perhaps the most succinct are the ones that point to Tom
Lowery's FAQ sections titled
3.How do I access a MS Windows based database from a
UNIX/Linux machine using DBI::Proxy?
4.How do I access a MS Windows based database from a
UNIX/Linux machine using OpenLinks Request Broker?
5.How do I access a MS Windows based database from a
UNIX/Linux machine using unixODBC?
Which can be found at:
http://tlowery.hypermart.net/perl_dbi_dbd_faq.html
--
Jeff
------------------------------
Date: Sun, 01 Oct 2000 03:04:30 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: different handling of = on unix and windows (in char class)
Message-Id: <39D6A9C2.6F4AE157@rochester.rr.com>
Zoltan Gyenes wrote:
>
> and again...
>
> after a brief testing I found that running the line
>
> print "matches\n" if "</B>"=~m/<[+-=].+?>/g;
>
> leads to DIFFERENT results depending the OS, on unix (Tru64) I get the
> correct answer (nothing) because "/" is none of the [+-=] characters.
> But on Windows NT 4 it prints "matches". the key character is the "=",
> without it everything is fine, but including it Win32 perl somehow
> matches the "/" with "=". (it's the same if you use ":", "." and some
> other chars instead of "/", moreover replacing "=" with "\061" also
> doesn't work)
> AFAIK in character classes the metacharacters lose their "metaness",
> but putting a "*" (into character class) dies on win32 (not on unix).
> Anybody experienced similar problems or maybe I know something
> terribly wrong?
Hmmmmm...well, in ASCII, / (0x2F) *is* between + (0x2B) and = (0x3D), so
it *should* match. But your platform may not be using the ASCII
character set. Maybe some code like:
print join(', ',(ord('+'),ord('/'),ord('='))),"\n";
would clarify. Or maybe you should just spell out the characters you
want in the character class in full, as the docs recommend.
...
> Zoltan Gyenes
--
Bob Walton
------------------------------
Date: Sat, 30 Sep 2000 22:27:26 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Executing exe from webpage
Message-Id: <stcq6ei0htg84e@corp.supernews.com>
Rand25@juno.com wrote:
: I cant seen to find a way to execute files from an html/javascript
: menu....is there a way to do it with CGI or inline Perl? I want to have
: be able to run games and My Computer from a menu attached to my Active
: Desktop page.
This really has nothing to do with Perl; execution of client-local apps is
going to depend on client-local code (presumably Javascript or client-side
Java or some Microsoft Active Fill-In-The-Blank hack. (It also sounds
like a massive security hole, but again, that's not a Perl issue.) I'd
suggest asking this on more appropriate newsgroups.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: Sun, 01 Oct 2000 02:30:03 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: File upload testing if it's there
Message-Id: <39D6A1AF.4081AD64@rochester.rr.com>
yorktown5425@my-deja.com wrote:
>
> I thought using the 'defined' stuff was standard fair with CGI scripts
> (CGI.pm), for example this code works:
>
> <snippet of code>
> $Name = $query->param("Name");
>
> # make sure a name was sent
> if (!defined $Name) {
> print "No name specified!!";
> exit;
> }
> </snippet of code>
>
> If the person doesn't enter some text in the "Name" field then the if
> block is executed, but if they do enter text then the if block is
> skipped.
>
> am I relying on an unintended side affect here?
Hmmmm...well, I just tried it on a Windoze 98 SE system with Perl
5.005_03 ActiveState build 522 and the WebSite 1.1 web server (running
locally). An <input type="text" name="whatever"> field always returns a
defined value. It is the null string if nothing is entered into that
field in the form. Things like checkboxes will simply fail to return a
name=value pair from the browser, and will come up as undef. But it
looks like standard text fields will not generate undef. Here is my
test code (straight from the CGI docs, with one line [plus a comment
line identifying that line] added):
# CGI script that creates a fill-out form
# and echoes back its values.
use CGI qw/:standard/;
print header,
start_html('A Simple Example'),
h1('A Simple Example'),
start_form,
"What's your name? ",textfield('name'),p,
"What's the combination?", p,
checkbox_group(-name=>'words',
-values=>['eenie','meenie','minie','moe'],
-defaults=>['eenie','minie']), p,
"What's your favorite color? ",
popup_menu(-name=>'color',
-values=>['red','green','blue','chartreuse']),p,
submit,
end_form,
hr;
if (param()) {
#following line added to test defined
if(defined(param('name'))){print "name is defined",p;}
print "Your name is",em(param('name')),p,
"The keywords are: ",em(join(", ",param('words'))),p,
"Your favorite color is ",em(param('color')),
hr;
}
There is a possibility the results might depend upon the behavior of the
web browser. I suppose the browser could choose to send a name= when
the field is not filled in, or it could omit it entirely (I don't know
what the standards say, but nobody seems to pay attention to them
anyway). Netscape 4.75 sends the name regardless. So does IE
5.00.2614.3500IC. To have your scripts be portable across browsers, it
looks like you should not rely on a defined test for text fields.
--
Bob Walton
>
> In article <39D5683A.57BAA9BB@rochester.rr.com>,
> Bob Walton <bwalton@rochester.rr.com> wrote:
> > jim_marshall2268@hotmail.com wrote:
> > >
> > > I'm new to perl, started two days ago. I've been doing C/C++ and
> Java
> > > for many years...
> > >
> > > I'm writing a small script to do file upload (fileupload), I'm using
> > > the CGI.pm module. The form I have has three file upload fields,
> but
> > > the user can select to upload only 1 file (or just 2 files, or all
> 3).
> > > So I want to test if the field is present.
> > >
> > > I tried this
> > >
> > > $jpgFile = $query->param("pic1");
> > > # if (defined $jpgFile) {
> > > if ($jpgFile) {
> > > print "File pic1 is present";
> > > }
> > > elif {
> > > print "File 'pic1' is not present";
> > > }
> > >
> > > No matter what the "is not present" code was being executed. I
> ended up
> > > having to do this
> > >
> > > $jpgFile = $query->param("pic1");
> > > if ($jpgFile ne '') {
> > > print "File pic1 is present";
> > > }
> > > elif {
> > > print "File 'pic1' is not present";
> > > }
> > >
> > > Can someone explain why the former didn't work? And if it is safe
> and
> > > valid to use the later? The code works fine with the 'ne' but I
> want
> > > to be sure it is ok.
> > >
> > > Thanks
> > > -Jim
> > ...
> > Couple of things:
> >
> > 1. Your printed messages indicate that you somehow think this code
> will
> > test for the presence of a file. It is merely testing for the
> presence
> > of a filled-in filename in your form.
> >
> > 2. The "defined" function will return true if the variable is
> defined,
> > regardless of the value it stores (except for undef). If it contains
> > the null string, it is still defined. Thus, your call to defined will
> > always return true, since you have defined $jpgFile and it will never
> > contain undef. See:
> >
> > perldoc -f defined
> >
> > 3. Your second way of doing it should be OK. It is better than just:
> >
> > if($jpgFile){...
> >
> > since that would fail if the value of $jpgFile was 0. An unlikely,
> but
> > possible, filename.
> >
> > 4. To actually test for the presence of a file, see the -e operator.
> > See:
> >
> > perldoc -f -e
> >
> > --
> > Bob Walton
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4479
**************************************