[15432] in Perl-Users-Digest
Perl-Users Digest, Issue: 2842 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 22 14:05:27 2000
Date: Sat, 22 Apr 2000 11:05:11 -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: <956426711-v9-i2842@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 22 Apr 2000 Volume: 9 Number: 2842
Today's topics:
Re: "Advanced Search" problems... Plz HELP! <lr@hpl.hp.com>
.pag and .dir files disappear; I get . and .db files <ness@willowmountain.com>
Re: .pag and .dir files disappear; I get . and .db file <tony_curtis32@yahoo.com>
Re: .pag and .dir files disappear; I get . and .db file <ness@willowmountain.com>
Re: <textarea> problem <gellyfish@gellyfish.com>
Re: Converting HTML hex characters to characters mongoose@wpi.edu
Re: Converting HTML hex characters to characters <tmp0001@unixsnedkeren.dk>
creating a =~ operator <dwb1@home.com>
Re: creating a =~ operator <lr@hpl.hp.com>
Re: emulate a browser <jeff@vpservices.com>
finding current directory in Net::FTP ? <emmons@frozenlinux.com>
Re: finding current directory in Net::FTP ? <tony_curtis32@yahoo.com>
Re: Form to Html template sample code neede <joe90@nospam-please.thanks>
Re: Form to Html template sample code neede (Randal L. Schwartz)
Re: Form to Html template sample code neede (Randal L. Schwartz)
Re: Form to Html template sample code neede <gellyfish@gellyfish.com>
Re: Good Techniques and Practices <gellyfish@gellyfish.com>
Re: Good Techniques and Practices <gellyfish@gellyfish.com>
Re: How to detect when a connection is dropped with Per <gellyfish@gellyfish.com>
Re: How to pass parameter? <gellyfish@gellyfish.com>
Re: If Statement nobull@mail.com
Re: If Statement <lr@hpl.hp.com>
Re: If Statement <godzilla@stomp.stomp.tokyo>
Re: local function question <tony_curtis32@yahoo.com>
Make Test Error in GD.pm <yaqoota@emirates.net.ae>
Re: Make Test Error in GD.pm <elaine@chaos.wustl.edu>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 22 Apr 2000 08:32:42 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: "Advanced Search" problems... Plz HELP!
Message-Id: <MPG.136b65f2d98f048d98a959@nntp.hpl.hp.com>
In article <u98zy61i4y.fsf@wcl-l.bham.ac.uk> on 22 Apr 2000 12:37:17
+0100, nobull@mail.com <nobull@mail.com> says...
> er@matrix.com.br (Lobo) writes:
...
> > For an example, I have a file that have
> > this fields:
> >
> > Lobo|27|Brazil|27, Gustavo Schmidt street|blablabla
> >
> > and I need the search to find only the "27" value of the second field,
> > not the fourth field...
>
> There are many solutions, here are two:
>
> /^[^\|]*\|27\|/
This is correct, though the '|' doesn't need escaping within the
character class.
> (split '|')[1] eq 27
This is incorrect, because the '|' does need escaping within the regex
that is the first argument to split(), even though you chose to write it
as a string.
I argued a while ago that literal strings (other than " " in any form)
as the split operand deserved to draw a warning. Probably that proposal
should have been 'literal strings containing unescaped regex
metacharacters'.
That wasn't embraced, because it might introduce warnings into correct,
functioning programs. But maybe with the new degrees of control over
warnings in 5.6, this change might be considered again. As you can see
from this example, even relatively knowledgeable Perl programmers can
fall into this trap.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 22 Apr 2000 09:35:09 -0700
From: "Ness Mountain" <ness@willowmountain.com>
Subject: .pag and .dir files disappear; I get . and .db files
Message-Id: <fqkM4.320$pK4.6504@typhoon.aracnet.com>
Hi, thanks for reading this.
I have a simple CGI database application, the only thing I've written in
Perl. It's being used by several people, and it works fine almost all the
time. SOMETIMES, don't know when or why, it slags the database files,
destroying them utterly.
When this happens, I have gotten the information back off a recent backup
and started again, but my users are losing patience.
This problem seems in my confused brain to be related to the file names the
hash files are stored in. It used to make files called
LeadDBHash.pag and
LeadDBHash.dir
Now I see only
LeadDBHash. and
LeadDBHash.db
After the disaster, just now, I deleted the . and .db files, and started the
system. The dbmopen statement recreates the (empty) database, and it works
fine, although the only file now seems to be
LeadDBHash.
Does anyone know what is going on? I am frantic. It has done it three
times.
Thanks in advance for your advice!
Ness Mountain
Willow Mountain Consulting
------------------------------
Date: 22 Apr 2000 11:34:08 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: .pag and .dir files disappear; I get . and .db files
Message-Id: <87itxaw0vz.fsf@shleppie.uh.edu>
>> On Sat, 22 Apr 2000 09:35:09 -0700,
>> "Ness Mountain" <ness@willowmountain.com> said:
> Hi, thanks for reading this. I have a simple CGI
> database application, the only thing I've written in
> Perl. It's being used by several people, and it works
> fine almost all the time. SOMETIMES, don't know when or
> why, it slags the database files, destroying them
> utterly.
You're not locking the database against multiple writes.
perldoc -q lock
hth
t
------------------------------
Date: Sat, 22 Apr 2000 09:43:15 -0700
From: "Ness Mountain" <ness@willowmountain.com>
Subject: Re: .pag and .dir files disappear; I get . and .db files
Message-Id: <QxkM4.321$pK4.6375@typhoon.aracnet.com>
Tony Curtis <tony_curtis32@yahoo.com> wrote in message
news:87itxaw0vz.fsf@shleppie.uh.edu...
> >> On Sat, 22 Apr 2000 09:35:09 -0700,
> >> "Ness Mountain" <ness@willowmountain.com> said:
>
> > Hi, thanks for reading this. I have a simple CGI
> > database application, the only thing I've written in
> > Perl. It's being used by several people, and it works
> > fine almost all the time. SOMETIMES, don't know when or
> > why, it slags the database files, destroying them
> > utterly.
>
> You're not locking the database against multiple writes.
>
> perldoc -q lock
>
> hth
> t
Is that related to the filename issue?
------------------------------
Date: 22 Apr 2000 14:33:44 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: <textarea> problem
Message-Id: <8ds9no$mic$1@orpheus.gellyfish.com>
On Fri, 21 Apr 2000 13:27:47 -0400 Roger Watson wrote:
> I have had a strange result when sending form data to a Perl variable using
> the <textarea> tag. It appears to limit the data to 1000 characters even
> though there is no such limit imposed in the <textarea> tag.
>
> I have entered the same data into a <input type="text"> tag (in the same
> form) and no such limitation -- all the data is captured by the variable as
> expected.
>
> Has anyone else seen this? What is going on here?
I dont know but I think you are asking in the wrong group.
comp.infosystems.www.authoring.cgi
Should be of more assistance.
Of course you might also get more help if you actually show the smallest
piece of Perl code that demonstrates this behaviour. I for one would not
be interested in seeing your entire program.
/J\
--
I promised my boy one simple thing: lots of riches, and that man broke
my promise!
--
fortune oscar homer
------------------------------
Date: Sat, 22 Apr 2000 11:02:58 -0500
From: mongoose@wpi.edu
Subject: Re: Converting HTML hex characters to characters
Message-Id: <3901CD32.57A1C023@wpi.edu>
Jonathan Stowe wrote:
>
> On Sat, 22 Apr 2000 01:41:27 -0500 mongoose@wpi.edu wrote:
> > Ok one of my fields in an html forms returns a string a users wrote, but
> > if the user puts in chars like ! or ? it just returns the hex number
> > in %3F or something similiar. How do I convert these hex strings into
> > characters? I thought this should work but this only seems to not work
> > with the \x character
> >
> > $data =~ s/\%([0-9A-F]{2})/\x$1/g;
> >
> > . I want to replace all the %hh with the one character equivelent.
>
> If you use some module like CGI.pm then this will be done for you before
> you need to access the parameter.
I added the line
use CGI;
to the perl script but what do I do now to get it to parse the strings
the webbrowser gives me?
------------------------------
Date: Sat, 22 Apr 2000 18:32:20 +0200
From: Thorbjoern Ravn Andersen <tmp0001@unixsnedkeren.dk>
Subject: Re: Converting HTML hex characters to characters
Message-Id: <3901D414.C4E22B23@unixsnedkeren.dk>
mongoose@wpi.edu wrote:
> I added the line
> use CGI;
> to the perl script but what do I do now to get it to parse the strings
> the webbrowser gives me?
Read what "perldoc CGI" tells you.
--
Thorbjørn Ravn Andersen "...plus...Tubular Bells!"
http://www.mip.sdu.dk/~ravn
------------------------------
Date: Sat, 22 Apr 2000 14:57:59 GMT
From: <dwb1@home.com>
Subject: creating a =~ operator
Message-Id: <Pine.LNX.4.20.0004221002470.2805-100000@ethyl.addictmud.org>
Is it possible to create a function that can be used with the =~ operator, or
maybe make use of some other operator? so that for example, I could do
something like this:
$somevar =~ &function;
insetad of
$somevar = &function($somevar);
I'm assuming that it's not possible, but I figured I would ask anyways :)
Dan.
------------------------------
Date: Sat, 22 Apr 2000 09:12:36 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: creating a =~ operator
Message-Id: <MPG.136b6f4caa46323898a95b@nntp.hpl.hp.com>
In article <Pine.LNX.4.20.0004221002470.2805-100000@ethyl.addictmud.org>
on Sat, 22 Apr 2000 14:57:59 GMT, dwb1@home.com <dwb1@home.com> says...
>
>
> Is it possible to create a function that can be used with the =~ operator, or
> maybe make use of some other operator? so that for example, I could do
> something like this:
>
> $somevar =~ &function;
>
> insetad of
>
> $somevar = &function($somevar);
>
> I'm assuming that it's not possible, but I figured I would ask anyways :)
#!/usr/bin/perl -w
use strict;
sub regex { my $string = shift; qr{$string} }
'foo' =~ regex($_) and print "Matched $_\n" for qw( foo f.o bar );
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 22 Apr 2000 10:54:58 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: emulate a browser
Message-Id: <3901E772.13F154AE@vpservices.com>
Jonah wrote:
>
> This was from an older thread. I want this new post to be up front,
> hope this isn't the wrong thing to do, if it is let me know.
Threading good. Ignoring threading bad. Tarzan no like ignoring
threading.
> Basically, all I want to do is emulate the same effect as calling the
> mailing list
> manager script directly from the form, but I still want the form to call my
> script first so I can do what I have to do.....
I'm still lost. Could you break this down into ordered steps. What do
you want the user to do, what do you want accomplished on the server (by
what programs e.g. is the mailing list thingie a C program or what?) and
then what do you want returned to the user?
You've jumped to telling us you want to emulate a browser but it isn't
at all clear from what you've described that that is the appropriate way
to go. Expalin (so we can understand) first what you want to
accomplish, then we'll be able to comment on whether LWP is the way to
go to do that.
> read (STDIN, $content, $ENV{'CONTENT_LENGTH'});
> &parseform;
Eeeeeeeeeeeeeeeeeeew. Tarzan really hate bad parse routines. Throw
that away and use CGI.pm.
--
Jeff
------------------------------
Date: Sat, 22 Apr 2000 12:48:46 -0500
From: "Dale Emmons" <emmons@frozenlinux.com>
Subject: finding current directory in Net::FTP ?
Message-Id: <sg3pb75ll6e83@corp.supernews.com>
I've looked all over (except, obviously, the right place) to find a way that
tells the current directory that the script is in when it's connected to a
server via Net::FTP. Could someone please tell me or point me to
documentation that has it?
Thanks in advance
-Dale
------------------------------
Date: 22 Apr 2000 13:04:22 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: finding current directory in Net::FTP ?
Message-Id: <87g0sem2qh.fsf@shleppie.uh.edu>
>> On Sat, 22 Apr 2000 12:48:46 -0500,
>> "Dale Emmons" <emmons@frozenlinux.com> said:
> I've looked all over (except, obviously, the right
> place) to find a way that tells the current directory
> that the script is in when it's connected to a server
> via Net::FTP. Could someone please tell me or point me
> to documentation that has it?
You do mean the directory on the ftp server don't you, and
not the current directory of this client program?
perldoc Net::FTP
pwd ()
Returns the full pathname of the current directory.
hth
t
------------------------------
Date: Sat, 22 Apr 2000 13:51:10 GMT
From: joe 90 <joe90@nospam-please.thanks>
Subject: Re: Form to Html template sample code neede
Message-Id: <3901AFA2.6FAA3456@nospam-please.thanks>
ELPHIDE wrote:
> Hello,
>
> Could anyone send me a sample perl code for the following usage :
>
> Grab a value from a form and send it to a precise placeholder in a Html
> template.
>
# something like
# probably best to check www.perlfaq.com/faqs/
# set up module
use CGI qw(standard);
# collect parameters using CGI
my $formfieldvalue = param("formfieldvalue");
# print the formvalue in the html template
print content-type = text/html;
print <<end_of_html_statement;
# html stuff... blah blah
Your form field value was $formfieldvalue
end_of_html_statement
>
> Thanks
>
> Giotto
------------------------------
Date: 22 Apr 2000 07:07:50 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Form to Html template sample code neede
Message-Id: <m1bt32ut3d.fsf@halfdome.holdit.com>
>>>>> "ELPHIDE" == ELPHIDE <NA@NA.ORG> writes:
ELPHIDE> Could anyone send me a sample perl code for the following usage :
ELPHIDE> Grab a value from a form and send it to a precise placeholder in a Html
ELPHIDE> template.
Sorry... all the code I have sends it to an imprecise placeholder. :-)
But since your terms are all somewhat subject to interpretation, let me
at least send you to the following module, which probably does
nearly all of what you want:
perldoc CGI
CGI.pm comes with perl, so no need to even install it. :)
[aside - Are you *really* with Narcotics Anonymous? I can't tell if
your address is a spamblock (in which case you are being evil because
it's also possibly a valid address) or the real thing. Some .sig
lines would help here, sir.]
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 22 Apr 2000 07:11:20 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Form to Html template sample code neede
Message-Id: <m14s8uusxj.fsf@halfdome.holdit.com>
>>>>> "Randal" == Randal L Schwartz <merlyn@stonehenge.com> writes:
>>>>> "ELPHIDE" == ELPHIDE <NA@NA.ORG> writes:
Randal> [aside - Are you *really* with Narcotics Anonymous? I can't tell if
Randal> your address is a spamblock (in which case you are being evil because
Randal> it's also possibly a valid address) or the real thing. Some .sig
Randal> lines would help here, sir.]
No, mail to it bounced. So you are an evil person because you are
essentially stealing the resources of another valid domain holder just
so spammers won't find you. <sigh>
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 22 Apr 2000 14:44:54 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Form to Html template sample code neede
Message-Id: <8dsacm$mkp$1@orpheus.gellyfish.com>
On Sat, 22 Apr 2000 19:27:18 +0800 ELPHIDE wrote:
> Hello,
>
> Could anyone send me a sample perl code for the following usage :
>
> Grab a value from a form and send it to a precise placeholder in a Html
> template.
>
The documentation of HTML::Template perhaps ?
/J\
--
Ah, good ol' trustworthy beer. My love for you will never die.
--
fortune oscar homer
------------------------------
Date: 22 Apr 2000 13:51:11 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Good Techniques and Practices
Message-Id: <8ds77v$m7n$1@orpheus.gellyfish.com>
On Fri, 21 Apr 2000 21:10:41 GMT Bart Lateur wrote:
> Samay wrote:
>
>>Learning and using Perl Debugger is really a very good
>>Programming practice..
>
> I never use it.
>
>>Also desigining your program, along with the variable and
>>subroutine on paper..can help you also.
>
> I never do that. I'm not a Pascal programmer....
>
> One thing I can say: my programs grow like organic substances. Subs are
> neverfinished until the project is finished. I dare throw away ealrier
> stuff if later it turns out I took an inefficient way to achieve
> something. In general, my programs grow better.
>
> Now, designing something on paper before turning on the computer,
> prevents you to get in touch with the real thing. You DON'T KNOw what
> you're talking about, until you get hands on experience.
>
> Also, a design on paper stiffles evolution. If I were to design anything
> on paper before starting, I'm pretty sure I'd have thrown away that
> paper before the program is half finished.
On my business cards it say 'Analyst/Programmer' so you can pretty well
guess that I'm going to disagree with you about this ;-}
People tend to think that Rapid Application Development is mutually exclusive
with the 'old fashioned' practices of Analysis, Specification and Design:
I dont think that this is the case, indeed, where you have more than one
developer working on a project it becomes essential.
A clear specification that describes the inputs, outputs and constraints
upon a system might not be necessary where you are a single programmer
working in isolation and you can keep the whole thing in your head at once
but when a project grows beyond what you can sensibly keep in your head
or requires the input of more than one developer then these things will
need to be defined overtly in some way and should be defined before the
actual development begins.
The organic development of the *implementation* of any program is not
necessarily a bad thing, however the interfaces between the program and
its data sources and data sinks should be defined before the programming
begins especially when these things are beyond your control or might be
used by other systems. I will tend to design, for instance, the structure
of a database before I commit this to an actual system: where there might
be reason to change this in the future (and the fact of this change but
not its nature can be foreseen) I will design a set of interfaces to this
data that will survive a change in the implementation before I set finger
to keyboard. These virtues are something that to a certain extent we have
got from the Object Oriented methodologies and can be used whether we are
actually programming in an OO environment or not; Perl is fairly well
blessed in this respect in giving us the ability to use Encapsulation and
Abstraction (down zealots, down I am not suggesting that Perl is near
approaching a complete OO language) and to use those Encapsulated and
Abstracted objects in a procedural manner.
When developing large scale systems you do need to know what you are making
before you begin to make it. I would be really suspicious of a house builder
who came along to build me a house without any plans, without any clear idea
of what resources were to be required and how long it would take. Making
computer programs is no different to other crafts in this respect whatever
people might want to think. In drawing up the specification and design
for a project you are setting forth the costs and resource requirements:
any client who is happy to remain ignorant of these things probably
deserves everything that they get, however I would consider a matter of
professional responsibility to provide this information.
Then we get to the matter of certification under such as ISO 9000 :
documentation will be required, of the development process itself, the
procedures that govern the requisition and specification of software, and
the controls that pertain to change an maintenance of the software. This
is intractable if you wish to work for an organization that holds or
wishes to hold such certification and increasingly businesses do wish to
go in this direction for many very good reasons and eventually it is
likely that all professional developers will find themselves working in
somesuch environment.
The growth of the 'web as a major application area has given rise to the
Cottage Industry approach against the overall trends within the computer
industry as a whole but even this is coming to an end : it might be fine
for the occasional CGI program but I very much doubt that a large
'e-commerce' project for instance will progress without the appropriate
documentation.
/J\
--
First you don't want me to get the pony, then you want me to take it
back. Make up your mind.
--
fortune oscar homer
------------------------------
Date: 22 Apr 2000 14:02:55 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Good Techniques and Practices
Message-Id: <8ds7tv$m8m$1@orpheus.gellyfish.com>
On Fri, 21 Apr 2000 10:02:27 -0700 Gabe wrote:
>
> Can someone point me to information about good perl programming techniques
> and practices?
>
In the end of the day it is not so much about good Perl programming
techniques but what is generally considered to be good programming
practice. There are quite a few books about the practice of programming
on the whole and you might find that this will be discussed in some
group such as comp.programming.misc.
In general where a programming language supports the restriction of the
scope of data then that should be done where appropriate.
/J\
--
Friendship is far more tragic than love. It lasts longer.
--
fortune oscar homer
------------------------------
Date: 22 Apr 2000 12:40:33 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to detect when a connection is dropped with Perl
Message-Id: <8ds33h$m3e$1@orpheus.gellyfish.com>
On Sat, 22 Apr 2000 16:45:14 +0800 I'm a good man wrote:
> How to detect when a connection is dropped with Perl? Thanks a lot.
Er. What kind of connection ?
/J\
--
Whenever Marge turns on one of her non-violent programs, I take a walk. I
go to a bar, I pound a few, then I stumble home in the mood for looooove.
--
fortune oscar homer
------------------------------
Date: 22 Apr 2000 14:44:12 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to pass parameter?
Message-Id: <8dsabc$mkk$1@orpheus.gellyfish.com>
On Sat, 22 Apr 2000 18:09:46 +0800 Username wrote:
> Dear all,
>
> how to pass parameters between files?
> say
>
> if i pass it by
>
> abc.cgi?aaa="hey"
>
> and i call it by $aaa , nothing would occur, why?
>
Thats right. What did you expect to happen ? It is the responsibility of
the program that uses the CGI to extract the variables from the query
as passed to it from the server. You might see the original CGI spec.
at <http://hoohoo.ncsa.uiuc.edu/cgi/>[1] for more details in the first
instance. Most sage programmers will use the module CGI.pm (which is part
of the Perl distribution) to do the hard work for them :
#!/usr/bin/perl -w
use strict;
use CGI qw(:standard);
print header,start_html;
for my $param (param())
{
print "$param = ",param($param),"<BR>\n";
}
print end_html;
[1] I cant remember the URL of the later putative version 2 spec.
/J\
--
Marge, I'm going to miss you so much. And it's not just the sex. It's
also the food preparation.
--
fortune oscar homer
------------------------------
Date: 22 Apr 2000 14:30:21 +0100
From: nobull@mail.com
To: anne.smith@lineone.net
Subject: Re: If Statement
Message-Id: <u94s8u1cwi.fsf@wcl-l.bham.ac.uk>
"Anne Smith" <anne.smith@lineone.net> writes:
> I am trying to validate a text field whether a user has entered any data or
> not.
>
> I am using the syntax if (FORM_DATA {'firstname'} eq "")
> print " Incorrect firstname";
Try using the syntax of Perl instead.
No, joking appart if you post sample code that is not what you are
actually using it makes life doubly difficult for people to help you
because we have to guess which of the mistakes in your code are the
real mistakes.
> I thought that the "" would mean that the user has entered no data, but the
> system is using this in the meaning that the user has entered some data.
Perl has a concept of undefined (undef) as distinct from a null
string. In some contexts this is used to represent no data. Since we
have no contextual information we can't judge if this is relevant
here.
> Does anyone know what the correct operator is for empty data.
Please define the term "empty data".
I think your question really is: How does some Perl library that I'm
not going to name return the fact that no value has been entered in a
field?
To compare something to an empty string use:
EXPR eq ""
To know if something is defined use:
defined(EXPR)
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 22 Apr 2000 08:55:06 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: If Statement
Message-Id: <MPG.136b6b30aceb3ca898a95a@nntp.hpl.hp.com>
In article <u94s8u1cwi.fsf@wcl-l.bham.ac.uk> on 22 Apr 2000 14:30:21
+0100, nobull@mail.com <nobull@mail.com> says...
> "Anne Smith" <anne.smith@lineone.net> writes:
> > I am trying to validate a text field whether a user has entered any data or
> > not.
...
> I think your question really is: How does some Perl library that I'm
> not going to name return the fact that no value has been entered in a
> field?
>
> To compare something to an empty string use:
>
> EXPR eq ""
>
> To know if something is defined use:
>
> defined(EXPR)
To clarify this for CGI.pm:
param 'foo'
returns undef if the field 'foo' does not exist in the form being
returned, the null string if the field exists but nothing has been
entered. The list returned by param() will include 'foo' in the second
case; i.e., all parameters whose names are returned by param() have
defined values.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 22 Apr 2000 10:25:43 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: If Statement
Message-Id: <3901E097.86504A3E@stomp.stomp.tokyo>
Anne Smith wrote:
> I am trying to validate a text field whether a
> user has entered any data or not.
> I am using the syntax if (FORM_DATA {'firstname'} eq "")
> print " Incorrect firstname";
> I thought that the "" would mean that the user has entered no data, but the
> system is using this in the meaning that the user has entered some data.
> Does anyone know what the correct operator is for empty data.
You have problem somewhere but it is not with
this syntax you are using unless cgi.pm has
a bug when using this syntax of yours. Perhaps
consider dumping cgi.pm and writing your own
read and parse routine to handle this correctly.
An examination of your form action syntax would
be of benefit to be sure you have not inadvertently
added a space or another 'invisible' character to
your text input. A test print of your input would
be prudent to discover what data are coming in.
Godzilla!
=========
A test script is below if you would like to
validate this. These are my printed results
after numerous tests, using this test code
following my printed results:
Without any user input:
No User Input
With "test user input" (no quote marks)
as my text box input:
test user input
Test code to validate my findings:
#!/usr/local/bin/perl
&Parse;
sub Parse
{ # Parse #
local (*in) = @_ if @_;
local ($i, $key, $val);
read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
@in = split(/&/,$in);
foreach $i (0 .. $#in)
{
$in[$i] =~ s/\+/ /g;
($key, $val) = split(/=/,$in[$i],2);
($val eq "") && next;
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$in{$key} .= $val;
}
return 1;
} # Parse #
print "Content-Type: text/html\n\n";
$test = $in{Test};
$user_input = $in{User_Input};
print
"<HTML><HEAD><TITLE>TEST USER INPUT</TITLE></HEAD><BODY>
<CENTER><HR><BR><U>TEST USER INPUT</U><P><P>
<FORM METHOD=\"POST\" ACTION=\"test.cgi\">
<INPUT TYPE=\"submit\" NAME=\"Button\" VALUE=\"Test User Input\">
<INPUT TYPE=\"hidden\" NAME=\"Test\" VALUE=\"test\">
<INPUT TYPE=\"text\" SIZE = \"20\" MAXLENGTH=\"20\"
NAME=\"User_Input\" VALUE=\"\">
</FORM></CENTER><P>";
if ($test)
{
if ($user_input eq "")
{ print "<P> No User Input <P>"; }
if ($user_input ne "")
{ print "<P> $user_input <P>"; }
}
print "</BODY></HTML>";
exit;
------------------------------
Date: 22 Apr 2000 11:24:59 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: local function question
Message-Id: <87ln26w1b8.fsf@shleppie.uh.edu>
>> On Sat, 22 Apr 2000 09:13:43 -0700,
>> Anonymous <nobody@newsfeeds.com> said:
> After reviewing this thread and other threads, it
> appears PG knows more about Perl than her detractors
> trying to run her out of this newsgroup on a rail.
Then I'm sure you can post your evidence to back up this
assertion.
------------------------------
Date: Sat, 22 Apr 2000 19:45:23 +0400
From: "Quaid Joher" <yaqoota@emirates.net.ae>
Subject: Make Test Error in GD.pm
Message-Id: <8dshaj$r8k2@news.emirates.net.ae>
Thanks Jonathan,
With 'make test' I received following message;
bash-2.01$ make test
PERL_DL_NONLAZY=1
/usr/bin/perl -Iblib/arch -Iblib/lib -I/usr/local/lib/perl5/5.
00502/i386-freebsd -I/usr/local/lib/perl5/5.00502 -e 'use Test::Harness
qw(&runt
ests $verbose); $verbose=0; runtests @ARGV;' t/*.t
t/GD................Can't load './blib/arch/auto/GD/GD.so' for module GD:
Undefi
ned symbol "_SetCPerlObj" in perl:./blib/arch/auto/GD/GD.so at
/usr/local/lib/pe
rl5/5.00502/i386-freebsd/DynaLoader.pm line 168.
at t/GD.t line 11
BEGIN failed--compilation aborted at t/GD.t line 11.
dubious
Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 1-10
Failed 10/10 tests, 0.00% okay
Failed Test Status Wstat Total Fail Failed List of failed
----------------------------------------------------------------------------
---
t/GD.t 2 512 10 10 100.00% 1-10
Failed 1/1 test scripts, 0.00% okay. 10/10 subtests failed, 0.00% okay.
*** Error code 2
Stop.
Still lurking in the storm of unix error flood.
QUAID
----- Original Message -----
From: Jonathan Stowe <gellyfish@gellyfish.com>
Newsgroups: comp.lang.perl.misc
Sent: April 22, 2000 12:16
Subject: Re: Error in installing GD.pm
> On Sat, 22 Apr 2000 10:05:11 +0400 Quaid Joher wrote:
> > For the past two weeks I have been trying to properly install all the
> > graphics modules, libraries and programs and I have followed the
following
> > procedure. I am installing these in my home directory.
> >
> > 1. Installed zlib
> > 2. Installed libpng
> > 3. Installed GD-1.8.1
> > 4. Installing GD-1.27 (GD.pm)
> >
> > Following message I received on command "perl Makefile.PL
> > LIB=/usr/www/home/lib" (where home is my home);
> >
> > Checking if your kit is complete...
> > Looks good
> > Note (probably harmless): No library found for -lttf
> > Note (probably harmless): No library found for -ljpeg
> > Writing Makefile for GD
> >
> > Following message I received on the next command "make"
> >
> >
cc -c -I/usr/www/home/include -I/usr/local/include/gd -I/usr/local/include -
> > O
>
> -DVERSION=\"1.27\" -DXS_VERSION=\"1.27\" -DPIC -fpic -I/usr/local/lib/
pe
> > rl5/
> > 5.00502/i386-freebsd/CORE GD.c
> > GD.xs: In function `XS_GD__Image_newFromXpm':
> > GD.xs:357: warning: assignment makes pointer from integer without a cast
>
>
> I assume you mean this. It is not an 'error' it is simply warning that
you
> have some ambiguous useage in the file being compiled. 'gcc' will do that
> other compilers might not. Its not a problem you should be worried as if
> it *was* a problem then _no-one_ would have a working GD ;-}
>
> You appear to have a different version of GD from me so I cant point in
> you in the direction of the line of code that has given rise to this
> problem.
>
> > Running Mkbootstrap for GD ()
> > chmod 644 GD.bs
> > LD_RUN_PATH="/usr/www/home/lib:/usr/lib" ld -o
> > lib/arch/auto/GD/GD.so -Bshare
> > able -L/usr/local/lib GD.o -L/usr/www/home/lib -lgd -lpng -lz -lm
> > chmod 755 blib/arch/auto/GD/GD.so
> > cp GD.bs blib/arch/auto/GD/GD.bs
> > chmod 644 blib/arch/auto/GD/GD.bs
> > Manifying blib/man3/GD.3
> > (I have typed here 'home' where my site resides for security)
> >
> > Can some one guide me where I have made the mistake (if any) or what
step
> > that I may have missed out. My thanks to Tom Phoenix to guide me in the
> > early stages.
> >
>
> If you now run 'make test' I am sure that you will find that it passes.
> The rest of the compilation and linking seems to passed without problem.
>
> --
> Forty seconds? But I want it now!
> --
> fortune oscar homer
------------------------------
Date: Sat, 22 Apr 2000 17:05:01 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Make Test Error in GD.pm
Message-Id: <B5275438.2CBF%elaine@chaos.wustl.edu>
in article 8dshaj$r8k2@news.emirates.net.ae, Quaid Joher at
yaqoota@emirates.net.ae quoth:
> With 'make test' I received following message;
>
> bash-2.01$ make test
> PERL_DL_NONLAZY=1
> /usr/bin/perl -Iblib/arch -Iblib/lib -I/usr/local/lib/perl5/5.
> 00502/i386-freebsd -I/usr/local/lib/perl5/5.00502 -e 'use Test::Harness
> qw(&runt
I don't use freebsd but the error message looks a lot like the one I see on
Solaris. Lincoln has provided a patch script with the distribution that you
will need to apply to a fresh source copy of GD [not the module, the lib]
then build and install it...then rebuild GD the module.
Try that and let us know if that doesn't work.
e.
------------------------------
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 2842
**************************************