[18940] in Perl-Users-Digest
Perl-Users Digest, Issue: 1135 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 14 14:10:44 2001
Date: Thu, 14 Jun 2001 11:10: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: <992542212-v10-i1135@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 14 Jun 2001 Volume: 10 Number: 1135
Today's topics:
Re: Perl HTTP & SSL <mbudash@sonic.net>
Pod and Perl viscido@u.washington.edu
Re: Problems with Threads and Signal handlers <dan@tuatha.sidhe.org>
Re: Q: How to make a Perlscript Shareware? <camerond@mail.uca.edu>
Read a cookie then redirect ? <pmg@kroazhent.com>
Re: Read a cookie then redirect ? <info@rpv.de>
Re: Read a cookie then redirect ? <andras@mortgagestats.com>
Re: regular exp replacement question <mbudash@sonic.net>
sessionid or htaccess (ohulan)
Validating postcodes <wayne.marrison@consignia.com>
Re: Validating postcodes <keesh@users.sf.net>
Re: Validating postcodes (Anno Siegel)
Re: Validating postcodes <ren@tivoli.com>
Re: Which C compiler to use for modules? <newspost@coppit.org>
Re: Which C compiler to use for modules? <newspost@coppit.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 14 Jun 2001 08:39:43 -0700
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Perl HTTP & SSL
Message-Id: <mbudash-90C65A.08394314062001@news.pacbell.net>
In article <3b1f896e$1@rpc1284.daytonoh.ncr.com>, "Dennis Kowalski"
<dennis.kowalsk@daytonoh.ncr.com> wrote:
> I have a script that uses the LWP and HTTP modules to access a web server
> and drive in transactions for stress testing.
>
> I have tested it on my development server and it works fine.
> I get a login page and send in the id and password and then get other
> screens.
>
> My problem is that the actual test has to run against a production server
> using SSL.
>
> I need HTTPS capability.
>
> Is there anyway in Perl to handle pages from and to a secure site that is
> using SSL?
>
> Thanks
>
>
>
per README.SSL that comes with the lib-www (LWP) distro:
------------------------------------------------------------
SSL SUPPORT
-----------
The libwww-perl package has support for using SSL/TLSv1 with its HTTP
client and server classes. This support makes it possible to access
https schemed URLs with LWP. Because of the problematic status of
encryption software in general and certain encryption algorithms in
particular, in several countries, libwww-perl package doesn't include
SSL functionality out-of-the-box.
Encryption support is obtained through the use of Crypt::SSLeay or
IO::Socket::SSL, which can both be found from CPAN. At present, the
easiest and recommended module to use is Crypt::SSLeay. Crypt::SSLeay
provides "plug-and-play" SSL support for LWP while IO::Socket::SSL
requires patching LWP. In addition to bringing SSL support to the LWP
package, IO::Socket::SSL can be used as an object oriented interface
to SSL encrypted network sockets.
There is yet another SSL interface for perl called Net::SSLeay. It has
a more complete SSL interface and can be used for web client
programming among other things but doesn't directly support LWP.
The underlying SSL support in all of these modules is based on OpenSSL
<http://www.openssl.org/> (formerly SSLeay). For WWW-server side SSL
support (e.g. CGI/FCGI scripts) in Apache see <http://www.modssl.org/>.
------------------------------------------------------------
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: 14 Jun 2001 09:34:44 -0700
From: viscido@u.washington.edu
Subject: Pod and Perl
Message-Id: <m3k82f6mvv.fsf@fiddler.u.washington.edu>
Hi there. I'm a relatively new-ish perl programmer (only been using it
for a few months). I've written some code for other users, and I want
to make a sort of "online help" for them. That is, the program asks
for user input, and does something with whatever they type in. What I
would like is to build a command, say "help <item>", where my script
will show them a "help file" on the item. I could make a separate
"help.txt" file or even some sort of searchable DBM file, but then
every time I add a subroutine or module to the script, I have to go
into the help database and mess with it.
What I'd rather do, is have perl search through the list of
subroutines available to the script (via use, require, etc), and look
for help topics embedded within the subroutine. So, if I have
sub command {
=<some pod help text here>
<subroutine>
return whatever;
}
and someone types "help command", the script will know to look inside
the command subroutine for the pod documentation, and then display
that to the user.
Is there a relatively easy way to do that, such as a module? None of
the Pod::* modules appear to serve my purposes, but I thought perhaps
there was something I was missing.
Thanks,
Steven
--
Steven Viscido [viscido@u.washington.edu]
Department of Zoology, Box 351800 Kincaid Hall
University of Washington
Seattle, WA 98195 Tel: 206-221-6893
------------------------------
Date: Thu, 14 Jun 2001 16:07:21 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Problems with Threads and Signal handlers
Message-Id: <Zi5W6.83783$v5.6387502@news1.rdc1.ct.home.com>
Scott Rutherford <arbman@dhmail.net> wrote:
> Dan Sugalski wrote:
>>
>> Well, the best you can do is read the thread docs for the platforms
>> you're working on. Most Unices conform fully to the POSIX thread
>> standard at this point (assuming a recent version of them, of
>> course) and their docs normally mention where they don't. Non-unix
>> platforms might be a bit trickier, but for signals it's not a big
>> deal, as signals are a unix thing anyway.
>>
>> Dan
> Ok, I tried the Thread::Signal module but I didn't seem to get anywhere,
> but I figure that trying to combine forking, signals and threads is probably
> unnecessary and certainly painful. So I've opted for a fully threaded
> approach.
Mixing threads and fork is a bad idea. You hit all sorts of deadlock problems
that way.
> However whatever the situation I couldn't get Thread::Signal to work infact
> non of
> the scripts containing
> use Thread::Signal
> wouldn't even run!!!
What errors were you getting?
Dan
------------------------------
Date: Thu, 14 Jun 2001 10:46:20 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Q: How to make a Perlscript Shareware?
Message-Id: <3B28DC4C.984AA4A1@mail.uca.edu>
Philip Newton wrote:
>
> Trying to make software uncrackable is probably an exercise in futility.
Undoubtedly so. Even using the oft-suggested perl2exe won't help you if
the crackers are determined enough, so I hear.
That said, what I would recommend is the following:
Send out your code with a "do not function after xx/xx/xxxx" generated
when the program is downloaded and buried in a module somewhere. Then
when the user registers, send him/her the replacement module without the
die code. No, this will not in any way deter someone who is he**-bent to
crack it, but anyone with half a brain will realize that it is far more
cost-effective to pay for the fix (and get tech support/bug fixes, I
assume) rather than to spend an unpredictable amount of his/her time to
"save" a few bucks. This assumes, of course, that you are not going to
charge a ridiculous amount to register the program. And, yes, I have
paid authors for "pure Perl" programs because it's not worth my time to
cheat them (OK, I wouldn't do it anyway, but this serves to prod me to
stay honest).
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: Thu, 14 Jun 2001 19:04:31 +0200
From: "Pat Krz" <pmg@kroazhent.com>
Subject: Read a cookie then redirect ?
Message-Id: <9gaqr9$2t6$1@front5.grolier.fr>
I got some problems managing cookies with the CGI.PM module.
I have to read User's ID stored in a cookie, then send the user to
his private page/url.
Here's the problem ... I read some FAQ and posts dealing with
writing a cookie then redirect, but nothing about reading then redirect.
In fact, the problem seems to be that a read-cookie operation includes
sending a header( print $q->(cookie -name...)),the redirect function cannot
be used after that (?).
Some ideas ?
Regards.
Frederic.
------------------------------
Date: Thu, 14 Jun 2001 19:15:32 +0200
From: Michael =?ISO-8859-1?Q?D=F6ring?= <info@rpv.de>
Subject: Re: Read a cookie then redirect ?
Message-Id: <9garhc$csi$1@news.netcologne.de>
"Pat Krz" <pmg@kroazhent.com> schrieb:
>I got some problems managing cookies with the CGI.PM module.
>I have to read User's ID stored in a cookie, then send the user to
>his private page/url.
>
>Here's the problem ... I read some FAQ and posts dealing with
>writing a cookie then redirect, but nothing about reading then redirect.
>In fact, the problem seems to be that a read-cookie operation includes
>sending a header( print $q->(cookie -name...)),the redirect function
>cannot be used after that (?).
Use $ENV{HTTP_COOKIE} to read the cookie and
print "Status: 302 Found\nLocation: $location\n\n"
to redirect. Then you don't need CGI.pm :-)
--
MICHAEL DÖRING ..... Postfach 3143 ..... D-53831 Troisdorf
Tel: 02241/9781 -97 ... Fax: -96 ... Mobil: 0172 702 3 777
eMail: info@RPV.de .... ICQ: 12860386 .... web: www.RPV.de
DAS Newsletterprogramm für Ihre Homepage: www.RPV.de/demo/
------------------------------
Date: Thu, 14 Jun 2001 13:43:50 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Read a cookie then redirect ?
Message-Id: <3B28F7D6.CE148EA3@mortgagestats.com>
Pat Krz wrote:
> I got some problems managing cookies with the CGI.PM module.
> I have to read User's ID stored in a cookie, then send the user to
> his private page/url.
>
>
[snip]
> In fact, the problem seems to be that a read-cookie operation includes
> sending a header( print $q->(cookie -name...))
No, you don't have to print a header to read a cookie.
------------------------------
Date: Thu, 14 Jun 2001 09:29:38 -0700
From: Michael Budash <mbudash@sonic.net>
Subject: Re: regular exp replacement question
Message-Id: <mbudash-19B68F.09293814062001@news.pacbell.net>
In article <9fn66j$hnu$1@coco.singnet.com.sg>, "keng"
<keng@spinalfluid.com> wrote:
> dear all,
>
> suppose
> i have a $x = 123, "123,000,00", 124; taken from a csv file.
> how do i strip the double quotes and the commas in the double quotes
> and change it to 123, 12300000, 124
>
> pls help
> thanks in advance
> --
> regards
> keng
>
>
try this:
use Text::ParseWords;
$x = '123, "123,000,00", 124';
$newx = join (', ', map { $_ =~ s/,//g; $_; } quotewords(', ', 0, $x));
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: 14 Jun 2001 08:05:25 -0700
From: ohulan@gmx.net (ohulan)
Subject: sessionid or htaccess
Message-Id: <6feb7f1e.0106140705.6893d827@posting.google.com>
my problem: I have a member area (htaccess not in cgi-bin, because I
have
very much HTML documents in there). some cgis should be only allowed
to be called from this area. HTTP_REFERER is not what i want. can i
protect two directories with one htaccess-file. i don´t want that
members must log in in membersarea AND members cgi-bin. otherwise, a
session ID is the best solution.
how does it works? can I generate with php in the member area (cgis
run only in cgi-bin, or not?) a session id and insert it in the link
to script as an URL parameter (no cookies)? the script then examines
if this
is an correct id (it has not to be 100% safe). script has also
urlparamters. is that a problem?
i need source-code, because i´m a perl/cgi-newbie
------------------------------
Date: Thu, 14 Jun 2001 16:13:25 +0100
From: "Wayne Marrison" <wayne.marrison@consignia.com>
Subject: Validating postcodes
Message-Id: <992531792.602668@igateway.postoffice.co.uk>
Hi People....
I have a slight problem .....
I need to validate postcodes given to my program to ensure that they
correspond to the RoyalMail standard (UK).
I have the patterns required, i.e. "AN NAA","ANN NAA","AAN NAA","AANN
NAA","ANA NAA","AANA NAA","AAA NAA" (with or without the space) and need to
ensure that the code passed to my program conforms to one of the above
(A=Alpha, N=Numeric).
I have checked the FAQ's but cannot find anything that does the job. I have
also checked CPAN for a relevant module,but again, without much success.
As I'm no expert on REGEX, I was wondering if anyone knew the answer to this
little problem.
Thanks in advance
Wayne
------------------------------
Date: Thu, 14 Jun 2001 16:01:17 GMT
From: Ciaran McCreesh <keesh@users.sf.net>
Subject: Re: Validating postcodes
Message-Id: <hd5W6.11693$J25.1605957@news1.cableinet.net>
On Thursday 14 June 2001 4:13 pm, Wayne Marrison declared:
> I have the patterns required, i.e. "AN NAA","ANN NAA","AAN NAA","AANN
> NAA","ANA NAA","AANA NAA","AAA NAA" (with or without the space) and need
> to ensure that the code passed to my program conforms to one of the above
> (A=Alpha, N=Numeric).
First, a warning: You can use \d for a digit, no problem. For the RoyalMail
standard, you can't use \w because some versions of perl don't treat this
as [a-zA-Z] . I can't remember if officially lowercase is allowed, but I
assume it is.
The simplest way, horribly inefficient mind, would be to translate your A
to [a-zA-Z], your N to [0-9] and replace your space with \s* or * (space
star). Then you just stick them all together with | :
if ($postcode =~ /[a-zA-Z][0-9]\s*[0-9][a-zA-Z]{2}|[a-zA-Z][0-9]{2}\s*|
(etc etc)/) {
Since the first digit has to be [a-zA-Z] (AFAIK anyway) you can optimise
slightly by starting with that... There may be other patterns that I'm not
aware of...
> As I'm no expert on REGEX, I was wondering if anyone knew the answer to
> this little problem.
"Mastering Regular Expressions" by J. Friedl, published by O'Reilly :)
Doesn't have an exact answer, but after reading it you'll be able to work
one out :)
--
Ciaran McCreesh
mail: keesh at users dot sf dot net
web: http://www.opensourcepan.com
------------------------------
Date: 14 Jun 2001 16:48:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Validating postcodes
Message-Id: <9gapsn$rgg$1@mamenchi.zrz.TU-Berlin.DE>
According to Ciaran McCreesh <keesh@users.sf.net>:
> On Thursday 14 June 2001 4:13 pm, Wayne Marrison declared:
> > I have the patterns required, i.e. "AN NAA","ANN NAA","AAN NAA","AANN
> > NAA","ANA NAA","AANA NAA","AAA NAA" (with or without the space) and need
> > to ensure that the code passed to my program conforms to one of the above
> > (A=Alpha, N=Numeric).
>
> First, a warning: You can use \d for a digit, no problem. For the RoyalMail
> standard, you can't use \w because some versions of perl don't treat this
> as [a-zA-Z] . I can't remember if officially lowercase is allowed, but I
> assume it is.
>
> The simplest way, horribly inefficient mind, would be to translate your A
> to [a-zA-Z], your N to [0-9] and replace your space with \s* or * (space
> star). Then you just stick them all together with | :
>
> if ($postcode =~ /[a-zA-Z][0-9]\s*[0-9][a-zA-Z]{2}|[a-zA-Z][0-9]{2}\s*|
> (etc etc)/) {
>
> Since the first digit has to be [a-zA-Z] (AFAIK anyway) you can optimise
> slightly by starting with that... There may be other patterns that I'm not
> aware of...
>
> > As I'm no expert on REGEX, I was wondering if anyone knew the answer to
> > this little problem.
>
> "Mastering Regular Expressions" by J. Friedl, published by O'Reilly :)
> Doesn't have an exact answer, but after reading it you'll be able to work
> one out :)
Here is a way that doesn't use a regex. First build a hash of
admissible patterns:
my %patterns;
@patterns{ "AN NAA","ANN NAA","AAN NAA","AANN NAA",
"ANA NAA","AANA NAA","AAA NAA"} = ();
Now, if $_ contains the postal code in question, translate digits
to the letter 'N' and alphabetics to 'A' (leave everything else
alone):
tr/0-9A-Za-z/NNNNNNNNNNA/; # final A is effectively repeated
Now see if we got one of the patterns:
if ( exists $patterns{ $_} ) {
# it's fine
}
Anno
------------------------------
Date: 14 Jun 2001 10:54:01 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Validating postcodes
Message-Id: <m3ithzhxba.fsf@dhcp9-173.support.tivoli.com>
On Thu, 14 Jun 2001, wayne.marrison@consignia.com wrote:
> I need to validate postcodes given to my program to ensure that they
> correspond to the RoyalMail standard (UK).
>
> I have the patterns required, i.e. "AN NAA","ANN NAA","AAN
> NAA","AANN NAA","ANA NAA","AANA NAA","AAA NAA" (with or without the
> space) and need to ensure that the code passed to my program
> conforms to one of the above (A=Alpha, N=Numeric).
#!/usr/bin/perl
use strict;
use warnings;
my @postcodes = ("AN NAA","ANN NAA","AAN NAA","AANN NAA","ANA NAA",
"AANA NAA","AAA NAA");
my $pattern = join '|', map { s/A/[a-zA-Z]/g;
s/N/\\d/g;
s/ / ?/g;
$_ } @postcodes;
print "Pattern is $pattern\n";
my @strings = ("j44ak", "45234", "X55 5Zx", "apple", "one 4me");
for (@strings) {
print /^($pattern)$/ ? "$_ matches\n" : "$_ doesn't match\n";
}
__END__
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Thu, 14 Jun 2001 11:23:30 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Which C compiler to use for modules?
Message-Id: <Pine.SUN.4.33.0106141120370.20271-100000@mamba.cs.Virginia.EDU>
On 13 Jun 2001, isterin wrote:
> On Windows you should have ActiveState and install binary packages
> through ppm utility that comes with it. If you ever need to compile a
> module that is not available through activestate binaries, you must
> use VC++, because this is what ActiveState perl is compiled with. You
> must compile all packages with the same compiler that you perl was
> compiled with.
For the record, I've installed 5-10 binary modules with ppm, and have
yet to find one where I needed a compiler because no version was
available through ppm. I would bet that you could lobby the module
author to release a ppm bundle, considering how that will expand the
easy application of their module on Win32 systems.
David
------------------------------
Date: Thu, 14 Jun 2001 11:46:26 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Which C compiler to use for modules?
Message-Id: <Pine.SUN.4.33.0106141123330.20271-100000@mamba.cs.Virginia.EDU>
On Wed, 13 Jun 2001, Godzilla! wrote:
> Loading is successful but fails upon calling another module from
> within, which is not DOS eight character.
Really? I've never had this problem on Windows 95/98/NT. What version
are you on? I've never had to worry about 8.3 file format.
> I am rather surprised and annoyed modules are being
> written which are not "stand alone" and require
> other modules to be installed, without this being
> noted in a module's documentation. This is very
> stupid programming and even more stupid documentation.
Stupid documentation, yes. Stupid programming, no. I would *much*
rather use a module that has a history of being correct than try to
write it myself and get a fast but incorrect answer. I'm sure you
would use the Date::Manip module to correctly do date arithmetic even
though it's slow, right? You'd hate to have to reimplement
Date::Manip, right? You exploit the benefits of reuse when you use a
module, and there's no reason why a module author shouldn't do the
same.
> Inherently, I will add this to my long list of complaints
> about modules; those which call other modules run even
> slower and are greater memory hogs than I previously knew.
I'd rather spend $50 and get a faster processor or memory than spend
10 hours reimplementing a module to be both correct and faster.
(Figure 10 hours * $20/hr = $200). It's hard enough getting the
software right--I'd rather leave the speed to those that have solved
that problem (hardware guys).
On the other hand, maybe you can have your cake and eat it too. If a
module uses another module which is particularly slow, perhaps there
is an alternative that you can suggest to the module author. For
example, if the module uses Date::Manip, suggest the faster but less
featureful Date::Calc. Also, they may be able to design their module
to get the benefits of both. That's what I do with grepmail
(Date::Calc by default, Date::Manip when you need it). Or perhaps they
could use some tricks to speed things up: Mark Overmeer uses on-demand
parsing of emails in his Mail::Box module.
> Any suggestions for a C compiler which is factually known to
> successfully compile modules?
I believe there has been some success in using the free GNU compilers.
Check out Cygwin. However, I tend to think that if you ask the module
author nicely, they'll compile it and release a ppm package.
David
------------------------------
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.
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 V10 Issue 1135
***************************************