[22671] in Perl-Users-Digest
Perl-Users Digest, Issue: 4892 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 25 09:05:55 2003
Date: Fri, 25 Apr 2003 06:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 25 Apr 2003 Volume: 10 Number: 4892
Today's topics:
Re: apache+perl: how to set a basedir <Andrew.McGregor@amtrak.co.uk>
Re: apache+perl: how to set a basedir <wiz@near.it>
Re: approximate substitution <ubl@schaffhausen.de>
Re: approximate substitution (Helgi Briem)
Can't locate object method new in package MD5 (perhaps (Eric)
Re: Can't locate object method new in package MD5 (perh <tassilo.parseval@rwth-aachen.de>
Re: Can't locate object method new in package MD5 (perh (Anno Siegel)
Curses and perl5.8 (aka ? the Platypus)
Re: Curses and perl5.8 <Andrew.McGregor@amtrak.co.uk>
Re: Curses and perl5.8 (aka ? the Platypus)
Re: Curses and perl5.8 <tassilo.parseval@rwth-aachen.de>
Re: Curses and perl5.8 (aka ? the Platypus)
Re: fake flocking on win32 <peakpeek@purethought.com>
Re: Getting FULL path+filename from a filehandle <krahnj@acm.org>
Re: non-blocking read with IO::Select <japh_klch@programmer.net>
Passing reference to a thread <robh@rthorton.freeserve.co.uk>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Record seperator over lines <kderaedt@hotmail.com>
Re: Record seperator over lines <tassilo.parseval@rwth-aachen.de>
Re: Regex greediness question (Sara)
Re: Session Script <Andrew.McGregor@amtrak.co.uk>
Re: Tough question for the guru's; Grep Once, Awk Twice <krahnj@acm.org>
Re: Tough question for the guru's; Grep Once, Awk Twice (Anno Siegel)
Re: Tough question for the guru's; Grep Once, Awk Twice <richard@zync.co.uk>
Re: Undefining Aggregates <no-spam-TeanerTiner@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 25 Apr 2003 09:26:04 +0100
From: Andrew McGregor <Andrew.McGregor@amtrak.co.uk>
Subject: Re: apache+perl: how to set a basedir
Message-Id: <3EA8F11C.2000605@amtrak.co.uk>
Wiz wrote:
> Hi there,
> I try to set a "basedir" on my apache+perl configuration, running on a linux
> web server.
> I need to allow perl script to access only to the virtualhost directory's
> files, and not to all the web server's tree.
> How can I do it, without set a chroot jail?
what is wrong with chroot?
------------------------------
Date: Fri, 25 Apr 2003 12:47:47 +0200
From: Wiz <wiz@near.it>
Subject: Re: apache+perl: how to set a basedir
Message-Id: <b8b3tg$7tent$1@ID-70527.news.dfncis.de>
Original message from Andrew McGregor, Fri 25 April 2003 10:26:
> Wiz wrote:
>> Hi there,
>> I try to set a "basedir" on my apache+perl configuration, running on a
>> linux web server.
>> I need to allow perl script to access only to the virtualhost directory's
>> files, and not to all the web server's tree.
>> How can I do it, without set a chroot jail?
>
> what is wrong with chroot?
Nothing wrong, but with a chroot perl scripts could open all files of chroot
directories. I need of something that works as the "open_basedir" directive
of PHP.
Marco
------------------------------
Date: Fri, 25 Apr 2003 09:21:16 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: approximate substitution
Message-Id: <b8aqqj$o6f$1@news.dtag.de>
Benjamin Goldberg wrote:
> Have you considered trying Text::Soundex?
>
> use Text::Soundex;
<snip code>
> splice( @input, $match, $splicelen, $replace );
$match -> $matched
First of all thanks, it works. The Problem with Text::Soundex is that it
finds only thinks that sound alike. A spelling mistake can seriously
change the sound, so you won't get a match. At least that's what I think
is happening.
If you change the string in %word2id to "same String" (extra r) you
don't get a match.
I think in the case of my problem an algorithm based on edit distances
would work better because spelling mistakes usually only increase the
edit distance by one.
Bye,
malte.exe
------------------------------
Date: Fri, 25 Apr 2003 11:30:54 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: approximate substitution
Message-Id: <3ea91bda.1283733340@news.cis.dfn.de>
On Fri, 25 Apr 2003 09:21:16 +0200, Malte Ubl
<ubl@schaffhausen.de> wrote:
>First of all thanks, it works. The Problem with Text::Soundex is that it
>finds only thinks that sound alike. A spelling mistake can seriously
>change the sound, so you won't get a match. At least that's what I think
>is happening.
>I think in the case of my problem an algorithm based on edit distances
>would work better because spelling mistakes usually only increase the
>edit distance by one.
How about String::Approx?
--
Regards, Helgi Briem
helgi DOT briem AT decode DOT is
------------------------------
Date: 25 Apr 2003 03:19:48 -0700
From: eric.chin@pinnacle.co.uk (Eric)
Subject: Can't locate object method new in package MD5 (perhaps you forgot to load MD5)?)
Message-Id: <d8c847cd.0304250219.39ae05c8@posting.google.com>
Greetings,
I am fairly new to Perl and I recently upgraded my redhat linux 7.1 to
redhat linux 9. Perl 5.8.0 was installed by default as part of the
installation.
We use a perl script to generate a reverse look up table from the dns
zone file. After the upgrade, the perl script complain that it can't
locate the 'new' method.
The exact message is as follows:
"Can't locate object method new via package MD5 (perhaps you forgot to
load MD5?)"
Does anyone have similar experience ? If so, how do you fix it ?
perl script is mkrdns.pl written by Theo Van Dinter.
I wonder am I missing any other perl module ?
TIA
Eric
------------------------------
Date: 25 Apr 2003 10:25:20 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Can't locate object method new in package MD5 (perhaps you forgot to load MD5)?)
Message-Id: <b8b2eg$b37$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Eric:
> I am fairly new to Perl and I recently upgraded my redhat linux 7.1 to
> redhat linux 9. Perl 5.8.0 was installed by default as part of the
> installation.
>
> We use a perl script to generate a reverse look up table from the dns
> zone file. After the upgrade, the perl script complain that it can't
> locate the 'new' method.
>
> The exact message is as follows:
>
> "Can't locate object method new via package MD5 (perhaps you forgot to
> load MD5?)"
>
> Does anyone have similar experience ? If so, how do you fix it ?
>
> perl script is mkrdns.pl written by Theo Van Dinter.
>
> I wonder am I missing any other perl module ?
Is the MD5 module installed? I remember that each time I upgrade Perl I
find myself installing some MD5-related modules to make CPAN.pm happy
(or, rather, happier - it works without).
Try on the command-line:
perl -MMD5 -e1
If it gives some noisy error messages, it is not installed and you
should do a "perl -MCPAN -e 'install MD5'".
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 25 Apr 2003 10:29:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Can't locate object method new in package MD5 (perhaps you forgot to load MD5)?)
Message-Id: <b8b2m1$1hc$2@mamenchi.zrz.TU-Berlin.DE>
Eric <eric.chin@pinnacle.co.uk> wrote in comp.lang.perl.misc:
> Greetings,
>
> I am fairly new to Perl and I recently upgraded my redhat linux 7.1 to
> redhat linux 9. Perl 5.8.0 was installed by default as part of the
> installation.
>
> We use a perl script to generate a reverse look up table from the dns
> zone file. After the upgrade, the perl script complain that it can't
> locate the 'new' method.
>
> The exact message is as follows:
>
> "Can't locate object method new via package MD5 (perhaps you forgot to
> load MD5?)"
>
> Does anyone have similar experience ? If so, how do you fix it ?
>
> perl script is mkrdns.pl written by Theo Van Dinter.
>
> I wonder am I missing any other perl module ?
The module MD5 has been deprecated for a while. In 5.8.0 it appears to
have been replaced with Digest::MD5. Ask the author for an upgrade,
or change the script yourself to use Digest::MD5. As a last cop-out,
install the deprecated module from CPAN.
Anno
------------------------------
Date: Fri, 25 Apr 2003 07:29:41 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@dformosa.zeta.org.au>
Subject: Curses and perl5.8
Message-Id: <slrnbahp8p.phe.dformosa@dformosa.zeta.org.au>
I'm trying to install Curses.pm under perl5.8 however when I try it
fails to compile. I can't see anything on deja-google about it is
this a know problem or something I should submit a bug report on.
--
Please excuse my spelling as I suffer from agraphia. See
http://dformosa.zeta.org.au/~dformosa/Spelling.html to find out more.
Free the Memes.
------------------------------
Date: Fri, 25 Apr 2003 09:32:18 +0100
From: Andrew McGregor <Andrew.McGregor@amtrak.co.uk>
Subject: Re: Curses and perl5.8
Message-Id: <3EA8F292.9080302@amtrak.co.uk>
David Formosa (aka ? the Platypus) wrote:
> I'm trying to install Curses.pm under perl5.8 however when I try it
> fails to compile. I can't see anything on deja-google about it is
> this a know problem or something I should submit a bug report on.
it is not a known problem... you haven't posted the error message!
don't submit a bug, post the error then someone may be able to help.
------------------------------
Date: Fri, 25 Apr 2003 09:43:01 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@dformosa.zeta.org.au>
Subject: Re: Curses and perl5.8
Message-Id: <slrnbai12o.phe.dformosa@dformosa.zeta.org.au>
On Fri, 25 Apr 2003 09:32:18 +0100, Andrew McGregor
<Andrew.McGregor@amtrak.co.uk> wrote:
> David Formosa (aka ? the Platypus) wrote:
>> I'm trying to install Curses.pm under perl5.8 however when I try it
>> fails to compile. I can't see anything on deja-google about it is
>> this a know problem or something I should submit a bug report on.
>
> it is not a known problem... you haven't posted the error message!
The error message was a long and spammy[1] one if installing Curses
was inpossable for everyone then I wasn't willing to waste bandwidth
posting it. However since its something new I'll include it in this message.
> don't submit a bug, post the error then someone may be able to help.
I haven't programed in c for the longest time, however I think that
Curses.c:275 is the scean killer. However the warnings worry me and
make me think that there is something deeply wrong.
cc -c -I/usr/include/ncurses -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -DVERSION=\"1.06\" -DXS_VERSION=\"1.06\" -fpic "-I/usr/local/lib/perl5/5.8.0/i586-linux-thread-multi-64all-ld/CORE" Curses.c
Curses.c: In function `c_sv2field':
Curses.c:148: warning: cast to pointer from integer of different size
Curses.c: In function `c_sv2form':
Curses.c:169: warning: cast to pointer from integer of different size
Curses.c: In function `c_sv2item':
Curses.c:190: warning: cast to pointer from integer of different size
Curses.c: In function `c_sv2menu':
Curses.c:212: warning: cast to pointer from integer of different size
Curses.c: In function `c_sv2panel':
Curses.c:233: warning: cast to pointer from integer of different size
Curses.c: In function `c_sv2screen':
Curses.c:254: warning: cast to pointer from integer of different size
Curses.c: In function `c_sv2window':
Curses.c:275: warning: passing arg 1 of `Perl_sv_isa' from incompatible pointer type
Curses.c:275: warning: passing arg 2 of `Perl_sv_isa' from incompatible pointer type
Curses.c:275: too few arguments to function `Perl_sv_isa'
Curses.c:276: warning: cast to pointer from integer of different size
In file included from Curses.c:344:
CursesFun.c: In function `XS_Curses_newterm':
CursesFun.c:1279: warning: initialization from incompatible pointer type
CursesFun.c:1280: warning: initialization from incompatible pointer type
CursesFun.c:3453: warning: initialization from incompatible pointer type
CursesFun.c: In function `XS_Curses_getwin':
CursesFun.c:3472: warning: initialization from incompatible pointer type
make: *** [Curses.o] Error 1
[1] In the old sence of the word.
--
Please excuse my spelling as I suffer from agraphia. See
http://dformosa.zeta.org.au/~dformosa/Spelling.html to find out more.
Free the Memes.
------------------------------
Date: 25 Apr 2003 10:16:42 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Curses and perl5.8
Message-Id: <b8b1ua$ajn$1@nets3.rz.RWTH-Aachen.DE>
Also sprach David Formosa (aka ? the Platypus):
> The error message was a long and spammy[1] one if installing Curses
> was inpossable for everyone then I wasn't willing to waste bandwidth
> posting it. However since its something new I'll include it in this message.
>
>> don't submit a bug, post the error then someone may be able to help.
>
> I haven't programed in c for the longest time, however I think that
> Curses.c:275 is the scean killer. However the warnings worry me and
> make me think that there is something deeply wrong.
>
> cc -c -I/usr/include/ncurses -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -DVERSION=\"1.06\" -DXS_VERSION=\"1.06\" -fpic "-I/usr/local/lib/perl5/5.8.0/i586-linux-thread-multi-64all-ld/CORE" Curses.c
> Curses.c: In function `c_sv2field':
> Curses.c:148: warning: cast to pointer from integer of different size
[...]
That looks like a 32bit versus 64bit issue. Your perl appears to be
compiled with -Duse64bitint. Line 148 is
if (sv_isa(sv, "Curses::Field")) { return (FIELD*)SvIV((SV*)SvRV(sv)); }
so the IV returned by SvIV is larger than a pointer to FIELD (that is
what the warning implies).
That's the diagnostic part. I have no fix. You should send a message to
the author of the module and ask him whether he's aware of any such
problem.
> Curses.c: In function `c_sv2form':
> Curses.c:169: warning: cast to pointer from integer of different size
> Curses.c: In function `c_sv2item':
> Curses.c:190: warning: cast to pointer from integer of different size
> Curses.c: In function `c_sv2menu':
> Curses.c:212: warning: cast to pointer from integer of different size
> Curses.c: In function `c_sv2panel':
> Curses.c:233: warning: cast to pointer from integer of different size
> Curses.c: In function `c_sv2screen':
> Curses.c:254: warning: cast to pointer from integer of different size
> Curses.c: In function `c_sv2window':
> Curses.c:275: warning: passing arg 1 of `Perl_sv_isa' from incompatible pointer type
> Curses.c:275: warning: passing arg 2 of `Perl_sv_isa' from incompatible pointer type
> Curses.c:275: too few arguments to function `Perl_sv_isa'
This is not clear to me at all. The line in question looks fine to me:
if (Perl_sv_isa(sv, "Curses::Window")) {
sv is a proper 'SV*' and the second argument is a 'const char*' as
described by perlapi.pod.
> Curses.c:276: warning: cast to pointer from integer of different size
> In file included from Curses.c:344:
> CursesFun.c: In function `XS_Curses_newterm':
> CursesFun.c:1279: warning: initialization from incompatible pointer type
> CursesFun.c:1280: warning: initialization from incompatible pointer type
> CursesFun.c:3453: warning: initialization from incompatible pointer type
> CursesFun.c: In function `XS_Curses_getwin':
> CursesFun.c:3472: warning: initialization from incompatible pointer type
> make: *** [Curses.o] Error 1
These warnings all pertain to PerlIO. Since I never wrapped my brain
around that I am out. First address the author...the combo
Perl5.8.0/64bit/XS might even be interesting enough for the p5porters.
But that's for the author to decide.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Fri, 25 Apr 2003 10:55:42 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@dformosa.zeta.org.au>
Subject: Re: Curses and perl5.8
Message-Id: <slrnbai5at.phe.dformosa@dformosa.zeta.org.au>
On 25 Apr 2003 10:16:42 GMT, Tassilo v. Parseval
<tassilo.parseval@rwth-aachen.de> wrote:
> Also sprach David Formosa (aka ? the Platypus):
[...]
>> cc -c -I/usr/include/ncurses -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -DVERSION=\"1.06\" -DXS_VERSION=\"1.06\" -fpic "-I/usr/local/lib/perl5/5.8.0/i586-linux-thread-multi-64all-ld/CORE" Curses.c
>> Curses.c: In function `c_sv2field':
>> Curses.c:148: warning: cast to pointer from integer of different size
> [...]
>
> That looks like a 32bit versus 64bit issue. Your perl appears to be
> compiled with -Duse64bitint. Line 148 is
>
> if (sv_isa(sv, "Curses::Field")) { return (FIELD*)SvIV((SV*)SvRV(sv)); }
>
> so the IV returned by SvIV is larger than a pointer to FIELD (that is
> what the warning implies).
perl -V
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
[...]
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_64_BIT_INT
USE_LONG_DOUBLE USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
Thank for the spotting of the 64 bit thing. I'm guessing even if it
was able to compile it would get very sick when it ran with these
errors.
> That's the diagnostic part. I have no fix. You should send a message to
> the author of the module and ask him whether he's aware of any such
> problem.
Ok. (Fires up email client)
[...]
>> Curses.c:275: warning: passing arg 1 of `Perl_sv_isa' from incompatible pointer type
>> Curses.c:275: warning: passing arg 2 of `Perl_sv_isa' from incompatible pointer type
>> Curses.c:275: too few arguments to function `Perl_sv_isa'
>
> This is not clear to me at all. The line in question looks fine to me:
>
> if (Perl_sv_isa(sv, "Curses::Window")) {
>
> sv is a proper 'SV*' and the second argument is a 'const char*' as
> described by perlapi.pod.
I'll see if the author knows about this as well.
> These warnings all pertain to PerlIO. Since I never wrapped my brain
> around that I am out. First address the author...the combo
> Perl5.8.0/64bit/XS might even be interesting enough for the p5porters.
> But that's for the author to decide.
(* nods *) Ok.
--
Please excuse my spelling as I suffer from agraphia. See
http://dformosa.zeta.org.au/~dformosa/Spelling.html to find out more.
Free the Memes.
------------------------------
Date: Fri, 25 Apr 2003 07:32:55 +0000
From: Sharon Grant <peakpeek@purethought.com>
Subject: Re: fake flocking on win32
Message-Id: <5pohavcpnhs2uihosrlq3lre5tqrqmj4gd@4ax.com>
On 21 Apr 2003 13:47:13 -0700, in comp.lang.perl.misc, botfood@yahoo.com (dan baker) wrote:
>I'm working on a little web-driven application that will
>use tie()ed hashes for a simple database. So far it looks like a plain
>tie using DB_File
>
>SO, I am thinking that I would "fake" flock functionality
>simplistically by open()ing a temp "lock" file
It has been done:
http://www.cpan.org/modules/by-module/DB_File/DB_File-Lock-0.05.readme
Also you should read the discussions about flock() in the
DB_File documentation. There you will find a reference to
three alternative approaches, including DB_File::Lock
--
Sharon
------------------------------
Date: Fri, 25 Apr 2003 09:44:58 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Getting FULL path+filename from a filehandle
Message-Id: <3EA90383.1FE25CAE@acm.org>
"Michael P. Broida" wrote:
>
> I've been digging through the Camel book and haven't been
> able to find out how to get the FULL path+filename from a
> filehandle.
Assuming that you are running Linux:
my $fullpath = readlink "/proc/$$/fd/" . fileno filehandle;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 25 Apr 2003 18:18:02 +0800
From: "Kenneth" <japh_klch@programmer.net>
Subject: Re: non-blocking read with IO::Select
Message-Id: <3ea90b74@newsgate.imsbiz.com>
Ouch! I forgot about it!
Thank you Tassilo I'll give it a try.
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> ¼¶¼g©ó¶l¥ó
news:b8alo8$qkh$1@nets3.rz.RWTH-Aachen.DE...
>
> WARNING: One should not attempt to mix buffered I/O (like "read"
> or <FH>) with "select", except as permitted by POSIX, and even
> then only on POSIX systems. You have to use "sysread" instead.
>
> So you need unbuffered reading:
>
> while (...) {
> for my $h ($sel->can_read($timeout)) {
> my $data;
> while ($h->sysread(my $buf, 4096) {
> $data .= $buf;
> }
> # do something with $data
> }
> }
>
------------------------------
Date: Fri, 25 Apr 2003 13:18:13 +0100
From: "Robert Horton" <robh@rthorton.freeserve.co.uk>
Subject: Passing reference to a thread
Message-Id: <pan.2003.04.25.12.18.13.572737@rthorton.freeserve.co.uk>
Hi,
I'm experimenting with the Thread module... When I try to pass a reference
(to a hash) into a subroutine, the value appears to be different inside
than that passed (see below). It works fine if I just run the subroutine
normally. Am I doing something really dumb or is there something I don't
know about regarding declaring anonymous data to be passed to a
subroutine?
Any thoughts appreciated - thanks,
Rob.
---------------
#!/usr/bin/perl
use warnings;
use Thread;
my $hashref = {};
sub main{
print $hashref."\n";
my $thread1 = Thread->new(\&addtohash,"Moose","Hello",$hashref);
#addtohash("Moose","Hello2",$hashref);
$thread1->join();
printf("Moose key: %s\n",$$hashref{"Moose"});
}
sub addtohash{
#Takes: key, value, \hash
print $_[2]."\n";
${$_[2]}{$_[0]} = $_[1];
}
main();
exit(0);
----------------
yalumba:~/perl>./sample2.pl
HASH(0x813aa8c)
HASH(0x82188d0)
Use of uninitialized value in printf at ./sample2.pl line 14.
Moose key:
----------------
------------------------------
Date: Fri, 25 Apr 2003 02:22:05 -0500
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
Message-Id: <3DOdnTYIuf-AfzWjXTWcow@august.net>
Outline
Before posting to comp.lang.perl.misc
Must
- Check the Perl Frequently Asked Questions (FAQ)
- Check the other standard Perl docs (*.pod)
Really Really Should
- Lurk for a while before posting
- Search a Usenet archive
If You Like
- Check Other Resources
Posting to comp.lang.perl.misc
Is there a better place to ask your question?
- Question should be about Perl, not about the application area
How to participate (post) in the clpmisc community
- Carefully choose the contents of your Subject header
- Use an effective followup style
- Speak Perl rather than English, when possible
- Ask perl to help you
- Do not re-type Perl code
- Provide enough information
- Do not provide too much information
- Do not post binaries, HTML, or MIME
Social faux pas to avoid
- Asking a Frequently Asked Question
- Asking a question easily answered by a cursory doc search
- Asking for emailed answers
- Beware of saying "doesn't work"
- Sending a "stealth" Cc copy
Be extra cautious when you get upset
- Count to ten before composing a followup when you are upset
- Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------
Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
This newsgroup, commonly called clpmisc, is a technical newsgroup
intended to be used for discussion of Perl related issues (except job
postings), whether it be comments or questions.
As you would expect, clpmisc discussions are usually very technical in
nature and there are conventions for conduct in technical newsgroups
going somewhat beyond those in non-technical newsgroups.
This article describes things that you should, and should not, do to
increase your chances of getting an answer to your Perl question. It is
available in POD, HTML and plain text formats at:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
For more information about netiquette in general, see the "Netiquette
Guidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
A note to newsgroup "regulars":
Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume
A note about technical terms used here:
In this document, we use words like "must" and "should" as
they're used in technical conversation (such as you will
encounter in this newsgroup). When we say that you *must* do
something, we mean that if you don't do that something, then
it's unlikely that you will benefit much from this group.
We're not bossing you around; we're making the point without
lots of words.
Do *NOT* send email to the maintainer of these guidelines. It will be
discarded unread. The guidelines belong to the newsgroup so all
discussion should appear in the newsgroup. I am just the secretary that
writes down the consensus of the group.
Before posting to comp.lang.perl.misc
Must
This section describes things that you *must* do before posting to
clpmisc, in order to maximize your chances of getting meaningful replies
to your inquiry and to avoid getting flamed for being lazy and trying to
have others do your work.
The perl distribution includes documentation that is copied to your hard
drive when you install perl. Also installed is a program for looking
things up in that (and other) documentation named 'perldoc'.
You should either find out where the docs got installed on your system,
or use perldoc to find them for you. Type "perldoc perldoc" to learn how
to use perldoc itself. Type "perldoc perl" to start reading Perl's
standard documentation.
Check the Perl Frequently Asked Questions (FAQ)
Checking the FAQ before posting is required in Big 8 newsgroups in
general, there is nothing clpmisc-specific about this requirement.
You are expected to do this in nearly all newsgroups.
You can use the "-q" switch with perldoc to do a word search of the
questions in the Perl FAQs.
Check the other standard Perl docs (*.pod)
The perl distribution comes with much more documentation than is
available for most other newsgroups, so in clpmisc you should also
see if you can find an answer in the other (non-FAQ) standard docs
before posting.
It is *not* required, or even expected, that you actually *read* all of
Perl's standard docs, only that you spend a few minutes searching them
before posting.
Try doing a word-search in the standard docs for some words/phrases
taken from your problem statement or from your very carefully worded
"Subject:" header.
Really Really Should
This section describes things that you *really should* do before posting
to clpmisc.
Lurk for a while before posting
This is very important and expected in all newsgroups. Lurking means
to monitor a newsgroup for a period to become familiar with local
customs. Each newsgroup has specific customs and rituals. Knowing
these before you participate will help avoid embarrassing social
situations. Consider yourself to be a foreigner at first!
Search a Usenet archive
There are tens of thousands of Perl programmers. It is very likely
that your question has already been asked (and answered). See if you
can find where it has already been answered.
One such searchable archive is:
http://groups.google.com/advanced_group_search
If You Like
This section describes things that you *can* do before posting to
clpmisc.
Check Other Resources
You may want to check in books or on web sites to see if you can
find the answer to your question.
But you need to consider the source of such information: there are a
lot of very poor Perl books and web sites, and several good ones
too, of course.
Posting to comp.lang.perl.misc
There can be 200 messages in clpmisc in a single day. Nobody is going to
read every article. They must decide somehow which articles they are
going to read, and which they will skip.
Your post is in competition with 199 other posts. You need to "win"
before a person who can help you will even read your question.
These sections describe how you can help keep your article from being
one of the "skipped" ones.
Is there a better place to ask your question?
Question should be about Perl, not about the application area
It can be difficult to separate out where your problem really is,
but you should make a conscious effort to post to the most
applicable newsgroup. That is, after all, where you are the most
likely to find the people who know how to answer your question.
Being able to "partition" a problem is an essential skill for
effectively troubleshooting programming problems. If you don't get
that right, you end up looking for answers in the wrong places.
It should be understood that you may not know that the root of your
problem is not Perl-related (the two most frequent ones are CGI and
Operating System related), so off-topic postings will happen from
time to time. Be gracious when someone helps you find a better place
to ask your question by pointing you to a more applicable newsgroup.
How to participate (post) in the clpmisc community
Carefully choose the contents of your Subject header
You have 40 precious characters of Subject to win out and be one of
the posts that gets read. Don't waste them. Take care while
composing them, they are the key that opens the door to getting an
answer.
Spend them indicating what aspect of Perl others will find if they
should decide to read your article.
Do not spend them indicating "experience level" (guru, newbie...).
Do not spend them pleading (please read, urgent, help!...).
Do not spend them on non-Subjects (Perl question, one-word
Subject...)
For more information on choosing a Subject see "Choosing Good
Subject Lines":
http://www.cpan.org/authors/id/D/DM/DMR/subjects.post
Part of the beauty of newsgroup dynamics, is that you can contribute
to the community with your very first post! If your choice of
Subject leads a fellow Perler to find the thread you are starting,
then even asking a question helps us all.
Use an effective followup style
When composing a followup, quote only enough text to establish the
context for the comments that you will add. Always indicate who
wrote the quoted material. Never quote an entire article. Never
quote a .signature (unless that is what you are commenting on).
Intersperse your comments *following* each section of quoted text to
which they relate. Unappreciated followup styles are referred to as
"Jeopardy" (because the answer comes before the question), or
"TOFU".
Reversing the chronology of the dialog makes it much harder to
understand (some folks won't even read it if written in that style).
For more information on quoting style, see:
http://web.presby.edu/~nnqadmin/nnq/nquote.html
Speak Perl rather than English, when possible
Perl is much more precise than natural language. Saying it in Perl
instead will avoid misunderstanding your question or problem.
Do not say: I have variable with "foo\tbar" in it.
Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
or I have $var = <DATA> (and show the data line).
Ask perl to help you
You can ask perl itself to help you find common programming mistakes
by doing two things: enable warnings (perldoc warnings) and enable
"strict"ures (perldoc strict).
You should not bother the hundreds/thousands of readers of the
newsgroup without first seeing if a machine can help you find your
problem. It is demeaning to be asked to do the work of a machine. It
will annoy the readers of your article.
You can look up any of the messages that perl might issue to find
out what the message means and how to resolve the potential mistake
(perldoc perldiag). If you would like perl to look them up for you,
you can put "use diagnostics;" near the top of your program.
Do not re-type Perl code
Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.
Provide enough information
If you do the things in this item, you will have an Extremely Good
chance of getting people to try and help you with your problem!
These features are a really big bonus toward your question winning
out over all of the other posts that you are competing with.
First make a short (less than 20-30 lines) and *complete* program
that illustrates the problem you are having. People should be able
to run your program by copy/pasting the code from your article. (You
will find that doing this step very often reveals your problem
directly. Leading to an answer much more quickly and reliably than
posting to Usenet.)
Describe *precisely* the input to your program. Also provide example
input data for your program. If you need to show file input, use the
__DATA__ token (perldata.pod) to provide the file contents inside of
your Perl program.
Show the output (including the verbatim text of any messages) of
your program.
Describe how you want the output to be different from what you are
getting.
If you have no idea at all of how to code up your situation, be sure
to at least describe the 2 things that you *do* know: input and
desired output.
Do not provide too much information
Do not just post your entire program for debugging. Most especially
do not post someone *else's* entire program.
Do not post binaries, HTML, or MIME
clpmisc is a text only newsgroup. If you have images or binaries
that explain your question, put them in a publically accessible
place (like a Web server) and provide a pointer to that location. If
you include code, cut and paste it directly in the message body.
Don't attach anything to the message. Don't post vcards or HTML.
Many people (and even some Usenet servers) will automatically filter
out such messages. Many people will not be able to easily read your
post. Plain text is something everyone can read.
Social faux pas to avoid
The first two below are symptoms of lots of FAQ asking here in clpmisc.
It happens so often that folks will assume that it is happening yet
again. If you have looked but not found, or found but didn't understand
the docs, say so in your article.
Asking a Frequently Asked Question
It should be understood that you may have missed the applicable FAQ
when you checked, which is not a big deal. But if the Frequently
Asked Question is worded similar to your question, folks will assume
that you did not look at all. Don't become indignant at pointers to
the FAQ, particularly if it solves your problem.
Asking a question easily answered by a cursory doc search
If folks think you have not even tried the obvious step of reading
the docs applicable to your problem, they are likely to become
annoyed.
If you are flamed for not checking when you *did* check, then just
shrug it off (and take the answer that you got).
Asking for emailed answers
Emailed answers benefit one person. Posted answers benefit the
entire community. If folks can take the time to answer your
question, then you can take the time to go get the answer in the
same place where you asked the question.
It is OK to ask for a *copy* of the answer to be emailed, but many
will ignore such requests anyway. If you munge your address, you
should never expect (or ask) to get email in response to a Usenet
post.
Ask the question here, get the answer here (maybe).
Beware of saying "doesn't work"
This is a "red flag" phrase. If you find yourself writing that,
pause and see if you can't describe what is not working without
saying "doesn't work". That is, describe how it is not what you
want.
Sending a "stealth" Cc copy
A "stealth Cc" is when you both email and post a reply without
indicating *in the body* that you are doing so.
Be extra cautious when you get upset
Count to ten before composing a followup when you are upset
This is recommended in all Usenet newsgroups. Here in clpmisc, most
flaming sub-threads are not about any feature of Perl at all! They
are most often for what was seen as a breach of netiquette. If you
have lurked for a bit, then you will know what is expected and won't
make such posts in the first place.
But if you get upset, wait a while before writing your followup. I
recommend waiting at least 30 minutes.
Count to ten after composing and before posting when you are upset
After you have written your followup, wait *another* 30 minutes
before committing yourself by posting it. You cannot take it back
once it has been said.
AUTHOR
Tad McClellan <tadmc@augustmail.com> and many others on the
comp.lang.perl.misc newsgroup.
------------------------------
Date: Fri, 25 Apr 2003 11:45:32 +0200
From: "kderaedt" <kderaedt@hotmail.com>
Subject: Record seperator over lines
Message-Id: <3ea903bd$0$578$ba620e4c@reader1.news.skynet.be>
Hi,
I have a problem with a files where I have different records. The
records can be separated by a new line. How can I eliminate this new line?
See example below.
Content test file: Record seperator is #%#
qmfkjsqfjqmskfdj #%# qsfqsdfqgqsg
qsdfqsdfqs # qsdfqsdfqsdffdqqsdf #%#
Used code for the record seperator:
#!/usr/bin/perl
open (IN, "wsp.out");
open (OUT, "> wsp.new");
local $/ = '#%#';
$a = 0;
while(<IN>) {
$Line = $_;
$a++;
}
close IN;
close OUT;
Output:
1 : qmfkjsqfjqmskfdj #%#
2 : qsfqsdfqgqsg
qsdfqsdfqs # qsdfqsdfqsdffdqqsdf #%#
Should be:
1 : qmfkjsqfjqmskfdj #%#
2 : qsfqsdfqgqsgqsdfqsdfqs # qsdfqsdfqsdffdqqsdf #%#
Thanks
Karel
------------------------------
Date: 25 Apr 2003 09:53:11 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Record seperator over lines
Message-Id: <b8b0i7$955$1@nets3.rz.RWTH-Aachen.DE>
Also sprach kderaedt:
> I have a problem with a files where I have different records. The
> records can be separated by a new line. How can I eliminate this new line?
> See example below.
>
> Content test file: Record seperator is #%#
>
> qmfkjsqfjqmskfdj #%# qsfqsdfqgqsg
> qsdfqsdfqs # qsdfqsdfqsdffdqqsdf #%#
>
> Used code for the record seperator:
> #!/usr/bin/perl
> open (IN, "wsp.out");
> open (OUT, "> wsp.new");
> local $/ = '#%#';
> $a = 0;
> while(<IN>) {
> $Line = $_;
> $a++;
> }
Don't do the copy into $Line. Just use $_ (unless you need a copy, of
course). To get rid of newlines, simply add:
while (<IN>) {
tr/\n//d; # works on $_
...
}
> close IN;
> close OUT;
>
> Output:
> 1 : qmfkjsqfjqmskfdj #%#
> 2 : qsfqsdfqgqsg
> qsdfqsdfqs # qsdfqsdfqsdffdqqsdf #%#
>
>
> Should be:
> 1 : qmfkjsqfjqmskfdj #%#
> 2 : qsfqsdfqgqsgqsdfqsdfqs # qsdfqsdfqsdffdqqsdf #%#
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 25 Apr 2003 05:26:14 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: Regex greediness question
Message-Id: <776e0325.0304250426.4fb5f8d0@posting.google.com>
"Tman" <nerdy1@snet.net> wrote in message news:<Z8Rpa.1172$Hg4.279561317@newssvr10.news.prodigy.com>...
> Am I misunderstanding something here?
>
> C:\Temp>perl -de 1
> .....
> DB<1> p "aaaaaabaaaaa" =~ /a(.*?b.*?)a/
> aaaaab
>
in a regex, would
/(something)*?/
ever be any different than
/(something)*/
Wouldn't both match zero-many sometings?
Just looked odd to me.
-Gx
------------------------------
Date: Fri, 25 Apr 2003 09:23:38 +0100
From: Andrew McGregor <Andrew.McGregor@amtrak.co.uk>
Subject: Re: Session Script
Message-Id: <3EA8F08A.5080602@amtrak.co.uk>
Chris wrote:
> Does anyone know where I can find a sample script storing variables for a
> Session? I found documentation on sessions at cpan.org but didn't see any
> scripts I could try running on my server.
>
> Thanks,
> Chris
>
>
what do you mean by "session"?
if you are talking about cgi then the standard is:
http://stein.cshl.org/WWW/software/CGI/
else maybe something like?
Data::Dumper or the storable module
both modules are compared/described with examples somewhere in the first
few chapters of Perl DBI along with other methods of storing data to disk.
if you are after a very simple way to store a variable then use :
open (FH, ">>$file") or die $!;
print FH "$variable\n";
close FH or warn $!;
...
open(FH, $file) or die $!;
while my $line (<FH>) {
print $line;
}
close FH or warn $!;
------------------------------
Date: Fri, 25 Apr 2003 08:58:03 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <3EA8F883.8EA13EFD@acm.org>
Anno Siegel wrote:
>
> Ethan Brown <ethan@draupnir.gso.saic.com> wrote in comp.lang.perl.misc:
> > >>>>> "Tad" == Tad McClellan <tadmc@augustmail.com> writes:
>
> > >> print join(' ', @RAWDATA[$#RAWDATA - 4 .. $#RAWDATA])
> >
> > Tad> You can add two characters to the 1st one to get spaces between them:
> > Tad> print "@RAWDATA[$#RAWDATA - 4 .. $#RAWDATA]"
> >
> > Nice! I suppose I should have used ', ' so you wouldn't have had such an
> > easy target.
>
> {
> local $, = ', ';
Oh Anno, it is in quotes so changing $, will have no effect.
local $" = ', ';
> print "@RAWDATA[$#RAWDATA - 4 .. $#RAWDATA]";
I'm surprised no one mentioned using negative indexes instead of
$#RAWDATA.
print "@RAWDATA[ -5 .. -1 ]";
John
--
use Perl;
program
fulfillment
------------------------------
Date: 25 Apr 2003 09:17:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <b8aufb$1hc$1@mamenchi.zrz.TU-Berlin.DE>
John W. Krahn <krahnj@acm.org> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> >
> > Ethan Brown <ethan@draupnir.gso.saic.com> wrote in comp.lang.perl.misc:
> > > >>>>> "Tad" == Tad McClellan <tadmc@augustmail.com> writes:
> >
> > > >> print join(' ', @RAWDATA[$#RAWDATA - 4 .. $#RAWDATA])
> > >
> > > Tad> You can add two characters to the 1st one to get spaces
> between them:
> > > Tad> print "@RAWDATA[$#RAWDATA - 4 .. $#RAWDATA]"
> > >
> > > Nice! I suppose I should have used ', ' so you wouldn't have had such an
> > > easy target.
> >
> > {
> > local $, = ', ';
>
> Oh Anno, it is in quotes so changing $, will have no effect.
>
> local $" = ', ';
>
>
> > print "@RAWDATA[$#RAWDATA - 4 .. $#RAWDATA]";
Oh, right. Thanks for catching that.
> I'm surprised no one mentioned using negative indexes instead of
> $#RAWDATA.
>
> print "@RAWDATA[ -5 .. -1 ]";
Someone, somewhere in this rambling thread did, so I didn't want to
bring it up again. I was also dodging the issue whether the first
index has to be -4 or -5 :)
Anno
------------------------------
Date: Fri, 25 Apr 2003 12:46:57 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <20030425.124653.1286966948.18265@richg.zync>
Hi there,
Just to say I didn't ignore your posts yesterday, it's just that we
juggle 3 different dial up accounts here at work to keep connection costs
as low as possible, and yesterday afternoon we just happened to be on the
one which I hadn't set up news for (situation remedied now :-) ).
I would have been happy to help you with the script you posted, however
it seems you're now getting more than enough help from the experts. I
don't know if you realise it, but this thread has attracted at least one
post from nearly everyone who is anyone on this group :-)
Happy Perling
R
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Fri, 25 Apr 2003 12:30:23 GMT
From: TeanerTiner <no-spam-TeanerTiner@hotmail.com>
Subject: Re: Undefining Aggregates
Message-Id: <zT9qa.44778$M_2.35670@twister.nyroc.rr.com>
Anno Siegel wrote:
> TeanerTiner <no-spam-TeanerTiner@hotmail.com> wrote in comp.lang.perl.misc:
>
>>Bill Smith wrote:
>>
>>>"TeanerTiner" <no-spam-TeanerTiner@hotmail.com> wrote in message
>>>news:3RSpa.42259$M_2.32679@twister.nyroc.rr.com...
>>>
>>>
>>>>I have read all the threads concerning undefining aggregates, and I
>>>>understand the reasoning behind them. However, I *really* want to
>>>>undefine a hash so that 'defined(%hash)' is false. I found just this
>>>>exact thing in the Shiny Ball book, page 16. But it does not work in
>>>
>>>my
>>>
>>>
>>>>testing.
>
>
> That's why it is marked "deprecated". "defined( %hash)" just isn't
> a reliable indicator of the state of "%hash".
>
>
>>>--snip--
>>>
>>>When I checked perldoc -f defined (for perl version 5.6.1), I found:
>>>
>>>Use of "defined" on aggregates (hashes and arrays) is deprecated
>>>It used to report whether memory for that aggregate has ever been
>>>allocated. This behavior may disappear in future versions of Perl.
>>>You should instead use a simple test for size:
>>>
>>>
>>>This suggests that 'defined' does not mean exactly what you think, and
>>>that it probably not a good idea to use it in this way.
>>>
>>>Bill
>>>if (@an_array) { print "has array elements\n" }
>>>if (%a_hash) { print "has hash members\n" }
>
>
>
>>Thanks for the reply Bill. However, I do not want to know if the
>>aggregate has members. I want it to not exist, to use the language from
>>perldoc - I want there to be no memory allocated for aggregate and be
>>able to determine that.
>
>
> Well, you want to peek beyond Perl's api, and the lady is pissed.
> Storage allocation is perl's business and not nobody else's.
>
> Your interface seems to be copied from a set of C routines. There it
> makes sense (well, may make sense) to set a pointer to NULL to indicate
> an error. Perl's "undef" isn't NULL, however, and "undef" can play the
> role of NULL only in the domain of scalar variables, not aggregates.
I think you, of all responders, Anno, have hit the nail on the head. I
admittedly code in a more C fashion, sometimes to my detriment.
Furthermore, you give a good explanation as to why this is not an
optimal way to do this.
>
> It's not because we think our methods are superior that we advise
> you not to use this method, it's because we know the language well
> enough to know what works and what doesn't. What you're planning
> isn't a Perl interface, and it's not going to work smoothly.
Thank you for the insight given without the overtones of superiority.
>
> Anno
------------------------------
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 4892
***************************************