[19222] in Perl-Users-Digest
Perl-Users Digest, Issue: 1417 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 31 14:05:44 2001
Date: Tue, 31 Jul 2001 11:05:09 -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: <996602709-v10-i1417@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 31 Jul 2001 Volume: 10 Number: 1417
Today's topics:
Re: Accessing https URLs <mbudash@sonic.net>
Re: Accessing https URLs <godzilla@stomp.stomp.tokyo>
Re: Accessing https URLs <michael.vonk@nrl.navy.mil>
Re: BUG in Perl when using setpgrp... <chris-usenet@retardix.com>
Re: calling a perl script from perl (M)
Re: calling a perl script from perl <ilya@martynov.org>
Re: Finding "this" but not "this and that" with a regex <tsee@gmx.net>
Re: Finding All Combinations <chris.wallaceREMOVE_ME@lshtm.ac.uk>
Re: Finding All Combinations <caughran@chem.uga.edu>
Re: Help on Array ? ctcgag@hotmail.com
Installing DBD extensions to Perl (Steve Wales)
Re: Is a function/class library for processing of SMTP- lvirden@yahoo.com
Perl OO Help needed (again) <a@b.c>
Re: perl, pgp & file system issue <mbudash@sonic.net>
perlbug: blacklisted as a spam haven (John Kristian)
Re: perlbug: blacklisted as a spam haven <dan@tuatha.sidhe.org>
Re: Problems with with Perl, Cgi using the Dbi module <mbudash@sonic.net>
RegExp (Gerfried Ranner)
Strange problem... <nathan.randle@ntlworld.com>
Re: Strange problem... <ilya@martynov.org>
Re: Strange problem... <nathan.randle@ntlworld.com>
Re: Strange problem... <jeff@vpservices.com>
Re: Strange problem... <ilya@martynov.org>
why won't the cgi work <danield@life.uiuc.edu>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 31 Jul 2001 15:31:12 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Accessing https URLs
Message-Id: <mbudash-CEC457.08311631072001@news.sonic.net>
In article <3B66C30C.8D4ADF7@nrl.navy.mil>, "Michael G. Vonk"
<michael.vonk@nrl.navy.mil> wrote:
> Hello,
>
> I am using Active Perl 5.6 Build 623 on Windows NT 4.0
> and am trying to get the contents of a URL using https. I see
> in the lwpcook documentation that an SSL interface for LWP
> must be installed. But I do not see any README.SSL
> file that tells how to do this. Can someone tell me what I
> need to do?
here's the contents of README.SSL. it's not hard to do assuming you have
some kind of admin access to the server in question. everything you need
is out there, either at cpan or openssl.org. good luck!
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: Tue, 31 Jul 2001 08:43:47 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Accessing https URLs
Message-Id: <3B66D233.AABD1D64@stomp.stomp.tokyo>
Michael G. Vonk wrote:
(snipped)
> I am using Active Perl 5.6 Build 623 on Windows NT 4.0
> and am trying to get the contents of a URL using https. I see
> in the lwpcook documentation that an SSL interface for LWP
> must be installed. But I do not see any README.SSL
> file that tells how to do this. Can someone tell me what I
> need to do?
Research and read about:
IO::Socket::SSL
Net::SSLeay
Crypt::SSLeay
Godzilla!
------------------------------
Date: Tue, 31 Jul 2001 13:21:40 -0400
From: "Michael G. Vonk" <michael.vonk@nrl.navy.mil>
To: Michael Budash <mbudash@sonic.net>
Subject: Re: Accessing https URLs
Message-Id: <3B66E924.61EDF7C4@nrl.navy.mil>
Thanks. That is exactly what I was looking for. I
tried Crypt::SSLeay and it worked great.
Michael Budash wrote:
> In article <3B66C30C.8D4ADF7@nrl.navy.mil>, "Michael G. Vonk"
> <michael.vonk@nrl.navy.mil> wrote:
>
> > Hello,
> >
> > I am using Active Perl 5.6 Build 623 on Windows NT 4.0
> > and am trying to get the contents of a URL using https. I see
> > in the lwpcook documentation that an SSL interface for LWP
> > must be installed. But I do not see any README.SSL
> > file that tells how to do this. Can someone tell me what I
> > need to do?
>
> here's the contents of README.SSL. it's not hard to do assuming you have
> some kind of admin access to the server in question. everything you need
> is out there, either at cpan or openssl.org. good luck!
>
> 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: Tue, 31 Jul 2001 17:15:16 GMT
From: "Christopher Masto" <chris-usenet@retardix.com>
Subject: Re: BUG in Perl when using setpgrp...
Message-Id: <EIB97.53483$UH6.9114344@news02.optonline.net>
In article <3B64AEC0.80307@computer.org>, "Jason Boerner"
<jasonb@computer.org> wrote:
> Reading the camel book, "This function returns the current process group
> for the specified PID (use a PID of 0 for the current process)."
You have confused "process group" with "GID". Look at $) in perlvar.
I don't think you want that either, though. Based on your "expected
output", you have probably misunderstood something about Unix semantics.
Unless it's a Linux weirdism, you don't have an "active group", nor is
there any reason to change it.
------------------------------
Date: Tue, 31 Jul 2001 16:26:05 GMT
From: lithotroph@hotmail.com (M)
Subject: Re: calling a perl script from perl
Message-Id: <90EFBEA08pr5j8k@24.132.65.8>
ilya@martynov.org (Ilya Martynov) wrote on Mon, 30 Jul 2001
11:59:55 GMT:
>M> A probably stupid question: Can someone inform me on how to
>call a M> perl script from a current perl script while terminating
>the later M> (removing it from the stack) at the same time?
>
>exec("myscript.pl")
>
>Read 'perldoc -tf exec' for more info.
Forgot to mention that I was looking for a solution in the context
of an (apache) server.
Sorry.
(The idea is simply to uniformly call an index-script from a html
<form> with a single index-number, which then redirects the request
to the appropriate html page or script adding parameters etc.)
------------------------------
Date: 31 Jul 2001 20:36:16 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: calling a perl script from perl
Message-Id: <87r8uxqcn3.fsf@abra.ru>
M> Forgot to mention that I was looking for a solution in the context
M> of an (apache) server.
M> Sorry.
M> (The idea is simply to uniformly call an index-script from a html
M> <form> with a single index-number, which then redirects the request
M> to the appropriate html page or script adding parameters etc.)
I'm not sure that I correctly understand your requirements but if you
need to pass control to another CGI script you can always use external
redirect on this script.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Tue, 31 Jul 2001 18:23:21 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Finding "this" but not "this and that" with a regex?
Message-Id: <9k6lpu$oi8$06$1@news.t-online.com>
"Jay McGavren" <sgarfunkle@hotmail.com> schrieb im Newsbeitrag
news:6bb557e1.0107302114.696bc739@posting.google.com...
[snip]
make it:
#untested, sorry. Should work though.
> sub CanYouIgnore {
> $Record = shift;
my @notIgnorePhrases = ('and that');
> @IgnorePhrases = ("other thing", "this");
>
> $Ignore = 0;
my $ignorePhrase;
foreach $ignorePhrase (@IgnorePhrases) {
my $notIgnorePhrase;
foreach $notIgnorePhrase (@notIgnorePhrases) {
$Ignore = 1 if ( $Record =~ /$ignorePhrase/m && !($Record =~
/$notIgnorePhrase/m) );
}
}
> print "$Record\n" unless $Ignore;
> }
Now, the $Ignore var is only set to one if the ignorePhrase is found *and*
the notIgnorePhrase is not found. You could also set the list of Phrases to
exclude from the ignoration to 'this and that' instead. But that would not
let your example pass as you have data between 'this' and 'and that'.
Hope this works&helps.
Regards,
Steffen Müller
------------------------------
Date: Tue, 31 Jul 2001 16:53:30 +0100
From: chris wallace <chris.wallaceREMOVE_ME@lshtm.ac.uk>
Subject: Re: Finding All Combinations
Message-Id: <3B66D47A.9FD02920@lshtm.ac.uk>
Joel Caughran wrote:
>
> I working on a problem where I need to find all of the combinations of n
> out of a set of m items. I've got two systems that I can use but
> neither works well. I'm hoping someone has an alternative.
> I have read about closure functions and have built a couple of simple
> iterators. It seems that it should be possible to build a closure
> function that managed a stream of combinations. So far I can't get a
> recursive closure function to work.
Joel,
I know nothing about closure functions, but the combinations part is something
I looked at recently. Abigail presented a very elegant solution in the thread
http://groups.google.com/groups?hl=en&safe=off&th=1989885be0f66e05,16&start=0
and there's a slightly easier to understand solution by Kevin Campbell.
The both list all possible combinations though, so you may have to fiddle to
get things to fit your requirements.
Hth, Chris.
------------------------------
Date: Tue, 31 Jul 2001 13:04:36 -0400
From: Joel Caughran <caughran@chem.uga.edu>
Subject: Re: Finding All Combinations
Message-Id: <3B66E524.7DFDCB81@chem.uga.edu>
Chris,
Thanks for the pointer. From that I managed to locate a module called
List:Combinations by Clark Cooper. It does exactly what I need.
Joel
--
Joel A Caughran caughran@chem.uga.edu
Chemistry Learning Center caughran@uga.edu
Department of Chemistry
University of Georgia (706) 542-1906 voice
Athens, Georgia 30602-2556 (706) 542-9454 fax
chris wallace wrote:
>
> Joel Caughran wrote:
> >
> > I working on a problem where I need to find all of the combinations of n
> > out of a set of m items. I've got two systems that I can use but
> > neither works well. I'm hoping someone has an alternative.
>
> > I have read about closure functions and have built a couple of simple
> > iterators. It seems that it should be possible to build a closure
> > function that managed a stream of combinations. So far I can't get a
> > recursive closure function to work.
>
> Joel,
>
> I know nothing about closure functions, but the combinations part is something
> I looked at recently. Abigail presented a very elegant solution in the thread
> http://groups.google.com/groups?hl=en&safe=off&th=1989885be0f66e05,16&start=0
> and there's a slightly easier to understand solution by Kevin Campbell.
>
> The both list all possible combinations though, so you may have to fiddle to
> get things to fit your requirements.
>
> Hth, Chris.
------------------------------
Date: 31 Jul 2001 15:08:55 GMT
From: ctcgag@hotmail.com
Subject: Re: Help on Array ?
Message-Id: <20010731110855.753$7h@newsreader.com>
tvn007@hotmail.com (Tim) wrote:
> Hi,
>
> Could someone please help me on this ?
>
> Below is my script:
>
> @in1=(10); #Please DO NOT MODIFY the ARRAY
Array? What array? Oh, you mean the array with only one
element in it that might as well be a scalar. Why create
an array if you aren't going to use it's arrayness?
> $"="";
> for ($i=0;$i<=2;$i++){
Where'd the 2 come from?
>
> print "@in1[$i] @in2[$i]\n";
Why are you using array slices which refer to only one element?
> }
>
> THe ouput of the script above is:
>
> 10 AB
If you use warnings, you'll also see that the output contains bitches
about many things in your script.
>
> However, I would like the output to be
>
> 1 A
> 0 B
>
> Any help would be greatly appriciate !!
print "1 A\n0 B\n";
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service
------------------------------
Date: 31 Jul 2001 10:59:46 -0700
From: Steve.Wales@tequinox.com (Steve Wales)
Subject: Installing DBD extensions to Perl
Message-Id: <8af3ba21.0107310959.3e32836b@posting.google.com>
A client of mine is trying to install DBD into Perl5.005. They ran the
Makefile.PL script to create the makefile
When he runs make he gets:
"Make: Must be a separator on rules line 2219. Stop."
Anyone able to tell me what might cause that? Line 2219 of the
makefile is blank, I believe. The line above it reads:
echo $(LIBEXTP)
Unfortunately, I know little about Makefiles - any help would be
appreciated.
It's on a HP-UX 11.00 box, for Oracle 8.1.6 (DBI extension has already
been built).
A copy of the reply in email would be appreciated, if possible (so I
can forward to the client - I don't have root access to his box).
Thanks,
Steve
------------------------------
Date: 31 Jul 2001 17:04:07 GMT
From: lvirden@yahoo.com
Subject: Re: Is a function/class library for processing of SMTP-mails available?
Message-Id: <9k6oe7$bsm$4@srv38.cas.org>
According to Markus Elfring <elf@messer.de>:
:I have found a useful module
:(http://search.cpan.org/search?module=Mail::Audit,
:http://simon-cozens.org/writings/mail-audit.html) for Perl now.
:Does anybody know a similar library for other programming languages?
Do you mean "does anyone know of libraries like CPAN for other languages"
or do you mean "does anyone know of functional equivalents in all
the various languages for the specific function Mail::Audit ?
--
--
"See, he's not just anyone ... he's my son." Mark Schultz
<URL: mailto:lvirden@cas.org> <URL: http://www.purl.org/NET/lvirden/>
Even if explicitly stated to the contrary, nothing in this posting
------------------------------
Date: Tue, 31 Jul 2001 10:30:50 -0700
From: BCC <a@b.c>
Subject: Perl OO Help needed (again)
Message-Id: <3B66EB4A.F4111775@b.c>
I am working on converting some existing code into a more OO format, and
am having troubles. This is the error that shows in my Apache log file
(I am running this under mod_perl):
[Tue Jul 31 10:20:26 2001] null: Attempt to free unreferenced scalar at
/usr/lib/perl5/site_perl/5.6.1/i686-linux/Apache/Registry.pm line 144.
And this is the message that appears in the browser (courtesy of Carp):
Software error:
Can't call method "unescape" on an undefined value at
/usr/lib/perl5/5.6.1/CGI.pm line 112.
I am simply trying to call a method via an object reference. I have had
a lot of help and great advice up to this point, and from all I
understand, this should work just fine. What am I still missing??
Here are the files:
CgiMOD.pm
---------
package CgiMOD;
use 5.006;
use strict;
use warnings;
use Global;
use CGI qw(:standard);
use CGI::Cookie;
our $VERSION = '0.01';
sub new {
my $proto=shift;
my $class=ref($proto) || $proto;
my $self = {string=>shift || ""}; # create a reference
return bless $self, $class; # make it part of this class
}
sub Read_Cookie {
my $self = shift;
my %cookies = CGI::Cookie->fetch;
my ($login,$level) = @{$cookies{Sequenom}{value}}[0,1]; #array slice
return ($login && $level) ? ($login,$level) : ("","");
}
Here's the CGI that calls Read_Cookie
test.cgi
--------
#!/usr/bin/perl -w
use CgiMOD;
use CGI qw(:standard);
my $cmod = new CgiMOD;
my $q = new CGI;
print $q->header();
print "test";
my ($log, $lev) = $cmod->Read_Cookie();
------------------------------
Date: Tue, 31 Jul 2001 15:27:27 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: perl, pgp & file system issue
Message-Id: <mbudash-6339DC.08273131072001@news.sonic.net>
In article <c36b2f02.0107310648.36e48e2d@posting.google.com>,
taviny@hotmail.com (Blixa Bargeld) wrote:
> Hi. Here's my dilemma - I have a perl script which accepts some form
> data which I'd like to encrypt & transmit in an email message. The
> thing is, I never want this data written to the file system - I'd like
> the encryption & data manipulation to be done solely in memory. I get
> the impression that the pgp modules for perl use temp files to assist
> in encryption. Does anyone know how this could be done? Thanks
read up on perl's open2 (or even open3). here's a snippet i've used in
several places for just this kind of thing. it's based on pgp 5.x for
irix. it is NOT a complete script, and you'll undoubtedly need to change
it in some way, but it's definitely a start. 'recipient@domain.com' is
the name of the key used to encrypt:
# We need a library function
use IPC::Open2; # part of the standard perl lib
# Set up the pgp command
$pgpcmd = '/server/path/to/pgpe -at -r recipient@domain.com';
# Open the PGP program for bidirectional I/O
open2(\*READPGP, \*WRITEPGP, $pgpcmd) or die("oops!");
# Send text to be encrypted to PGP
print WRITEPGP $unencrypted;
# Encrypt the data
close(WRITEPGP);
# Get the encrypted data from PGP
@encrypted = <READPGP>;
$encrypted = join ('', @encrypted);
close(READPGP);
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: 31 Jul 2001 09:27:31 -0700
From: jmk2001@engineer.com (John Kristian)
Subject: perlbug: blacklisted as a spam haven
Message-Id: <b6ae18db.0107310827.5ff3ba59@posting.google.com>
I can't contribute a bugfix via perlbug. My email bounces thus:
Your message cannot be delivered to the following recipients:
Recipient address: perlbug@perl.com
Reason: Server rejected MAIL FROM address.
Diagnostic code: smtp;553 5.3.0 Your site is blacklisted as a spam
haven.
Remote system: dns;mail.perl.com
(TCP|64.164.98.8|41249|199.45.135.9|25) (chthon.perl.com ESMTP
Sendmail 8.11.4/8.10.0; Tue, 31 Jul 2001 10:09:34 -0600 [MDT])
I tried last night and this morning, with several 'From' email
addresses, including one address @my former employer (which shouldn't
appear in any sensible list of spam havens).
Help? Is perl.com broken (and expected to be rectified soon)?
Should I do something else?
------------------------------
Date: Tue, 31 Jul 2001 16:39:01 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: perlbug: blacklisted as a spam haven
Message-Id: <FaB97.200695$v5.20005514@news1.rdc1.ct.home.com>
John Kristian <jmk2001@engineer.com> wrote:
> I can't contribute a bugfix via perlbug. My email bounces thus:
Try sending the bug report to perlbug@perl.org.
On the other hand, the perlbug script has known about the
change of destination for a number of versions--it's distinctly
possible that whatever bug you're reporting has been fixed in
a newer version of perl.
Dan
------------------------------
Date: Tue, 31 Jul 2001 16:28:15 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Problems with with Perl, Cgi using the Dbi module
Message-Id: <mbudash-D81E9B.09282031072001@news.sonic.net>
In article <f946d81f.0107310115.dc5c264@posting.google.com>,
KMindermann@gmx.de (Karen Mindermann) wrote:
> $statement=('INSERT INTO Ill_new ($columns) values ($value)');
offhand, i'd say try:
$statement="INSERT INTO Ill_new ($columns) values ($value)";
as a side note, you might want to look into the concept of
'placeholders' so you don't have to deal with quoting here:
> $value="('$Vorname','$Name','$Long_Titel','$Buchjahr','$Autor_Hrsgb',
> '$Ort','$Verlag','$Seiten','$Aufsatzverfasser','$Long_Aufsatz',
> '$Kommentar','$EMail_Adresse')";
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: 31 Jul 2001 10:14:28 -0700
From: ranner@gmx.net (Gerfried Ranner)
Subject: RegExp
Message-Id: <a6150edd.0107310914.3d4474c@posting.google.com>
Dear NG!
I am a VB programmer using some RegExp's.
As you are familiar with RE, I am posting here ;o)
I try to get the source-page of a frame definition
in a html file.
Such a definition can look like this:
<FRAME name="test1" src="http://www.altavista.com">
My RegExp pattern is:
strPattern = "(\<FRAME\s+.*src\s*\=\s*[\""|\']?)(.*)([\""|\']?.*\>)"
THIS WORKS!
But it returns the whole string, and I would like
to have http://www.altavista.com to be returned, only.
Do you know how to extract this information by using RE?
I think it has something to do with "back references"!?
Thank you very much,
Gerfried Ranner
------------------------------
Date: Tue, 31 Jul 2001 16:46:53 +0100
From: "Nathan Randle" <nathan.randle@ntlworld.com>
Subject: Strange problem...
Message-Id: <0rA97.12844$ip4.3830022@news2-win.server.ntlworld.com>
Sorry about writing two questions in quick succesion but this one is
baffling me.
I have set a perl script to write the values of check boxes into a file
seperated by | but when i test the script and look at the file all that's
included is the | seperators
So anybody know what I'vedone wrong here?
I have posted the script and the HTML page I used below:
Perl Script:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@checks = split(/&/, $buffer);
foreach $check (@checks) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
open(MAP,">output.dat");
flock(MAP,2);
print MAP "$FORM{'north'}|$FORM{'east'}|";
print MAP "$FORM{'south'}|$FORM{'west'}|";
close(MAP);
HTML Doc:
<html>
<head>
<title>
Directions
</title>
</head>
<body>
<form action="map.pl" method="POST">
North <input type="checkbox" name=north value=1><br>
East <input type="checkbox" name=east value=1><br>
South <input type="checkbox" name=south value=1><br>
West <input type="checkbox" name=west value=1><br>
<input type="submit">
</form>
</body>
</html>
Thanks in advance.
Nathan
------------------------------
Date: 31 Jul 2001 20:29:54 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Strange problem...
Message-Id: <87wv4pqcxp.fsf@abra.ru>
NR> Sorry about writing two questions in quick succesion but this one is
NR> baffling me.
NR> I have set a perl script to write the values of check boxes into a file
NR> seperated by | but when i test the script and look at the file all that's
NR> included is the | seperators
NR> So anybody know what I'vedone wrong here?
First of all it seems that you are reinventing the wheel. You should
use either CGI, CGI::Minimal or simular modules to parse CGI params
unless you really very good reason do not use them.
But anyway you code contains a bug which you could find very easily
under strict mode. See below for fix and consider using tested code
(CGI, CGI::Minimal or simular modules from CPAN) for CGI params
parsing and consider always using strict mode.
NR> [..skip..]
NR> Perl Script:
NR> #!/usr/bin/perl
NR> print "Content-type:text/html\n\n";
NR> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
NR> @checks = split(/&/, $buffer);
NR> foreach $check (@checks) {
NR> ($name, $value) = split(/=/, $pair);
^^^^^
It should be $check
NR> $value =~ tr/+/ /;
NR> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
NR> $FORM{$name} = $value;
NR> }
NR> open(MAP,">output.dat");
NR> flock(MAP,2);
NR> print MAP "$FORM{'north'}|$FORM{'east'}|";
NR> print MAP "$FORM{'south'}|$FORM{'west'}|";
NR> close(MAP);
NR> [..skip..]
If you will consider my suggestions your code can look like:
#!/usr/bin/perl -w
use strict;
use CGI;
use POSIX qw(:flock)
my $q = new CGI;
print "Content-type:text/html\n\n";
open(MAP,">output.dat");
flock(MAP,LOCK_EX);
print MAP $q->param('north') . '|' . $q->param('east') . '|';
print MAP $q->param('south') . '|' . $q->param('west') . '|';
flock(MAP,LOCK_UN)
close(MAP);
...
...
P.S. It is also good idea do use symbolic names for constants. Thus I
have 'use POSIX qw(:flock) and use LOCK_EX instead of 2'.
P.P.S. AFAIK on some systems you should always unlock file before
closing filehandle.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Tue, 31 Jul 2001 17:41:12 +0100
From: "Nathan Randle" <nathan.randle@ntlworld.com>
Subject: Re: Strange problem...
Message-Id: <XdB97.47293$SK6.6205548@news6-win.server.ntlworld.com>
I'm only just learning perl dont get me started on modules and things until
i've got the basics sorted lol.
Ilya Martynov <ilya@martynov.org> wrote in message
news:87wv4pqcxp.fsf@abra.ru...
>
> NR> Sorry about writing two questions in quick succesion but this one is
> NR> baffling me.
>
> NR> I have set a perl script to write the values of check boxes into a
file
> NR> seperated by | but when i test the script and look at the file all
that's
> NR> included is the | seperators
>
> NR> So anybody know what I'vedone wrong here?
>
> First of all it seems that you are reinventing the wheel. You should
> use either CGI, CGI::Minimal or simular modules to parse CGI params
> unless you really very good reason do not use them.
>
> But anyway you code contains a bug which you could find very easily
> under strict mode. See below for fix and consider using tested code
> (CGI, CGI::Minimal or simular modules from CPAN) for CGI params
> parsing and consider always using strict mode.
>
> NR> [..skip..]
>
> NR> Perl Script:
> NR> #!/usr/bin/perl
>
> NR> print "Content-type:text/html\n\n";
>
> NR> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> NR> @checks = split(/&/, $buffer);
> NR> foreach $check (@checks) {
> NR> ($name, $value) = split(/=/, $pair);
> ^^^^^
> It should be $check
>
> NR> $value =~ tr/+/ /;
> NR> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> NR> $FORM{$name} = $value;
> NR> }
>
> NR> open(MAP,">output.dat");
>
> NR> flock(MAP,2);
>
> NR> print MAP "$FORM{'north'}|$FORM{'east'}|";
> NR> print MAP "$FORM{'south'}|$FORM{'west'}|";
> NR> close(MAP);
>
> NR> [..skip..]
>
> If you will consider my suggestions your code can look like:
>
> #!/usr/bin/perl -w
>
> use strict;
> use CGI;
> use POSIX qw(:flock)
>
> my $q = new CGI;
>
> print "Content-type:text/html\n\n";
>
> open(MAP,">output.dat");
>
> flock(MAP,LOCK_EX);
>
> print MAP $q->param('north') . '|' . $q->param('east') . '|';
> print MAP $q->param('south') . '|' . $q->param('west') . '|';
> flock(MAP,LOCK_UN)
> close(MAP);
>
> ...
> ...
>
> P.S. It is also good idea do use symbolic names for constants. Thus I
> have 'use POSIX qw(:flock) and use LOCK_EX instead of 2'.
>
> P.P.S. AFAIK on some systems you should always unlock file before
> closing filehandle.
>
> --
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> | Ilya Martynov (http://martynov.org/)
|
> | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6
|
> | AGAVA Software Company (http://www.agava.com/)
|
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Tue, 31 Jul 2001 10:05:42 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Strange problem...
Message-Id: <3B66E566.4F0304AF@vpservices.com>
Nathan Randle wrote:
>
> I'm only just learning perl dont get me started on modules and things until
> i've got the basics sorted lol.
So in other words, since you are new you would rather do things the hard
(and sometimes unsafe) way rather than the easy (and safe) way? Your
statement is kind of like saying "I'm new in this office so don't tell
me I should use the elevator to get to the 50th floor until I've tried
rapelling up the outside of the building a few times." There are, of
course, many things where you will be better off testing the basics on
your own before using modules but something as complex as using perl for
CGI is not one of them. Come back and experiment later when you've
learned a bit about the complexities that CGI.pm hides from you.
--
Jeff
------------------------------
Date: 31 Jul 2001 21:42:42 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Strange problem...
Message-Id: <878zh5q9kd.fsf@abra.ru>
NR> I'm only just learning perl dont get me started on modules and things until
NR> i've got the basics sorted lol.
Probably creating your own module is not very easy task for
newbie. But using modules created by other people should not be really
big problem for you. Widely used modules like CGI have good
documentation, you can find a lot of usage examples in the Internet
and I bet that even if will run into any problems with it people on
this newsgroup will be able to help you. And always 'use strict' for
any script that exceeds 10 lines is very good habit to get used from
the begining studying Perl. Belive me, I have been newbie some time
ago also.
Don't refuse to learn good practices because you think you are not
ready for them. Once you have learned them you will wonder why you
haven't studied such simple and *usefull* things ealier.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Tue, 31 Jul 2001 12:22:09 -0500
From: Daniel Davidson <danield@life.uiuc.edu>
Subject: why won't the cgi work
Message-Id: <3B66E941.85FB7801@life.uiuc.edu>
I have a cgi that I am working, at least if I run it from the command on
my computer. However once I try to hit it with a web browser in my cgi
directory, it crashes. I am using imagemagick and running apache, and
it appears as if when run from apache, it cant see the path to the
imagemagick directory (I get a delegate cannot be found when trying to
read a jpg (error 330)).
Any help would be nice,
Dan
------------------------------
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 1417
***************************************