[16363] in Perl-Users-Digest
Perl-Users Digest, Issue: 3775 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 22 11:05:45 2000
Date: Sat, 22 Jul 2000 08:05:28 -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: <964278327-v9-i3775@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 22 Jul 2000 Volume: 9 Number: 3775
Today's topics:
Re: "Missing coprocessor" ("Ian.")
Re: "Missing coprocessor" ("Ian.")
Re: $query->can() and cgi.pm (Mark-Jason Dominus)
ANNOUNCE: AI::NeuralNet::BackProp v0.40, beta. <jdb@wcoil.com>
ANNOUNCE: AI::NeuralNet::BackProp v0.40, beta <jdb@wcoil.com>
ANNOUNCE: Locale::PO 0.10 <alansz@uic.edu>
Re: File Token <bart.lateur@skynet.be>
Re: File Token (M.J.T. Guy)
Re: File Token <bart.lateur@skynet.be>
Help (Wong Chi Chung)
Re: Help (Abigail)
Re: How do I match a range of numbers? (Keith Calvert Ivey)
How do I spilt up a UPD packet?? <ditlew@abk.auc.dk>
Re: How to detect when an output file is removed (M.J.T. Guy)
Re: How to detect when an output file is removed <care227@attglobal.net>
Loop with regexps <eric.selin@pp.inet.fi>
Perl 6 development begins in earnest (brian d foy)
Re: perl for embeded scripting <godzilla@stomp.stomp.tokyo>
Re: perl for embeded scripting (Gwyn Judd)
Re: Perl program dies through CGI, not from console <bart.lateur@skynet.be>
Re: perl-5.6.0: Bug with "not" operator? (M.J.T. Guy)
Query String Golf aqutiv@my-deja.com
Re: secure auth trick <gus@black.hole-in-the.net>
Re: Semaphore-ish File Sharing (M.J.T. Guy)
Re: Sending mail using sockets <bart.lateur@skynet.be>
Re: Suggestion for syntax change <bart.lateur@skynet.be>
Re: Swedish social security number control. (slow code <iltzu@sci.invalid>
Re: UDP and ActivePERL (WIN32) <carvdawg@patriot.net>
Re: uninitialized variable value? (Abigail)
Re: uninitialized variable value? (M.J.T. Guy)
Use of eval to redirect output? <nate@west.sun.com>
What does "assigning a new value to the entire hash" me <rhys.tucker@dtn.ntl.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 22 Jul 2000 10:53:38 +0000 (UTC)
From: ian.freedomnet@softhome.net ("Ian.")
Subject: Re: "Missing coprocessor"
Message-Id: <20000722.1053.1032snz@softhome.net>
>JS> http://www.delorie.com/djgpp/dl/ofc/simtel/v2gnu/perl552b.zip
>
>Ill have another look in the v2gnu directory.
Do that. I'm pretty sure it's in the DJGPP FAQ. Have you searched the
site of <www.delorie.com>?
I looked in the simtel mirror bit but I couldnt see anything in
the index file.
p.s. I've searched that FAQ myself. Here's the link I found:
http://www.delorie.com/djgpp/v2faq/faq11.html
most notably:
http://www.delorie.com/djgpp/v2faq/faq11_1.html
Thanks very much. Theres some good clues in there. Ill
familarise myself a bit more with this delorie site.
--
Bye now,
Ian.
------------------------------
Date: Sat, 22 Jul 2000 11:01:46 +0000 (UTC)
From: ian.freedomnet@softhome.net ("Ian.")
Subject: Re: "Missing coprocessor"
Message-Id: <20000722.1101.1033snz@softhome.net>
>>JS> Hey! You want to get killfiled over this ?
>>
>>Preferable to being completely ignored. I wouldnt mind so much if
>>this was a low volume group but there looks like theres hundreds
>>of people here.
>
>And how many of those hundreds do you think are using Perl for
>DOS on a 386 machine? There's nothing wrong with being in an
>extreme minority, but don't take it personally when few people
>know about your issues. It doesn't mean they hate you -- they
>just don't have anything to say.
Probably not many still using 386s; but I bet, quiet a few
who used to. As for being hated, its not exactly friendly
threatening to killfile a person. Still, Im on my way now.
--
Bye now,
Ian.
------------------------------
Date: Sat, 22 Jul 2000 13:11:28 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: $query->can() and cgi.pm
Message-Id: <39799d80.6fb$17c@news.op.net>
In article <1ee39co.79cwgullzptkN%kpreid@attglobal.net>,
Kevin Reid <kpreid@attglobal.net> wrote:
>A thought: can() is a method. Therefore it can be overriden. Couldn't
>CGI.pm (and other modules that use AUTOLOAD) override it to make it work
>as expected?
Yes, and CGI.pm's failure to do this should be construed as a bug.
Patches, as usual, are probably welcome.
If the original posted wants to work around the problem, one way to do
that is to add
sub CGI_can {
my ($package, $method) = @_;
# ... appropriate code here
}
BEGIN { *CGI::can = \&CGI_can unless defined &CGI::can }
in his main program.
------------------------------
Date: 22 Jul 2000 13:37:05 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: ANNOUNCE: AI::NeuralNet::BackProp v0.40, beta.
Message-Id: <8lc821$ov3$0@206.230.71.26>
Announcing the first public release of
AI::NeuralNet::BackProp v0.40, beta.
Download URL:
http://www.josiah.countystart.com/modules/AI/cgi-bin/rec.pl
Or, you can download it from your favorite CPAN mirror under:
$CPAN/authors/id/J/JB/JBRYAN/AI-NeuralNet-BackProp-0.40.zip
File size totals 35272 bytes.
Synopsis:
use AI::NeuralNet::BackProp;
my $net = new AI::NeuralNet::BackProp($layers,$neurons_per_layer);
$net->learn(\@input_pattern, \@desired_output_pattern);
my $array_ref_to_net_output = $net->run(\@test_input_pattern);
Description:
AI::NeuralNet::BackProp implements a neural network similar to a
feed-foward, back-propagtion network; learning via a mix of a generalization
of the Delta rule and a disection of Hebbs rule. The actual neruons of the
network are implemented via the AI::NeuralNet::BackProp::neuron package.
Notes:
A personal thankyou for suggestions from Daniel Macks
and encouragement from Tobia Brox. Thankyou!
Disclaimer:
I _DO NOT_ claim to have created a classical
implementation of any form of neural networking. I simply
claim to have created a module which learns using a method
similar to back-propagation. No doubt, methods used in
this module will leave much to be desired. But this is just
a beta release. I repeat, i do not make any claim about the
validity or adherance to any well known AI rules with this package.
This is just a fun experiment that I hope others can help and
have fun with as I have had fun producing this beta copy.
This disclaimer is provided in hopes of warding off any more
troll attacks or 25-message threads. :-) But that was good
reading.
Please give feedbacks on any idea you have for this module. Also, if you can
patch any bugs you think you find, or just tell me about any bugs you find
that I didn't mention in README, I would be grateful!
--
Josiah Bryan
VP of Product Development
TDCJ, Inc.
"Anything is possible."
vp@tdcj.com
http://www.josiah.countystart.com/
Tel: 937.316.6256
------------------------------
Date: 22 Jul 2000 08:13:26 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: ANNOUNCE: AI::NeuralNet::BackProp v0.40, beta
Message-Id: <snj99v1gjjt37@corp.supernews.com>
Announcing the first public release of
AI::NeuralNet::BackProp v0.40, beta.
Download URL:
http://www.josiah.countystart.com/modules/AI/cgi-bin/rec.pl
Or, you can download it from your favorite CPAN mirror under:
$CPAN/authors/id/J/JB/JBRYAN/AI-NeuralNet-BackProp-0.40.zip
File size totals 35272 bytes.
Synopsis:
use AI::NeuralNet::BackProp;
my $net = new AI::NeuralNet::BackProp($layers,$neurons_per_layer);
$net->learn(\@input_pattern, \@desired_output_pattern);
my $array_ref_to_net_output = $net->run(\@test_input_pattern);
Description:
AI::NeuralNet::BackProp implements a neural network similar to a
feed-foward, back-propagtion network; learning via a mix of a generalization
of the Delta rule and a disection of Hebbs rule. The actual neruons of the
network are implemented via the AI::NeuralNet::BackProp::neuron package.
Notes:
A personal thankyou for suggestions from Daniel Macks
and encouragement from Tobia Brox. Thankyou!
Disclaimer:
I _DO NOT_ claim to have created a classical
implementation of any form of neural networking. I simply
claim to have created a module which learns using a method
similar to back-propagation. No doubt, methods used in
this module will leave much to be desired. But this is just
a beta release. I repeat, i do not make any claim about the
validity or adherance to any well known AI rules with this package.
This is just a fun experiment that I hope others can help and
have fun with as I have had fun producing this beta copy.
This disclaimer is provided in hopes of warding off any more
troll attacks or 25-message threads. :-) But that was good
reading.
Please give feedbacks on any idea you have for this module. Also, if you can
patch any bugs you think you find, or just tell me about any bugs you find
that I didn't mention in README, I would be grateful!
--
Josiah Bryan
VP of Product Development
TDCJ, Inc.
"Anything is possible."
vp@tdcj.com
http://www.josiah.countystart.com/
Tel: 937.316.6256
------------------------------
Date: 22 Jul 2000 14:23:02 GMT
From: Alan Schwartz <alansz@uic.edu>
Subject: ANNOUNCE: Locale::PO 0.10
Message-Id: <snjd0naojjt76@corp.supernews.com>
I have just uploaded the Locale::PO module, version 0.10 to
CPAN.
The suggested module list line is:
Name DSLI Description Id
------------- ---- -------------------------------------------- ------
Locale::PO bdpO Manipulate gettext po-file entries ALANSZ
>From the README file:
Locale::PO - Object-oriented interface to gettext po-file entries
Copyright (c) 2000 Alan Schwartz <alansz@pennmush.org>.
All rights reserved. This program is free software; you can
redistribute it and/or modify it under the same terms as Perl itself.
DESCRIPTION
This module provides methods for manipulating objects that represent
entries in a gettext po-file (untranslated and translated strings,
with associated comments). It can load and save complete po-files.
INSTALLATION
perl Makefile.PL
make
make test
make install
REVISION HISTORY
0.10 July 2000 - Initial release.
FUTURE PLANS
This module will be the back end to a web interface for translation
teams to use as an alternative to emacs po-mode. When that's done,
it will be included as an example application.
------------------------------
Date: Sat, 22 Jul 2000 11:32:39 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: File Token
Message-Id: <o41jns83ivl5e801sb2iguqmq36heqan7u@4ax.com>
nobull@mail.com wrote:
>Better idea is probably to create the file under a different name and
>then rename it.
It might fail.
If two processes are working on a new version of the same file ,at the
same time, both are creating a new file. Then, both rename their file to
substitute the original file. All changes done by the first one to
finish, will be lost because the second one will overwrite it's changes.
You know what it's good for? Allowing read access to the old version, as
long as the new file isn't finished. When you do overwrite the old file,
on Unixy systems, processes that are reading the old file can continue
to do so, even after the new file is renamed. They won't ever see a
blend of old and new data. It's just that only one process may update
the file at a time. If more than one process wants to update the file,
the others should read the old data only after the first process
finished writing, and renamed the file.
Now, figure out a locking mechanism to assure that. I think a lockfile
will be a good idea, but the details aren't clear to me.
--
Bart.
------------------------------
Date: 22 Jul 2000 13:44:14 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: File Token
Message-Id: <8lc8fe$69f$1@pegasus.csx.cam.ac.uk>
Bart Lateur <bart.lateur@skynet.be> wrote:
>
>You know what it's good for? Allowing read access to the old version, as
>long as the new file isn't finished. When you do overwrite the old file,
>on Unixy systems, processes that are reading the old file can continue
>to do so, even after the new file is renamed. They won't ever see a
>blend of old and new data. It's just that only one process may update
>the file at a time. If more than one process wants to update the file,
>the others should read the old data only after the first process
>finished writing, and renamed the file.
>
>Now, figure out a locking mechanism to assure that. I think a lockfile
>will be a good idea, but the details aren't clear to me.
You don't need a separate lock file. Just ensure that all processes
use the same name for the new file and take an exclusive lock on it.
Essentially the same protocol as for updating in place.
Mike Guy
------------------------------
Date: Sat, 22 Jul 2000 14:15:40 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: File Token
Message-Id: <pnajnscln1h54ncgjlvl3ntub13l39j45b@4ax.com>
M.J.T. Guy wrote:
>You don't need a separate lock file. Just ensure that all processes
>use the same name for the new file and take an exclusive lock on it.
>Essentially the same protocol as for updating in place.
I don't think it will work.
Why? Suppose that one file is creating the new file, and locks it.
Andother program tries to create the same file, succeeds in opening it,
and finds it locked. So it waits.
The first program renames the file, closes it, releases the lock, in
whatever order you ight like best.
The other program now can lock the file. What file gets locked, and
updated? The file that was renamed! Oops! Direct update of the final
file, which is what we tried to avoid!
--
Bart.
------------------------------
Date: 22 Jul 2000 07:29:58 GMT
From: cswcc94@engsvr.ust.hk (Wong Chi Chung)
Subject: Help
Message-Id: <8lbihm$j87$1@news.ust.hk>
------------------------------
Date: 22 Jul 2000 03:46:00 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Help
Message-Id: <slrn8nilas.sif.abigail@alexandra.foad.org>
Wong Chi Chung (cswcc94@engsvr.ust.hk) wrote on MMDXVII September
MCMXCIII in <URL:news:8lbihm$j87$1@news.ust.hk>:
\\
Here are some hints:
When your newsreader brings up the message editor:
hit a
type your message.
hit ESC
hit ZZ
HTH. HAND.
Abigail
--
New email address: abigail@foad.org
------------------------------
Date: Sat, 22 Jul 2000 06:40:51 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: How do I match a range of numbers?
Message-Id: <397c411b.3632235@news.newsguy.com>
Jakob Schmidt <sumus@aut.dk> wrote:
>I can see two obvious options. Using the numerical values:
>
>while ( <DATA> )
>{
> /123\.250\.(\d+)\.\d+/ and 18 <= $1 and $1 <= 34 and next;
> # only lines without the offensive IP will make it here
> print
>}
>
>Or using brute force (don't do this if the range is big but the technique is
>useful if for instance you're dealing with a number of small ranges which
>could cause clumbsy predicates otherwise)
>
>my $range = join '|', 18..34;
>while ( <DATA> )
>{
> /123\.250\.($range)\.\d+/ and next;
> # only lines without the offensive IP will make it here
> print
>}
A third way would be to factor out the common parts of the
numbers so you don't have such a long list of alternations:
/^123\.250\.(?:1[89]|2\d|3[0-4])\.\d+$/ and next;
Of course, it's not as easy to generalize it.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)
------------------------------
Date: Sat, 22 Jul 2000 13:23:07 GMT
From: "Daniel Ditlew" <ditlew@abk.auc.dk>
Subject: How do I spilt up a UPD packet??
Message-Id: <%ehe5.3161$MJ5.36143@twister.sunsite.auc.dk>
Hi.. I'am newbie!! I haven't been able to find this information anywhere!!
I get a UPD packet that looks like this:
$packet = "(int32)(byte)(byte)(byte)(string)(int32)(float32)
..(..(byte)(string)(int32)(float32)..).."
My problem:
I seem to recive the packet as one long string, and I
dont know how to split the string up into the different components..
The following does some of the trick(I dont know why).. But it's still
messes up!!:
@msg = split("\x", $packet);
- Ditlew, Denmark, Newbie!!
------------------------------
Date: 22 Jul 2000 13:39:40 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: How to detect when an output file is removed
Message-Id: <8lc86s$66r$1@pegasus.csx.cam.ac.uk>
Drew Simonis <care227@attglobal.net> wrote:
>timhood@bigfoot.com wrote:
>>
>> I have a process that writes output to a log file. It seems though that
>> if someone removes the logfile after the program redirects the output
>> that all future output goes to nowhere-land.
>>
>
>You might find these usefull:
>
>http://www.perl.com/pub/doc/manual/html/lib/Fatal.html
>http://www.perl.com/pub/doc/manual/html/pod/perlfunc/print.html
>http://www.perl.com/pub/doc/manual/html/pod/perldiag.html
While they're all good things to read, I don't see the relevance to Tim's
problem.
In the Unix world, you're at liberty to delete a file even though it
is currently open. Or more strictly, you can delete a link to a file
(directory entry). The file itself isn't deleted; rather it will
go away when the last handle to it disappears (in this case, when
the program closes the file).
So in fact your program is filling up the disk with stuff you can't see.
The prints won't give any error (at least until the disk is full ... ).
This is a situation best avoided.
Mike Guy
------------------------------
Date: Sat, 22 Jul 2000 10:41:26 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: How to detect when an output file is removed
Message-Id: <3979B296.267C5F70@attglobal.net>
"M.J.T. Guy" wrote:
>
> Drew Simonis <care227@attglobal.net> wrote:
>
> >You might find these usefull:
> >
> >http://www.perl.com/pub/doc/manual/html/lib/Fatal.html
> >http://www.perl.com/pub/doc/manual/html/pod/perlfunc/print.html
> >http://www.perl.com/pub/doc/manual/html/pod/perldiag.html
>
> While they're all good things to read, I don't see the relevance to Tim's
> problem.
>
> In the Unix world, you're at liberty to delete a file even though it
> is currently open. Or more strictly, you can delete a link to a file
> (directory entry). The file itself isn't deleted; rather it will
> go away when the last handle to it disappears (in this case, when
> the program closes the file).
I had been aware of this and understand the connection between
links to a file and that files existence, but I overlooked that
a process can hold a file. I shouldn't have. Heck, I just installed
lsof to track this very sort of behaviour.
> So in fact your program is filling up the disk with stuff you can't see.
> The prints won't give any error (at least until the disk is full ... ).
Thanks for the info, Mike. Yet another lesson learned.
------------------------------
Date: Sat, 22 Jul 2000 13:24:34 GMT
From: "Eric Selin" <eric.selin@pp.inet.fi>
Subject: Loop with regexps
Message-Id: <mghe5.880$Av5.21090@news.kpnqwest.fi>
Hi, I need a loop that will search for a regexp in a string.
Like this:
$b = 1;
loop until(endof $a) {
$a =~ /^(.*);
print "<a href=\"$b\">a$</a>\n";
$b++;
}
Thats just an idea. I hope you get the point.
Thanx, Eric
------------------------------
Date: Wed, 19 Jul 2000 15:55:20 -0500
From: brian@smithrenaud.com (brian d foy)
Subject: Perl 6 development begins in earnest
Message-Id: <snj9abtsjjt181@corp.supernews.com>
reply to brian d foy, brian+perl6@smithrenaud.com
LARRY WALL ANNOUNCES BROAD VISION FOR PERL 6
In his keynote address to the O'Reilly Second Open Source
Convention, Larry Wall laid out his vision for the future
development of Perl 6. Larry reports that "Perl 6
development has began in earnest".
The next version of Perl is a chance for the language
developers to both rewrite the internals and externals of
Perl based on their experience from developing Perl 5 and
Chip Salzenberg¹s work with Topaz. Larry promises that Perl
6 will be "better, stronger, faster" and that there will be
a clear, clean migration path from Perl 5 to Perl 6. A
preview release of should be available by next summer.
Perl 6 will use a development model that draws from the
lessons learned from perl5-porters and other large open
source projects such as the Apache web server and the Linux
operating system. Development topics will be assigned to
working groups which will work under a central project
manager with Nat Torkington acting as the interim project manager.
Details will be made available in the Perl 6 section of
www.perl.org which is the blessed source of information
on Perl 6.
The current major release of Perl will continue to be
supported. The maintenance track will be led by Jarkko
Hietaniemi. Current development tracks, such as Unicode
support, will be finished in Perl 5.
Interested developers can subscribe to the Perl 6
development mailing list by sending a message to
bootstrap-subscribe@perl.org.
--
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ
<URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sat, 22 Jul 2000 00:04:42 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: perl for embeded scripting
Message-Id: <3979478A.E223ACAB@stomp.stomp.tokyo>
Jeff Davis wrote:
(snippage)
> The problem is that I can't let people use things such as 'open()' and
> other "unsafe" operations. In other words, I want a scripting language
> that you can't write a virus in. I think I could figure out which
> functions I could allow safely, but I need the rest to be completely
> forbidden.
> I appreciate any advice, including other strategies for
> what I wan to do.
There is this "wan" word again. Tell ya, this word sure
shows up in a lot of articles by different authors. Has
to be New Speak.
At times, I will say to some of my University students,
"I am Dr. Schilitubi. I am not Dr. Twenty Questions.
Have you considered researching your topic?"
So instead of asking broad general questions which
cannot be answered without assistance of an editor
and a good publisher, do your homework.
http://www.securityfocus.com/
http://www.cert.org/nav/securityimprovement.html
http://www.eekim.com/pubs/cgibook/ch09/0902.html
http://www.mathcs.urich.edu/~jkent/forms/restrictions.html
Just when you thought cgi.pm is the hottest yet,
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-03/msg00750.html
You ain't seen nuttin Mister,
http://www.AntiOnline.com/archives/anticode/?cat=cgi-bin-exploits.html
http://www.prognosisx.com/infosyssec/index.html
http://bau2.uibk.ac.at/matic/security.htm
http://anon.cotse.com/abusepolicies.html
Godzilla!
--
I will rock you.
http://la.znet.com/~callgirl3/hush.mid
------------------------------
Date: Sat, 22 Jul 2000 08:50:52 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: perl for embeded scripting
Message-Id: <slrn8nio39.ab3.tjla@thislove.dyndns.org>
I was shocked! How could Godzilla! <godzilla@stomp.stomp.tokyo>
say such a terrible thing:
>Jeff Davis wrote:
>
>(snippage)
>
>> The problem is that I can't let people use things such as 'open()' and
>> other "unsafe" operations. In other words, I want a scripting language
>> that you can't write a virus in. I think I could figure out which
>> functions I could allow safely, but I need the rest to be completely
>> forbidden.
>
>> I appreciate any advice, including other strategies for
>> what I wan to do.
>
>
>There is this "wan" word again. Tell ya, this word sure
>shows up in a lot of articles by different authors. Has
>to be New Speak.
Main Entry: wan
Function: intransitive verb
Inflected Form(s): wanned; wan·ning
Date: 1582
: to grow or become pale or sickly
--
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
Those who can, do. Those who can't, simulate.
------------------------------
Date: Sat, 22 Jul 2000 11:19:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl program dies through CGI, not from console
Message-Id: <130jns046olurd4r1f06rcrlooc9rv4oib@4ax.com>
iJohn wrote:
>When I get that kind of problem, I issue a regular text/html header right at
>the start of the script, and then stick in print diagnostic statements in
>the perl code, followed by an exit (print "Got to line 350";exit;). This
>usually narrows things down pretty quickly.
Let Perl help you in that. Set the $SIG{__DIE__} handler to do that for
you. Assuming the content-type header will always be sent:
$SIG{__DIE__} = sub {
local $_ = shift; s/&/&/g; s/</</g;
print "<PRE>$_</PRE>\n";
exit;
};
$! = rand 50;
die "Oops: $!";
Or, use the CGI::Carp module:
use CGI::Carp 'fatalsToBrowser';
--
Bart.
------------------------------
Date: 22 Jul 2000 13:54:42 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: perl-5.6.0: Bug with "not" operator?
Message-Id: <8lc932$6lr$1@pegasus.csx.cam.ac.uk>
Keith Calvert Ivey <kcivey@cpcug.org> wrote:
>mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:
>
>>The examples which have come up are like
>>
>> not (localtime)[6]; # it isn't Sunday
>
>Yes, but have you ever seen that used in a real program?
See the p5p archives for reports of problems actually encountered.
They had that general style.
Mike Guy
------------------------------
Date: Sat, 22 Jul 2000 08:29:43 GMT
From: aqutiv@my-deja.com
Subject: Query String Golf
Message-Id: <8lbm1f$rnb$1@nnrp1.deja.com>
Not sure if you've passed that already, But I'll just take the risk. ;)
(Note: this is the second time I post it, the first I'm almost sure
didn't succeed, sorry if you've seen that alrady)
So... What would be the shortest way to parse a query string style
string? I've found this solution:
$_ = $ENV{'QUERY_STRING'}; tr/+/ /;
@QS{/(.+?)=.+?(&|$)/g} = /.+?=(.+?)(&|$)/g;
s/%(..)/pack('c', hex($1))/eg foreach %QS;
Which I admit, Isn't perfect.
can anyone do it with less keywords and/or maby more efficient?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 22 Jul 2000 13:04:21 GMT
From: Gus <gus@black.hole-in-the.net>
Subject: Re: secure auth trick
Message-Id: <964271061.19125.0.nnrp-12.c29f015a@news.demon.co.uk>
Robin Bank <rbank@csf.edu> wrote:
> Just came up with a really cool trick to get a fairly secure password
> authentication in PERL for a site without having to go through all that
> encryption stuff.
s/PERL/Perl/;
What you're destribing is how to place a file on the filesystem which, with
the current configuration of your web server, will not be served. That
does not make things secure.
Firstly, an easier way would be (in Apache)
<Files \.USR$>
Order allow,deny
Deny from all
</Files>
So the requesting browser would get a 403 forbidden rather than a rather
confusing 500 error. It would also help make your log files a bit easier
to understand.
Alternatively, why not just store the file outside the web server document
tree ?
Lastly, I assume you are on your own server, so no-one else can write a
upload a CGI program which reads the file in question ?
--
gus@black.hole-in-the.net
0x58E18C6D
82 AA 4D 7F D8 45 58 05 6D 1B 1A 72 1E DB 31 B5
http://black.hole-in-the.net/gus/
------------------------------
Date: 22 Jul 2000 14:36:36 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Semaphore-ish File Sharing
Message-Id: <8lcbhk$85r$1@pegasus.csx.cam.ac.uk>
Glen Heide <jheide@sprint.ca> wrote:
>
>I got a txt file in my cgi-bin directory where my cgi scripts get access to
>user profiles and such. When multiple users READ from the file, I know that
>this won't cause a problem. In perl though, is there any problems that
>might happen if users changed their password at exactly the same time as
>another person was reading the file or changing their password? It's very
>unlikely, I open the file, read what I need, then close it, but I'd like to
>be on the safe side.
>
>I use the simple OPEN command. So, will any problems arise? And if so, are
>there any solutions?
It depends on how you update the file. If you use any method
except "create a new file then rename it over the old one", you
have potential problems. Even with renaming, you'll need to
interlock between competing updaters.
To avoid problems, take a shared lock on reading and an exclusive
lock on updating. See
perldoc -f flock
perldoc -q '\block'
Mike Guy
------------------------------
Date: Sat, 22 Jul 2000 11:01:44 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Sending mail using sockets
Message-Id: <rkvins0o6ao7h2bgo8j2hn2e9f55g34aii@4ax.com>
Abigail wrote:
>So, what exactly do you want? Talking SMTP yourself? Well, then you
>just open a socket and talk SMTP. To open a socket, you either use
>socket(), bind(), listen() and frieds, or you use the IO::Socket
>module. How to talk SMTP isn't a Perl question though.
However, you could use existing modules on CPAN as inspiration. Or just
use one of them.
For example:
Mail::Sendmail http://search.cpan.org/search?dist=Mail-Sendmail
Net::SMTP http://search.cpan.org/search?dist=libnet
--
Bart.
------------------------------
Date: Sat, 22 Jul 2000 11:48:13 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Suggestion for syntax change
Message-Id: <qu1jnsshg2nofnt7u27v7o5vupnnvnjjuc@4ax.com>
jason wrote:
>> @rest = @somelist[2 .. -1];
>that's an array .. not an unknown list ..
I know. It's just that examples with lists of unknown length aren't easy
to come up with in a snippet.
>you could just do
>
> @rest = @somelist[2..$#somelist];
That argument came up the last time we had this dicussion, too. If
that's a good enough answer for you, why do we need negative indices at
all? Can't we always do
$item[$#item-1]
instead of
$item[-2]
?
Well, no. Negative indices are neat.
It's just that these list index ranges aren't consequent in Perl.
Items referenced from start of list:
@item[2..4] works
Items referenced from end of list:
@item[-4 .. -1] works
Items referenced from start of list till referenced from end of list:
@item[2 .. -2] does not work
The fact that in practice, Perl first converts a range to a list of
indices, should be irrelevant. That is the reason why it fails. But,
take:
for my $i (1 .. 10000) {
dosomething($i);
}
Well, this will NOT first convert the range to a list of 100000 items.
It will go through them one at a time, creating each list item only when
it's used.
That's just an example that model and implementation need not agree.
Perl not doing proper DWIM for @item[2 .. -2] because of how it's
implemented, seems too primitive an argument to me.
--
Bart.
------------------------------
Date: 22 Jul 2000 14:35:57 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Swedish social security number control. (slow code / get it more effective if you can please)
Message-Id: <964275118.29818@itz.pp.sci.fi>
In article <39786E02.6E62EE95@ostas.lu.se>, Jimmy Lantz wrote:
>the below is a working code for checking if a swedish soc. security
>number is valid or not,
>but I wonder if any of you perlexperts can see ways to make it more
>efficient.
>It takes a lot of code to check it this way.
Alex Rhomber has already given a nice and compact answer. Here's a
slightly more verbose one, just to show TIMTOWTDI:
#!/usr/bin/perl -w
use strict;
foreach my $ssn (@ARGV) {
my @digits = $ssn =~ /(\d)/g;
print "$ssn has wrong number of digits!\n" and next
unless @digits == 10;
foreach (@digits[0,2,4,6,8]) { $_ += $_ + int($_ / 5) }
my $sum = 0;
foreach (@digits) { ($sum += $_) %= 10 }
print "$ssn passes checksum.\n" and next unless $sum;
print "$ssn fails, last digit should be ",
($digits[-1] - $sum) % 10, "\n";
}
__END__
>The swedish soc sec nr consists by 10 numbers.
>often written yymmdd-nnnn
..a fact that can create interesting situations for anyone trying to
use a Finnish ID in Sweden or vice versa, since SSNs here have the
format ddmmyy-nnnx, superficially similar except that the date parts
are reversed and the checksum is computed differently.
--
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: Sat, 22 Jul 2000 07:31:57 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: UDP and ActivePERL (WIN32)
Message-Id: <3979862D.59016DC6@patriot.net>
Tell you what...send me the full script via email...I use a pretty good
packet sniffer on
my NT box (Analyzer) and will test it out for you...
lush3@geocities.com wrote:
> Hello everyone,
> I'm trying to set up a communication via UDP but no matter what I
> try it does not work. Doing the same thing via TCP just works fine.
>
> Here's some code fragment -->
>
> $chall = "sensomething";
>
> use strict;
> use IO::socket;
>
> my (..... etc)
>
> $host="date.game.net";
> $port="12233";
>
> $sock = IO::Socket::INET->new(Proto => "udp",
> PeerPort => $port,
> PeerAddr => $host,)
> or die "Could not open SocketSend ... exiting";
>
> for (1..3000)
> {
> $sock->send($chall) == length($chall) or die "Can not send
> UDP data to $!";
> }
>
> $sock->recv($test,10) or die "Error receiving ....: $!";
>
> When I start the script it seems to send data (judging from my
> dial-up monitor) but I can't see the (new) port (UDP) via Netstat!!!
>
> When the script reaches the recv portion it either exits (unknown error)
> or just sits there doing (waiting?) ....!
> The UDP-Port does not show up while receiving as well!
>
> Any hints are higly appreciated!
> Should I use another module?
> I'm totally clueless here!
>
> Thanks in advance,
>
> Andreas
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: 22 Jul 2000 03:28:16 EDT
From: abigail@foad.org (Abigail)
Subject: Re: uninitialized variable value?
Message-Id: <slrn8nik9k.sif.abigail@alexandra.foad.org>
Keith Calvert Ivey (kcivey@cpcug.org) wrote on MMDXVII September MCMXCIII
in <URL:news:397a39b0.1733468@news.newsguy.com>:
"" abigail@foad.org (Abigail) wrote:
""
"" >Here's one way to test it:
"" >
"" > eval 'local $^W = 1; "$certain_variable"';
"" > if ($@ =~ /^Use of uninitialized value in string/) {
"" > # Value is unitialized
"" > }
""
"" Why does it say "uninitialized" there anyway rather than
"" "undefined"? If I initialize the variable and then later set it
"" to undef and use it, I still get the same warning.
You snipped out something from my posting.
The line where I pointed out that variables aren't uninitialized, but
*VALUES* can be.
Please don't reply and start babbling about uninitialized variables again.
Abigail
--
New email address: abigail@foad.org
------------------------------
Date: 22 Jul 2000 13:48:35 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: uninitialized variable value?
Message-Id: <8lc8nj$6ir$1@pegasus.csx.cam.ac.uk>
Abigail <abigail@foad.org> wrote:
>
>Here's one way to test it:
>
> eval 'local $^W = 1; "$certain_variable"';
> if ($@ =~ /^Use of uninitialized value in string/) {
> # Value is unitialized
> }
Eh? What are you expecting to see in $@ ?
You aren't confusing warn() and die() by any chance ?
Mike Guy
------------------------------
Date: Thu, 20 Jul 2000 13:53:06 -0700
From: Nathan Wiger <nate@west.sun.com>
Subject: Use of eval to redirect output?
Message-Id: <397766B2.C05BB2FC@west.sun.com>
Hi all-
I'm trying to make a little "eval compartment", similar to the way
Apache::Registry works, but with different constraints and for a
different purpose. What I'm trying to do is the *conceptual* equivalent
of this:
my $code = join '', (<CODE>);
@output = eval $code;
die if $@;
print &filter_output(@output);
So, what I'd like to do is be able to eval a block of code and have its
STDOUT output be stuck into @output. That way, I could do stuff with it.
In this way, it's a little like an interprocess pipe.
Maybe eval isn't the way to do this? Maybe a "|-" IPC pipe is the way to
go? Any advice?
Thanks,
Nate
------------------------------
Date: Sat, 22 Jul 2000 12:07:54 +0000
From: rhys <rhys.tucker@dtn.ntl.com>
Subject: What does "assigning a new value to the entire hash" mean?
Message-Id: <39798E9A.8FEE17F0@dtn.ntl.com>
The phrase "assigning a new value to the entire hash" is used twice on
p69 of Learning Perl (2nd ed). Could somebody explain what it means
please?
Is it simply this?
# %hash already exists
%hash = qw(key1 val1 key2 val2);
No doubt it's a simple oversight on my part (yet again;).
thanks,
rhys
------------------------------
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 3775
**************************************