[31570] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2829 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 22 09:09:39 2010

Date: Mon, 22 Feb 2010 06:09:22 -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           Mon, 22 Feb 2010     Volume: 11 Number: 2829

Today's topics:
    Re: benchmarks for perl? <bugbear@trim_papermule.co.uk_trim>
        eval exit/exec (was: macros: return or exit) <marc.girod@gmail.com>
    Re: macros: return or exit <marc.girod@gmail.com>
    Re: macros: return or exit <ben@morrow.me.uk>
    Re: macros: return or exit <marc.girod@gmail.com>
    Re: use strict... <source@netcom.com>
    Re: use strict... <tadmc@seesig.invalid>
    Re: use strict... <tadmc@seesig.invalid>
    Re: Using eval to iterate over a set of Perl variables <jurgenex@hotmail.com>
    Re: Using eval to iterate over a set of Perl variables <news@lawshouse.org>
    Re: Using eval to iterate over a set of Perl variables <uri@StemSystems.com>
        Version of http://www.perl.com/doc/manual/html/pod/perl <marc.girod@gmail.com>
    Re: Version of http://www.perl.com/doc/manual/html/pod/ <bart.lateur@telenet.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 22 Feb 2010 10:40:07 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: benchmarks for perl?
Message-Id: <6c-dnVkbWs-awh_WnZ2dnUVZ8uxi4p2d@brightview.co.uk>

Ben Morrow wrote:
> Quoth bugbear <bugbear@trim_papermule.co.uk_trim>:
>> Ben Morrow wrote:
>>> There is perlbench on CPAN, but I believe it's not considered to be as
>>> representative as it used to be.
>> I downloaded this (shortly after my first post).
>> I must be missing something - it only runs 8 tests, none
>> of which look very "general";
>> perl-5.10.0 (DEBUGGING)
>>      @bugbear-dell
>>      app/podhtml                         674.190 ms �-11.429
>>      startup/noprog                      2.484 ms �-2.098
>>      statement/func-call-empty-5arg      1.058 �s �-0.020
>>      statement/func-call-empty-2arg      670.138 ns �-20.012
>>      statement/func-call-empty-1arg      397.798 ns �-7.001
>>      statement/func-call-empty-0arg      215.374 ns �-2.893
>>      statement/assign-int                68.174 ns �-1.229
>>      statement/inc                       46.290 ns �-1.217
>>
>> is there a separate Module of tests, with perlbench being
>> just a harness?
> 
> You're running perlbench-runtests. Try perlbench-run instead, passing it
> paths to several different perl binaries. Obviously this means you have
> to have all the perls you want to compare on the same machine, so you
> can't easily compare, say, perl-on-linux and perl-on-win32. It would be
> very hard to get a meaningful comparison in that case anyway.

That's exactly what I need to do - I need a measure of "perl power"
on various boxes.

You're quite right about perlbench-run - it does EXACTLY
what I want.

     BugBear


------------------------------

Date: Sun, 21 Feb 2010 12:47:34 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: eval exit/exec (was: macros: return or exit)
Message-Id: <a3ed166f-6593-4564-b597-2eaf241fa7d8@f8g2000yqn.googlegroups.com>

On Feb 21, 7:23=A0pm, Marc Girod <marc.gi...@gmail.com> wrote:

> Do I miss something?

May I override *::exit and *::exec with a function doing die?
Or may I only override Package local functions?

a> perl -le '*::exit=3D\$die;$rc =3D eval{exit 25};if($@){print$@}
else{print$rc}'
a> echo $?
25
a> perl -le '*::exec=3D\$die;$rc =3D eval{exec "foo"};if($@){print$@}
else{print$rc}'
0

Marc


------------------------------

Date: Sun, 21 Feb 2010 11:23:40 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: macros: return or exit
Message-Id: <b5c41843-c3d7-4349-b951-920cecfe7ff2@b7g2000yqd.googlegroups.com>

Hello,

I am only now back to this old thread of mine,
and to investigating Uri's suggestion...

On Jan 25, 9:57 am, Marc Girod <marc.gi...@gmail.com> wrote:
> On Jan 24, 8:35 pm, "Uri Guttman" <u...@StemSystems.com> wrote:

> > but longjump in perl is spelled die/eval.

> I can very well investigate this path...

eval deals nicely with die, but not with exit or exec calls.

a> perl -le '$rc = eval{die"foo"};if($@){print$@}else{print$rc}'
foo at -e line 1.

a> perl -le '$rc = eval{exec q(/bin/date)};if($@){print$@}else{print
$rc}'
Sun Feb 21 19:21:49 GMTST 2010
a> perl -le '$rc = eval{exit 25};if($@){print$@}else{print$rc}'
a> echo $?
25

Do I miss something?

Marc



------------------------------

Date: Sun, 21 Feb 2010 23:19:19 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: macros: return or exit
Message-Id: <nkr857-8vr2.ln1@osiris.mauzo.dyndns.org>


Quoth Marc Girod <marc.girod@gmail.com>:
> Hello,
> 
> I am only now back to this old thread of mine,
> and to investigating Uri's suggestion...
> 
> On Jan 25, 9:57 am, Marc Girod <marc.gi...@gmail.com> wrote:
> > On Jan 24, 8:35 pm, "Uri Guttman" <u...@StemSystems.com> wrote:
> 
> > > but longjump in perl is spelled die/eval.
> 
> > I can very well investigate this path...
> 
> eval deals nicely with die, but not with exit or exec calls.

A piece of reusable code shouldn't normally call exit or exec (except
after a fork). What is the actual problem you are trying to solve?

Ben



------------------------------

Date: Mon, 22 Feb 2010 02:23:43 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: macros: return or exit
Message-Id: <7e3caa95-23b9-411f-9a89-297074794526@b7g2000yqd.googlegroups.com>

On Feb 21, 11:19=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:

> A piece of reusable code shouldn't normally call exit or exec (except
> after a fork). What is the actual problem you are trying to solve?

I am trying to reuse a piece of code which has not been
designed to be reused in that way.
It is a wrapper around a proprietary tool, giving
command line access to a database.
The original tool is mostly used to run one-shot
commands, but it also has a mode in which it stays up
and reads commands in a loop. This mode is convenient
to start the tool in the background, and feed it with
multiple commands.
This comes handy to the kind of enhancements I want to
implement in my own wrapper, which need to perform
numerous database accesses, and gain in performance by
not having to initialize and finalize the tool for
each of them.

Now, I write my wrapper using a framework designed for
this purpose, but not supporting the 'shell' function
described above. So wrappers written so far using this
framework have been emulating the tool in one-shot
commands, but not in the ability to install itself in
the background.

I wish my wrapper to overcome this limitation.

Now, the frustration in describing what intentions
comes from the tool being proprietary, which results
in the fact that I assume you (perl gurus) could not
in general run the code examples I could give.

The database is IBM Rational ClearCase.
The CLI tool is cleartool.
The CPAN perl package giving access to cleartool is
ClearCase::Argv (itself using Argv, and IPC::Open3
among others).
The CPAN wrapper infrastructure is ClearCase::Wrapper.
My own CPAN wrapper is ClearCase::Wrapper::MGi.

The changes I try to implement are for
ClearCase::Wrapper to support the latter, and would
go more specifically to cleartool.plx.

Does this help you to consider my questions?

Thanks,
Marc


------------------------------

Date: Sun, 21 Feb 2010 09:01:18 -0800
From: David Harmon <source@netcom.com>
Subject: Re: use strict...
Message-Id: <McadnQIr_b2I-hzWnZ2dnUVZ_rednZ2d@earthlink.com>

On Mon, 15 Feb 2010 19:33:44 -0800 in comp.lang.perl.misc,
merlyn@stonehenge.com (Randal L. Schwartz) wrote,
>>>>>> "Robin" == Robin  <robin1@cnsp.com> writes:
>
>Robin> I know this is a pretty stupid question, maybe, but is it better to
>Robin> use strict? I have never gotten a concise answer to this question
>Robin> because there reallty isn't any docs on it.
>
>    % perldoc strict
[...]
>
>You have a strange meaning of "isn't any".  Care to elaborate?

Doesn't exactly say whether "use strict" is better or not, though.  
If it is generally regarded as better, perhaps "use strict" should be
the default with "no strict" to override it if necessary (ever?)


------------------------------

Date: Sun, 21 Feb 2010 11:15:28 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: use strict...
Message-Id: <slrnho2qai.6u7.tadmc@tadbox.sbcglobal.net>

David Harmon <source@netcom.com> wrote:

>perhaps "use strict" should be
> the default 


That would break many existing programs.

That would be not nice at all!



Have you seen the BUGS section in "perldoc perl"?

(-w (similar to "use warnings") being off by default is a known "bug")


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"


------------------------------

Date: Sun, 21 Feb 2010 11:22:31 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: use strict...
Message-Id: <slrnho2qno.6u7.tadmc@tadbox.sbcglobal.net>

David Harmon <source@netcom.com> wrote:
> On Mon, 15 Feb 2010 19:33:44 -0800 in comp.lang.perl.misc,
> merlyn@stonehenge.com (Randal L. Schwartz) wrote,
>>>>>>> "Robin" == Robin  <robin1@cnsp.com> writes:
>>
>>Robin> I know this is a pretty stupid question, maybe, but is it better to
>>Robin> use strict? 


better than what?


>>Robin>I have never gotten a concise answer to this question
>>Robin> because there reallty isn't any docs on it.
>>
>>    % perldoc strict
> [...]
>>
>>You have a strange meaning of "isn't any".  Care to elaborate?
>
> Doesn't exactly say whether "use strict" is better or not, though.  


Oh.

Then you want the 2nd paragraph of

    perldoc perlstyle

        ... You should also always run under C<use strict> or know the
        reason why not. 

Since Robin (and, I assume, you) do not know why you would _not_ use strict, 
you _should_ use strict.  :-)


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"


------------------------------

Date: Sun, 21 Feb 2010 09:29:45 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Using eval to iterate over a set of Perl variables
Message-Id: <b5r2o5thn1nurgnnbmu0h3935rijmuvn96@4ax.com>

Henry Law <news@lawshouse.org> wrote:
>I'm inserting new records into a MYSQL database using Perl DBI.  There 
>are fourteen fields, each one of which has its corresponding variable in 
>my program.  I want to execute the "bind_param" method for each one of 
>them.  If you're not familiar with DBI here's an example of what I might 
>code:
>   $sth->bind_param( 1, $message_id );
>   $sth->bind_param( 2, $from_name );
>   ...
>   $sth->bind_param( 14, $body );
>
>Ugly.  So I have a list of those variable names, thus
>   my @variable_name_list = ( '$message_id', '$from_name', ...

Whenever you feel the urge to use a string as a variable name you should
seriously consider using a hash instead.

	my %myvars;

>and I have a loop with a counter, like this
>   for ( my $i = 1; $i<=14; $i++ ) {
>       eval{ $ins_sth->bind_param( $i, $variable_name_list[$i-1] ) };

	$ins_sth->bind_param( $i, $myvars{$variable_name_list[$i-1] })

jue


------------------------------

Date: Sun, 21 Feb 2010 17:41:32 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: Using eval to iterate over a set of Perl variables
Message-Id: <I72dnXmK7O_V7RzWnZ2dnUVZ8lpi4p2d@giganews.com>

Jürgen Exner wrote:
> Whenever you feel the urge to use a string as a variable name you should
> seriously consider using a hash instead.

Jürgen, Tad and the Doctor all on my case ... I stand corrected and will 
re-write it at once.  Thank you all.

-- 

Henry Law            Manchester, England


------------------------------

Date: Sun, 21 Feb 2010 22:45:45 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Using eval to iterate over a set of Perl variables
Message-Id: <87pr3yvspi.fsf@quad.sysarch.com>

>>>>> "HL" == Henry Law <news@lawshouse.org> writes:

  HL> Jürgen Exner wrote:
  >> Whenever you feel the urge to use a string as a variable name you should
  >> seriously consider using a hash instead.

  HL> Jürgen, Tad and the Doctor all on my case ... I stand corrected and
  HL> will re-write it at once.  Thank you all.

add me to that list. using a hash is always better than symrefs. my rule
is only use symrefs when you want to mung the symbol table. never use it
for data structures. a hash is meant for data and is actually faster
than symrefs as it doesn't do all the symbol table stuff that symrefs
need.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Sun, 21 Feb 2010 13:17:53 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Version of http://www.perl.com/doc/manual/html/pod/perlsub.html
Message-Id: <89207f99-cd64-4407-8a84-abe9eb1345c6@k19g2000yqc.googlegroups.com>

Hello,

I was discussing the use of: 'local *_' with a friend, and he noticed
that it is not mentioned in
http://www.perl.com/doc/manual/html/pod/perlsub.html
whereas it is in my local v5.10.1 installation:

       Localization of globs

       Notably, if you want to work with a brand new value of the
default
       scalar $_, and avoid the potential problem listed above about
$_
       previously carrying a magic value, you should use "local *_"
instead of
       "local $_".  As of perl 5.9.1, you can also use the lexical
form of $_
       (declaring it with "my $_"), which avoids completely this
problem.

Which one is newer?
Sure... this wasn't removed on purpose?

Thanks,
Marc


------------------------------

Date: Mon, 22 Feb 2010 13:19:08 +0100
From: Bart Lateur <bart.lateur@telenet.be>
Subject: Re: Version of http://www.perl.com/doc/manual/html/pod/perlsub.html
Message-Id: <ret4o5d52ccv7q8qk1s1l3hhikrjal8boo@4ax.com>

Marc Girod wrote:

>[...] he noticed
>that it is not mentioned in
>http://www.perl.com/doc/manual/html/pod/perlsub.html
>whereas it is in my local v5.10.1 installation:

>Which one is newer?
>Sure... this wasn't removed on purpose?

You may be sure that the docs for 5.10.x are the newest. And I'm not
surprised that www.perl.com is running a bit behind... as it no longer
even has a dedicated webmaster.

-- 
	Bart.


------------------------------

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 2829
***************************************


home help back first fref pref prev next nref lref last post