[30084] in Perl-Users-Digest
Perl-Users Digest, Issue: 1327 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 2 21:09:43 2008
Date: Sun, 2 Mar 2008 18:09:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 2 Mar 2008 Volume: 11 Number: 1327
Today's topics:
Re: "negative" regexp (David Combs)
Best way to distribute program with modules <january.weiner@gmail.com>
Re: Best way to distribute program with modules <ben@morrow.me.uk>
Re: Converting "’" to an Apostrophe? <nospam-abuse@ilyaz.org>
Re: Converting "’" to an Apostrophe? <stoupa@practisoft.cz>
Crypt::CBC vs individual cipher module differs? <wgumgfy@gmail.com>
Re: FAQ 4.53 How do I manipulate arrays of bits? sheinrich@my-deja.com
Re: killing the children <jurgenex@hotmail.com>
Re: killing the children xhoster@gmail.com
Re: killing the children <savagebeaste@yahoo.com>
Re: killing the children xhoster@gmail.com
Re: killing the children <savagebeaste@yahoo.com>
Re: Modules, global variables and such <january.weiner@gmail.com>
package_name->new(); a basic language queston <drubnone@yahoo.com>
Re: package_name->new(); a basic language queston sheinrich@my-deja.com
Re: package_name->new(); a basic language queston <drubnone@yahoo.com>
Re: package_name->new(); a basic language queston xhoster@gmail.com
php vs perl for RDBMS backend work dcruncher4@aim.com
Re: php vs perl for RDBMS backend work <jstucklex@attglobal.net>
Re: unsetenv in the shell xhoster@gmail.com
Re: unsetenv in the shell <uri@stemsystems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 3 Mar 2008 01:41:46 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: "negative" regexp
Message-Id: <fqfl0q$eep$1@reader2.panix.com>
In article <fnuujf.1f8.1@news.isolution.nl>,
Dr.Ruud <rvtol+news@isolution.nl> wrote:
>Petr Vileta schreef:
>
>> Example for convert any basic html page to plain text.
>
>Use "|links -dump" as a filter.
Or lynx? (although it does not understand javascript)
Question: does links?
Thanks
David
>
>--
>Affijn, Ruud
>
>"Gewoon is een tijger."
------------------------------
Date: Mon, 3 Mar 2008 01:10:46 +0100 (CET)
From: January Weiner <january.weiner@gmail.com>
Subject: Best way to distribute program with modules
Message-Id: <fqffm6$mcn$2@sagnix.uni-muenster.de>
Hi,
I have written quite a complex (at least for me) program of >10k lines of
code, packed in a main file and a dozen modules. While I am writing up the
publication (yep, it's a scientific program), I am wondering, what would be
the best way to package it.
Specifically, I would like to make the installation for the user as
painless as possible. Right now I write something along the lines "move
the Xxx directory into /usr/local/lib/site_perl or any other apropriate
directory with Perl modules", but this is hardly satisfactory.
I really have no experience with that, and regretfully, I will not have
time to devote a lot of attention to proper packaging, because other issues
around the publication are more pressing. Is there anything simple I could
do? I know I could use the PAR module (actually, I use pp to create
binaries), but I would much prefer to have a simple "clever" installer script.
Best regards,
January
------------------------------
Date: Mon, 3 Mar 2008 00:25:18 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Best way to distribute program with modules
Message-Id: <e4tr95-iv3.ln1@osiris.mauzo.dyndns.org>
Quoth January Weiner <january.weiner@gmail.com>:
> Hi,
>
> I have written quite a complex (at least for me) program of >10k lines of
> code, packed in a main file and a dozen modules. While I am writing up the
> publication (yep, it's a scientific program), I am wondering, what would be
> the best way to package it.
>
> Specifically, I would like to make the installation for the user as
> painless as possible. Right now I write something along the lines "move
> the Xxx directory into /usr/local/lib/site_perl or any other apropriate
> directory with Perl modules", but this is hardly satisfactory.
Is there something wrong with creating a CPAN-style distribution?
'tar -xzvf $TAR; perl Makefile.PL; make test; make install' is fairly
simple, or even simpler 'cpan -i pip; pip $TAR'.
Ben
------------------------------
Date: Sun, 2 Mar 2008 22:20:07 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Converting "’" to an Apostrophe?
Message-Id: <fqf96n$26v5$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Gunnar Hjalmarsson
<noreply@gunnar.cc>], who wrote in article <62vbniF23uf7cU2@mid.individual.net>:
> >>> perldoc perlop
> >>>
> >>> s Treat string as single line. (Make . match a newline)
> >> Great, that's a clarification I wasn't aware of.
> >
> > In which way it is a clarification?
>
> Compared to the previous perlop versions, where the part within
> parentheses was not there.
As I said, I do not see this change as an improvement; for me, it is
"an empty change". When I see such a statement, what I think is
yet another piece of vague ambiguous `conversational' English;
hence, it is DESIGNED to be a very ROUGH overview, and is not
designed to convey any precise information; I'm SUPPOSED TO
DISREGARD whatever it says since the purpose is just to instill a
warm fuzzy feeling in the reader.
Maybe other people read documentation differently, but in my practice,
such an approach usually gives quite good result.
[Unfortunately, this approach does not work with Perl docs; some
pieces are written in a very precise English, and STILL are wrong if
trusted to be true (i.e., the design is to instill a warm fuzzy
feeling).]
Hope this helps,
Ilya
------------------------------
Date: Mon, 3 Mar 2008 02:42:51 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: Converting "’" to an Apostrophe?
Message-Id: <fqflav$2n2k$1@ns.felk.cvut.cz>
Uri Guttman wrote:
>> "PV" == Petr Vileta <stoupa@practisoft.cz> writes:
>> Hmm, but try this
>
>> my $string = "foo\n’\nbar";
>> $string =~ s/’/'/g;
>> print "$string\n";
>> __END__
>
>> prints:
>> foo
>> '
>> bar
>
>> This is perl, v5.6.1 built for MSWin32-x86-multi-thread
>> (with 1 registered patch, see perl -V for more detail)
>
> and where is the bug in that result?
Sorry, I wrote my mess late at night ;-) The true print was to have been
foo
’
bar
In other word the substitution failed.
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>
------------------------------
Date: Sun, 2 Mar 2008 16:01:42 -0800
From: "Waylen Gumbal" <wgumgfy@gmail.com>
Subject: Crypt::CBC vs individual cipher module differs?
Message-Id: <630tf8F24ghl8U1@mid.individual.net>
I noticed that if I use a "CBC compatible" crypt module directly, I get
a normal expected result. But if I use CBC with the same cipher type on
the same key and plaintext I get a completely different result.
I've been up and down the perldoc for Crypt::CBC and just can't figure
out why the results differ so much. Because they differ so much you
can't use one method to decrypt the other.
For example:
use Crypt::CBC;
use Crypt::OpenSSL::AES;
$key = 'secretpassphrase';
$text = 'Crypt Test #0001';
my $en1 = new Crypt::OpenSSL::AES($key)->encrypt($text);
my $en2 = new Crypt::CBC(
-key => $key, -cipher => 'Crypt::OpenSSL::AES'
)->encrypt($text);
my $en1h = unpack('H*', $en1);
my $en2h = unpack('H*', $en2);
print "OpenSSL AES\n[$en1h]\n\n";
print "AES via CBC\n[$en2h]\n\n";
__OUTPUT__
OpenSSL AES
[e1f461cdc00f4855b9b2c0367cd3a293]
AES via CBC
[53616c7465645f5f36dd0b8d9b84e278382b8cd329f7020b545c3595c239284d37d4e3dc2d6a2fc97d375675b793b357]
Thanks.
--
WG
------------------------------
Date: Sun, 2 Mar 2008 06:41:25 -0800 (PST)
From: sheinrich@my-deja.com
Subject: Re: FAQ 4.53 How do I manipulate arrays of bits?
Message-Id: <ca334bbf-a028-4179-bcac-6fe5105b1376@13g2000hsb.googlegroups.com>
On Feb 29, 9:03 pm, PerlFAQ Server <br...@stonehenge.com> wrote:
<snip>
> For example, this sets $vec to have bit N set if $ints[N] was set:
>
> $vec = '';
> foreach(@ints) { vec($vec,$_,1) = 1 }
>
<snip>
IMHO the above sentence is wrong.
It'd rather say
'For example, this sets $vec to have bit N set if N is element of
@ints'.
my @ints = ();
$ints[5] = 1;
$ints[0] = 1;
$ints[2] = 1;
$ints[4] = 1;
my $vec = '';
foreach(@ints) { vec($vec,$_,1) = 1 }
print unpack('b*', $vec), "\n";
>test.pl
11000000
(plus warnings about values being uninitialized)
my @ints = (5,0,2,4);
my $vec = '';
foreach(@ints) { vec($vec,$_,1) = 1 }
print unpack('b*', $vec), "\n";
>test2.pl
10101100
Steffen
------------------------------
Date: Sun, 02 Mar 2008 14:27:56 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: killing the children
Message-Id: <36els3dp6o23rvntad7ln9fmmuogn27jk0@4ax.com>
lekonna <lekonna@gmail.com> wrote:
>i'm having a bit of a problem here with the exec functionality. I seem
>to be unable to kill the children of my process.
>
>Am i actually execing a command shell instance that then starts the
>program as child and my kill hangs there?
Well, there's your problem. Your kill() is killing the shell (which at that
time is probably dead already anyway) but not the children of the shell.
You need a way to identify/kill the grandchildren of the perl process,
maybe by killing the process tree of the shell or have the shell return the
ID of it's own children or something like that.
jue
------------------------------
Date: 02 Mar 2008 23:28:23 GMT
From: xhoster@gmail.com
Subject: Re: killing the children
Message-Id: <20080302182826.178$s3@newsreader.com>
lekonna <lekonna@gmail.com> wrote:
> Hi guys,
>
> i'm having a bit of a problem here with the exec functionality. I seem
> to be unable to kill the children of my process. Hope you can help me
> with this one.
>
> I'm doing a client-server setup where the server requests the clients
> to start instances of a certain application and now the bugger doesn't
> seem to die properly. The code in nutshell is here, i'll eliminate my
> crappy message handling and just quote the handler funcs:
You should include enough of the other stuff to make it actually runnable.
my $my_command="perl";
my @my_args=('-le', 'warn $$; sleep 2; warn $$');
$pid = fork;
if ( $pid == 0 )
{
exec( $my_command,@my_args) or die "can't do it Jim!";
} else {
$jobs{$pid} = $my_args[0];
}
sleep 1;
foreach ( keys( %jobs ) )
{
warn "killing $_";
kill 9,$_;
}
sleep 3;
__END__
On Linux, the second warn $$ never gets executed because that child has
already been killed. On Windows, sometimes it works that way and sometimes
it doesn't. An example of one of the times it doesn't:
H:\perl_misc>perl kill.pl
2364 at -e line 1.
killing -3872 at kill.pl line 16.
2364 at -e line 1.
> What happens is that the exec starts the program properly and returns
> a pid. the kill however seems to be unable
> to do anything to the program that is executed, it just keeps
> running.
>
> Am i actually execing a command shell instance that then starts the
> program as child and my kill hangs there?
You shouldn't be, since you are using the list form of exec. On Windows,
lords knows what might be going on.
>
> At the moment coding in Win32 environment but the code should port to
> linux/osX as well.
Good luck with that.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Sun, 2 Mar 2008 16:20:04 -0800
From: "C. Lumina" <savagebeaste@yahoo.com>
Subject: Re: killing the children
Message-Id: <630uhlF24vbp9U1@mid.individual.net>
lekonna wrote:
> Hi guys,
>
> i'm having a bit of a problem here with the exec functionality. I seem
> to be unable to kill the children of my process. Hope you can help me
> with this one.
I must say, perhaps you could of chosen a better wording for the subject
line!
Best way I take care of situations like this is to maintain a list of
any children created by the parent and make sure they get raped properly
on exit.
-CL
------------------------------
Date: 03 Mar 2008 00:36:13 GMT
From: xhoster@gmail.com
Subject: Re: killing the children
Message-Id: <20080302193616.764$Ba@newsreader.com>
"C. Lumina" <savagebeaste@yahoo.com> wrote:
> lekonna wrote:
> > Hi guys,
> >
> > i'm having a bit of a problem here with the exec functionality. I seem
> > to be unable to kill the children of my process. Hope you can help me
> > with this one.
>
> I must say, perhaps you could of chosen a better wording for the subject
> line!
>
> Best way I take care of situations like this is to maintain a list of
> any children created by the parent and make sure they get raped properly
> on exit.
Talk about unfortunate choice of words!
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Sun, 2 Mar 2008 17:00:26 -0800
From: "C. Lumina" <savagebeaste@yahoo.com>
Subject: Re: killing the children
Message-Id: <6310tcF25caepU1@mid.individual.net>
xhoster@gmail.com wrote:
> "C. Lumina" <savagebeaste@yahoo.com> wrote:
>> lekonna wrote:
>>> Hi guys,
>>>
>>> i'm having a bit of a problem here with the exec functionality. I
>>> seem to be unable to kill the children of my process. Hope you can
>>> help me with this one.
>>
>> I must say, perhaps you could of chosen a better wording for the
>> subject line!
>>
>> Best way I take care of situations like this is to maintain a list of
>> any children created by the parent and make sure they get raped
>> properly on exit.
>
> Talk about unfortunate choice of words!
AK! Geeze that was a horrible one on my part. (I of course meant to
write "reaped".)
-CL
------------------------------
Date: Mon, 3 Mar 2008 00:27:01 +0100 (CET)
From: January Weiner <january.weiner@gmail.com>
Subject: Re: Modules, global variables and such
Message-Id: <fqfd45$mcn$1@sagnix.uni-muenster.de>
Thanks for all the answers, I learned a lot. I now use $::DEBUG for my
purposes.
Cheers,
j.
------------------------------
Date: Sun, 2 Mar 2008 08:12:39 -0800 (PST)
From: werwer <drubnone@yahoo.com>
Subject: package_name->new(); a basic language queston
Message-Id: <e7fbbd78-e5ff-46b4-b9a1-07f331b32fb1@s12g2000prg.googlegroups.com>
This isn't about PerlSAX, but a package construct I found there in an
example using the module. I have no idea what's going on here so I'm
guessing. This appears in the code
my $handler = SaxHandler->new();
But there is no SaxHandler anywhere in the documentation ..... but
wait! Later in the code the author defines a package as in
package SaxHandler;
and in this package are subroutines with names of the callbacks, the
SAX event handling routines, that SAX will call for each different XML
event (starting ending new final ....)
I had no idea a package name could be used in such a fashion. I
appreciate some short discussion of what's going on. Thanks.
------------------------------
Date: Sun, 2 Mar 2008 08:20:21 -0800 (PST)
From: sheinrich@my-deja.com
Subject: Re: package_name->new(); a basic language queston
Message-Id: <cbf954bd-39ab-4f73-a013-5d9005513956@s8g2000prg.googlegroups.com>
On Mar 2, 5:12 pm, werwer <drubn...@yahoo.com> wrote:
> This isn't about PerlSAX, but a package construct I found there in an
> example using the module. I have no idea what's going on here so I'm
> guessing. This appears in the code
>
> my $handler = SaxHandler->new();
>
> But there is no SaxHandler anywhere in the documentation ..... but
> wait! Later in the code the author defines a package as in
>
> package SaxHandler;
>
> and in this package are subroutines with names of the callbacks, the
> SAX event handling routines, that SAX will call for each different XML
> event (starting ending new final ....)
>
> I had no idea a package name could be used in such a fashion. I
> appreciate some short discussion of what's going on. Thanks.
Welcome to the world of OOP!
:-))
perldoc perltoot
would be one of many possible places to start with.
Cheers, Steffen
------------------------------
Date: Sun, 2 Mar 2008 08:28:50 -0800 (PST)
From: werwer <drubnone@yahoo.com>
Subject: Re: package_name->new(); a basic language queston
Message-Id: <a38645fe-4e3d-4b04-b9c8-667b0f3c434a@d21g2000prf.googlegroups.com>
> Welcome to the world of OOP!
> :-))
>
> perldoc perltoot
>
> would be one of many possible places to start with.
>
> Cheers, Steffen
Ahhhh.... yes yes. Thanks. I had never seen it done that way. It
was always in a different file. Ok, makes a some sense now. Damn,
I'm getting old.
------------------------------
Date: 02 Mar 2008 23:33:06 GMT
From: xhoster@gmail.com
Subject: Re: package_name->new(); a basic language queston
Message-Id: <20080302183309.215$ym@newsreader.com>
werwer <drubnone@yahoo.com> wrote:
> This isn't about PerlSAX, but a package construct I found there in an
> example using the module. I have no idea what's going on here so I'm
> guessing. This appears in the code
>
> my $handler = SaxHandler->new();
>
> But there is no SaxHandler anywhere in the documentation ..... but
> wait! Later in the code the author defines a package as in
>
> package SaxHandler;
>
> and in this package are subroutines with names of the callbacks, the
> SAX event handling routines, that SAX will call for each different XML
> event (starting ending new final ....)
>
> I had no idea a package name could be used in such a fashion. I
> appreciate some short discussion of what's going on. Thanks.
It probably just means that the author didn't think SaxHandler would be of
general enough interest to make it a stand-alone module. It is roughly
like an "Inner class" in Java.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: 2 Mar 2008 10:27:05 -0800
From: dcruncher4@aim.com
Subject: php vs perl for RDBMS backend work
Message-Id: <fqerhp01uas@drn.newsguy.com>
Hi,
I would like to get an opinion on using php vs perl for backend
database related work. This is basically a script for nightly batch jobs
which reads from different databases and write to databases.
So far I have used perl/DBI for this.
I am looking into the possibility of using php for the same, if it
provides any significant benefit in code maintenance etc.
TIA.
------------------------------
Date: Sun, 02 Mar 2008 14:59:32 -0500
From: Jerry Stuckle <jstucklex@attglobal.net>
Subject: Re: php vs perl for RDBMS backend work
Message-Id: <o8ednQljEdyhklbanZ2dnUVZ_rvinZ2d@comcast.com>
dcruncher4@aim.com wrote:
> Hi,
>
> I would like to get an opinion on using php vs perl for backend
> database related work. This is basically a script for nightly batch jobs
> which reads from different databases and write to databases.
> So far I have used perl/DBI for this.
>
> I am looking into the possibility of using php for the same, if it
> provides any significant benefit in code maintenance etc.
>
> TIA.
>
>
Both are just languages. Neither one has any particular advantage in
maintenance, etc. It much more depends on the programmers who write the
code, how well the code is written and commented, the skills of the
people maintaining the code, and a bunch of other things.
And if it's working now, I see no reason to invest a bunch of time and
money rewriting it. Don't fix what isn't broke.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
------------------------------
Date: 03 Mar 2008 00:00:04 GMT
From: xhoster@gmail.com
Subject: Re: unsetenv in the shell
Message-Id: <20080302190007.393$QG@newsreader.com>
Si <smcbutler@gmail.com> wrote:
> hi, i have a perl program that calls another application. this second
> application uses the value of certain environment variables during its
> operation. i'm having trouble with unsetting those variables during
> the course of the perl script.
>
> my (wrong) pseudo code:
>
> $var1 = $ENV{'VAR1};
> $var2 = $ENV{'VAR2'};
> $var3 = $ENV{'VAR3'};
>
> system( "unsetenv VAR1");
> system( "unsetenv VAR2");
> system( "unsetenv VAR3");
>
> run_the_external_app;
>
> system( "setenv VAR1 $var1");
> system( "setenv VAR2 $var2");
> system( "setenv VAR3 $var3");
>
> can someone tell me what the correct syntax should be for this?
Others have explained why this doesn't work. By adding an extra scope
and a local, you can avoid having to explicitly store the old values.
{
my @del=qw/VAR1 VAR2 VAR3/;
local %ENV{@del};
delete %ENV{@del};
run_the_external_app;
};
Once the outer scope exits, the variables will automatically be reset.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Mon, 03 Mar 2008 00:14:37 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: unsetenv in the shell
Message-Id: <x763w4y87l.fsf@mail.sysarch.com>
>>>>> "x" == xhoster <xhoster@gmail.com> writes:
x> Others have explained why this doesn't work. By adding an extra scope
x> and a local, you can avoid having to explicitly store the old values.
x> {
x> my @del=qw/VAR1 VAR2 VAR3/;
x> local %ENV{@del};
x> delete %ENV{@del};
technically those should be @ENV{@del} as they are hash slices. but i
think perl allows % there.
x> Once the outer scope exits, the variables will automatically be reset.
definitely the best way to do this.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Architecture, Development, Training, Support, Code Review ------
----------- Search or Offer Perl Jobs ----- http://jobs.perl.org ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 1327
***************************************