[16278] in Perl-Users-Digest
Perl-Users Digest, Issue: 3690 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 17 06:10:40 2000
Date: Mon, 17 Jul 2000 03:10:15 -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: <963828615-v9-i3690@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 17 Jul 2000 Volume: 9 Number: 3690
Today's topics:
Re: Net::Smtp problems <gellyfish@gellyfish.com>
Opinions wanted on an idea for a new module - CGISessio <zigouras@mail.med.upenn.edu>
Re: Opinions wanted on an idea for a new module - CGISe (Randal L. Schwartz)
Re: Opinions wanted on an idea for a new module - CGISe <zigouras@mail.med.upenn.edu>
Re: padding strings with zero's <aqumsieh@hyperchip.com>
Re: Perl Expert? I need help! <gellyfish@gellyfish.com>
Posting bug reports = mail spam?? <ralawrence@my-deja.com>
Re: Prepared statement SQL <gellyfish@gellyfish.com>
Re: programming tools and techniques <alanc@alum.calberkeley.org>
Quiz scripts <geoff@solomons.org>
Read a file into a hash ? (Fidelio)
Re: string to number? <bart.lateur@skynet.be>
Re: string to number? <w14357@email.mot.com>
Re: Upper-to-lower case problem <iltzu@sci.invalid>
Re: using perl to automate multiform submission (Shao Zhang)
Re: using perl to automate multiform submission (jason)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 17 Jul 2000 09:09:41 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Net::Smtp problems
Message-Id: <8kuf05$b16$1@orpheus.gellyfish.com>
On Sun, 16 Jul 2000 12:20:14 -0700 deno wrote:
>
> js>>You really do need to check the success of the call to new
> js>>before you carry on and try to use $smtp. You also will want
> js>>to use the Debug mode of Net::SMTP to determine what it was
> js>>that went wrong.
>
>
> use Net::SMTP;
>
> $smtp = Net::SMTP->new('192.168.0.100', Timeout => 100);
> print "smtp is $smtp";
> print $smtp->banner,"\n";
> $smtp->quit;
>
>
> $smtp prints as "Net::SMTP=GLOB(0x1b3cd50"
>
Er yes that is right. I'm not sure what you are saying here, that is what
should be in the variable. If your messages are not being delivered
you should be using the Debug mode as I said before, you should also be
checking that $smtp is defined befoe you attempt to use it :
if ($smtp = Net:SMTP->new('192.168.0.100', Timeout => 100, Debug => 1))
{
print $smtp->banner,"\n";
}
else
{
print "SMTP failed to connect\n";
}
The chances are that a failure to connect is not a Perl problem at all but
something wong with your mail server or your network.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Mon, 17 Jul 2000 02:38:15 -0400
From: Nico Zigouras <zigouras@mail.med.upenn.edu>
Subject: Opinions wanted on an idea for a new module - CGISession.pm.
Message-Id: <Pine.OSF.4.21.0007170237110.5018-100000@mail.med.upenn.edu>
Hello:
I posted this in clpmodules but did not get many responses. I have
developed a new module that I would like to release on CPAN but I
would like to get some feedback first.
I am currently calling it CGISession.pm, but any suggestions would be
appreciated. Since it is a CGI-related module I may look in to releasing
it under the CGI tree.
So basically what problem it is trying to address is the statelessness of
CGI and HTTP that we have all had to deal with. mod_perl is a good
solution to getting around this, but many CGI programmers may not have
root access to install mod_perl. This is a module for those programmers -
it only relies on modules within the Perl 5 standard distribution.
Basically allows you to save and retrieve data between sessions and allows
for safety checking of expired sessions and invalid sessions. It is used
if you, say, validate a user on a first login page and then want to track
that user securely on subsequent CGI pages. You can add key value pairs
to the session as needed. After an amount of time it will expire and the
user will be sent an error page.
It works be storing a unique, random key in a hidden field and using that
key to access the data on the server. The data is tied to a DB_file for
fast retrieval.
This is how you would use it in the top of every one of your CGI scripts
that needs session management. It can be used in conjunction with CGI.pm
or not.
my $cgi = new CGI();
my $session = new CGISession($cgi->param('session'));
$session->put("name",$cgi->param('name'));
$session->put("id",123456);
$session->save;
# later...
$session->printFieldWithCGI( $cgi );
That is it - all you need in each one of your session scripts. If there
is no current session (i.e. $cgi->param('session') is undef), a new
session and id will be created.
Some of the public methods:
set - takes a key,value pair and sets it into the session
get - returns value from the session for a given key
setDb - takes a hash ref and sets all kv pairs in session to this hr
getDb - gets hashref of kv pairs of session
killSession - kills this session so any subsequent tries will be denied
dump - dumps out key value pairs in ascii or html format
getKeys - gets all keys in session
getValues - gets all values
delete - deletes a kv pair from session
getField - gets the string of the hidden field
printField - prints the string of the hidden field
printFieldFromCGI - prints the hidden field via a CGI object
save - saves the chnages of the session
Comment are appreciated. Thank you.
Sincerely,
Nico Zigouras.
------------------------------
Date: 17 Jul 2000 00:53:15 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Opinions wanted on an idea for a new module - CGISession.pm.
Message-Id: <m1em4tchw4.fsf@halfdome.holdit.com>
>>>>> "Nico" == Nico Zigouras <zigouras@mail.med.upenn.edu> writes:
Nico> Hello:
Nico> I posted this in clpmodules but did not get many responses. I have
Nico> developed a new module that I would like to release on CPAN but I
Nico> would like to get some feedback first.
Nico> I am currently calling it CGISession.pm, but any suggestions would be
Nico> appreciated. Since it is a CGI-related module I may look in to releasing
Nico> it under the CGI tree.
And this is different from CGI::Application (just released) exactly how?
I don't mind four ways to do it, but do we really need a fifth? :)
--
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: Mon, 17 Jul 2000 04:04:08 -0400
From: Nico Zigouras <zigouras@mail.med.upenn.edu>
Subject: Re: Opinions wanted on an idea for a new module - CGISession.pm.
Message-Id: <Pine.OSF.4.21.0007170403020.8343-100000@mail.med.upenn.edu>
Yeah - more research has shown that there are similar modules out there -
CGI::Persistent to name one. I guess what mine has to offer is expiration
checking and security checking, but I do not think that is neccessary for
a whole other module. Oh well...
On 17 Jul 2000, Randal L. Schwartz wrote:
> Date: 17 Jul 2000 00:53:15 -0700
> From: Randal L. Schwartz <merlyn@stonehenge.com>
> To: Nico Zigouras <zigouras@mail.med.upenn.edu>
> Newsgroups: comp.lang.perl.misc
> Subject: Re: Opinions wanted on an idea for a new module - CGISession.pm.
>
> The following message is a courtesy copy of an article
> that has been posted to comp.lang.perl.misc as well.
>
> >>>>> "Nico" == Nico Zigouras <zigouras@mail.med.upenn.edu> writes:
>
> Nico> Hello:
> Nico> I posted this in clpmodules but did not get many responses. I have
> Nico> developed a new module that I would like to release on CPAN but I
> Nico> would like to get some feedback first.
>
> Nico> I am currently calling it CGISession.pm, but any suggestions would be
> Nico> appreciated. Since it is a CGI-related module I may look in to releasing
> Nico> it under the CGI tree.
>
> And this is different from CGI::Application (just released) exactly how?
>
> I don't mind four ways to do it, but do we really need a fifth? :)
>
> --
> 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: Mon, 17 Jul 2000 07:08:48 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: padding strings with zero's
Message-Id: <7avgy5i67x.fsf@merlin.hyperchip.com>
shearn666@my-deja.com writes:
> Can someone assist??
Well, you don't show us any code, so how can we help you?
But here's a stab in the dark:
printf "%08.2f", 5.36;
--Ala
------------------------------
Date: 17 Jul 2000 10:03:53 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl Expert? I need help!
Message-Id: <8kui5p$b55$1@orpheus.gellyfish.com>
On Fri, 14 Jul 2000 18:28:26 +0200 Bart Lateur wrote:
> Sylvain2k wrote:
>
>>I have a little problem. there it is:
>>
>>$a = "My name is Sylvain";
>>
>>I want to delete ALL spaces in this variable.
>>I only want the first 8 caracters of the result.
>
> First, delete stha spaces, e.g. using "tr///d". Then, using substr, get
> the first eight characters.
>
> print test("My name is Sylvain"), "\n";
>
> sub test {
> local $_ = shift;
> tr/ //d;
> if(int rand 2) {
> print STDERR "Route 1\n";
> substr($_, 8) = '';
> return $_;
> } else {
> print STDERR "Route 2\n";
> return substr $_, 0, 8;
> }
> }
>
Hmm Schroedingers subroutine ....
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Mon, 17 Jul 2000 08:44:29 GMT
From: Richard Lawrence <ralawrence@my-deja.com>
Subject: Posting bug reports = mail spam??
Message-Id: <8kuh1b$b3h$1@nnrp1.deja.com>
Hi,
After submitting a bug report to perl5-porters my work email address
was inundated with spam. After some searching I've come to the
conclusion that someone has been harvesting the email addresses of all
posts to the perl5-porters newsgroup.
Except that no-one has thought about munging any email addresses in the
messages. (A simple s/@/Z@Z/g probably would have sufficed)
Concequently as a result of my bug report I get on average 2 postings a
day which offer me instant money, pornography or viagra.
If I had known I was to be "rewarded" this way, I probably wouldn't
have bothered reporting the bug in the first place.
Before I start complaining to the perl5-porters, I'd like to know if
anyone else has had similar experiences? Or am I in the minority here?
Rich
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 17 Jul 2000 10:14:31 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Prepared statement SQL
Message-Id: <8kuipn$b5t$1@orpheus.gellyfish.com>
In comp.lang.perl.misc brainmuffin@excite.com wrote:
> I am using mySQL as the database server. I have a Perl script that
> uses a prepared statement with variable substitution...that is, it
> has ? is it. Is there anyway to see the SQL statement it executes WITH
> the variables substituted??
>
There is no way that you can retrieve this in your program, but if you
have the appropriate degree of logging you will be able to record the
executed statements.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 17 Jul 2000 05:04:25 GMT
From: Alan Coopersmith <alanc@alum.calberkeley.org>
Subject: Re: programming tools and techniques
Message-Id: <8ku44p$4l6$1@agate.berkeley.edu>
acunet3278@my-deja.com writes in comp.sys.sun.apps:
|I am taking a beginner C language course.
|Could you kindly share your experience with me?
|Where can information be found about the following topics:
|
|When, why and how to use a debugger?
|What is it used for?
Since you're asking in UNIX newsgroups, I have to assume you're using
a UNIX system. If so, try running "man gdb" and "man dbx".
|When, why and how to use a Make?
|What is it used for?
|What is a target?
|What is a makefile?
"man make"
--
________________________________________________________________________
Alan Coopersmith alanc@alum.calberkeley.org
http://soar.Berkeley.EDU/~alanc/ aka: Alan.Coopersmith@Sun.COM
Working for, but definitely not speaking for, Sun Microsystems, Inc.
------------------------------
Date: Mon, 17 Jul 2000 10:49:13 +0100
From: Geoffrey Solomon <geoff@solomons.org>
Subject: Quiz scripts
Message-Id: <B5989529.5666%geoff@solomons.org>
Hi. I am looking to find a quiz script on the internet that lets you offer
questions a screen at a time (rather than all on one page). Does anyone know
of one, please?
------------------------------
Date: 17 Jul 2000 11:58:48 +0200
From: rjn@pobox.com (Fidelio)
Subject: Read a file into a hash ?
Message-Id: <8kulco$8ak$1@xs4.xs4all.nl>
Hi,
I want to read a file into a hash. I now have code like:
open(PASSWD, '/etc/passwd');
while (<PASSWD>) {
($login, $passwd, $uid, $gid,
$gcos, $home, $shell) = split(/:/);
# do something
}
Now everytime I want to access a user's home dir for example I
have to read the file.
Suppose I read the file into an array like:
open(PASSWD, '/etc/passwd');
@users = <PASSWD>;
close (PASSWD);
foreach $lines(@users) {
chop($lines);
@line = split(/\:/,$lines);
# put users into %users ??
}
Then I can access all the fields with @user{'root'} and eg. the home
dir with $user{'root'}[5] right ?
I a lost how to do this. @user{$line[0]} = @line just doesn't work.
R
--
-=*=- | Don't be a coward - use your real email address
Rob J. Nauta | Fidelio's beurspagina: http://www.xs4all.nl/~rob/beurs.html
rjn@pobox.com | Personal URL: http://www.xs4all.nl/~rob/ ICQ: 5369291
-=*=- | The Adsenger message Forum: http://www.delphi.com/adsenger
------------------------------
Date: Mon, 17 Jul 2000 10:46:40 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: string to number?
Message-Id: <gth5ns8cdaandlts946qiho42c74r5errt@4ax.com>
Tony Curtis wrote:
>> And the string is begin with "null" that asicc code is "0x20".
It's not "ASICC" but "ASCII". Interesting typo, anyway.
>NUL has ASCII code 0. I'm not sure what you are asking
>here, if anything. SPACE has code 0x20 (32) but SPACE
>isn't a number or a numeral.
Hmmm... it sounds like he's looking for the ord() function.
--
Bart.
------------------------------
Date: Mon, 17 Jul 2000 17:12:13 +0800
From: "David Li" <w14357@email.mot.com>
Subject: Re: string to number?
Message-Id: <8kuifh$4tr$1@schbbs.mot.com>
Thank you, Tony!
Tony Curtis <tony_curtis32@yahoo.com> wrote in message
news:87lmz1lcmi.fsf@limey.hpcc.uh.edu...
> >> On Mon, 17 Jul 2000 09:34:43 +0800,
> >> "David Li" <w14357@email.mot.com> said:
>
> > Hi, Could you tell me what function in Perl can convert
> > a string to number?
>
> There isn't one, perl does it for you:
>
> $x = '123'; # numeral
> ++$x; # number
> print "$x\n"; ==> 124
>
> > And the string is begin with "null" that asicc code is "0x20".
>
> NUL has ASCII code 0. I'm not sure what you are asking
> here, if anything. SPACE has code 0x20 (32) but SPACE
> isn't a number or a numeral.
>
> hth t
> --
> "With $10,000, we'd be millionaires!"
> Homer Simpson
------------------------------
Date: 17 Jul 2000 07:45:26 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Upper-to-lower case problem
Message-Id: <963819621.4449@itz.pp.sci.fi>
In article <hjnumsoj1bcg4rkcfd4u3nl6fgrcrnp7dp@4ax.com>, Bart Lateur wrote:
>Taint check:
>
> $valid = 1; # assumed, for now
> if($input{'batch'} =~ /^([a-fA-F)$/) {
> $batch = lc $1;
> } else {
> &error("Not a valid batch");
> $valid = 0;
> }
I think you should've taint-checked that code too:
/^([a-fA-F)$/: unmatched [] in regexp at - line 2.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method." -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: 17 Jul 2000 16:20:52 +1000
From: shao@linux.cia.com.au (Shao Zhang)
Subject: Re: using perl to automate multiform submission
Message-Id: <3972a5c4@news>
In article <8ktufo$pvd$1@murdoch.acc.Virginia.EDU>, Matthew Zimmerman wrote:
> In article <3972709d@news>, Shao Zhang <shao@linux.cia.com.au> wrote:
> >Hi,
> > Does anyone know how to use perl to automate multipart form submissions?
> > For example, some site needs you to press a "I ACCEPT" button to enter
> > to the next form.
> >
> > In this case, how should I do this using perl to automate this?
>
> The LWP module may do what you need. Check out
>
> perldoc LWP
> perldoc lwpcook
Hi,
Actually, I have asked this question in the past. The two answers
that I got was either LWP or CGI.pm.
I am also on the LWP mailing list, and I have asked them the same
question before, but with no response...
shao.
--
____________________________________________________________________________
Shao Zhang - Running Debian 2.1 ___ _ _____
Department of Communications / __| |_ __ _ ___ |_ / |_ __ _ _ _ __ _
University of New South Wales \__ \ ' \/ _` / _ \ / /| ' \/ _` | ' \/ _` |
Sydney, Australia |___/_||_\__,_\___/ /___|_||_\__,_|_||_\__, |
Email: shao@cia.com.au |___/
_____________________________________________________________________________
------------------------------
Date: Mon, 17 Jul 2000 06:48:37 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: using perl to automate multiform submission
Message-Id: <MPG.13dd49939c1fb2ed9896d0@news>
Shao Zhang wrote ..
>In article <8ktufo$pvd$1@murdoch.acc.Virginia.EDU>, Matthew Zimmerman wrote:
>> In article <3972709d@news>, Shao Zhang <shao@linux.cia.com.au> wrote:
>> >Hi,
>> > Does anyone know how to use perl to automate multipart form submissions?
>> > For example, some site needs you to press a "I ACCEPT" button to enter
>> > to the next form.
>> >
>> > In this case, how should I do this using perl to automate this?
>>
>> The LWP module may do what you need. Check out
>>
>> perldoc LWP
>> perldoc lwpcook
>
>Hi,
> Actually, I have asked this question in the past. The two answers
> that I got was either LWP or CGI.pm.
>
> I am also on the LWP mailing list, and I have asked them the same
> question before, but with no response...
doesn't the example in the LWP documentation help ? .. it basically
shows you exactly how to submit a form via POST using LWP
perldoc LWP
--
jason -- elephant@squirrelgroup.com --
------------------------------
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 3690
**************************************