[29640] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 884 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 26 21:09:39 2007

Date: Wed, 26 Sep 2007 18:09:06 -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           Wed, 26 Sep 2007     Volume: 11 Number: 884

Today's topics:
    Re: add error to an array or list or hash <rsarpi@gmail.com>
    Re: add error to an array or list or hash <ebmarquez@gmail.com>
    Re: add error to an array or list or hash <rsarpi@gmail.com>
    Re: add error to an array or list or hash <ebmarquez@gmail.com>
    Re: How to set a COM Object property to TRUE <kevindotcar@gmail.com>
    Re: string concatentation vs. interpolation: which one  <simon.chao@fmr.com>
    Re: string concatentation vs. interpolation: which one  <bik.mido@tiscalinet.it>
    Re: string concatentation vs. interpolation: which one  <bik.mido@tiscalinet.it>
    Re: string concatentation vs. interpolation: which one  <asolkar@gmail.com>
    Re: string concatentation vs. interpolation: which one  <ben@morrow.me.uk>
    Re: string concatentation vs. interpolation: which one  <wahab@chemie.uni-halle.de>
    Re: string concatentation vs. interpolation: which one  <bik.mido@tiscalinet.it>
    Re: string concatentation vs. interpolation: which one  <bik.mido@tiscalinet.it>
    Re: string concatentation vs. interpolation: which one  <bik.mido@tiscalinet.it>
    Re: string concatentation vs. interpolation: which one  <bik.mido@tiscalinet.it>
        tail recursion (was: Re: why are references so slow ?) <rvtol+news@isolution.nl>
    Re: tail recursion (was: Re: why are references so slow <bik.mido@tiscalinet.it>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 26 Sep 2007 20:30:32 -0000
From:  monk <rsarpi@gmail.com>
Subject: Re: add error to an array or list or hash
Message-Id: <1190838632.426621.210180@22g2000hsm.googlegroups.com>

> open(test.txt, /home/monk) or $myErrorHash{'Error'} = $!;

Right on.  Yeah..thanks.

I guess after I gather all the possible errors throughout the program,
I would like to fully identify each one of them uniquely.

Now in your experience, Do you recommend using arrays, hashes, or
lists? or just references {a=>b}?



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

Date: Wed, 26 Sep 2007 20:44:42 -0000
From:  ebm <ebmarquez@gmail.com>
Subject: Re: add error to an array or list or hash
Message-Id: <1190839482.875279.92370@57g2000hsv.googlegroups.com>

On Sep 26, 1:30 pm, monk <rsa...@gmail.com> wrote:
> > open(test.txt, /home/monk) or $myErrorHash{'Error'} = $!;
>
> Right on.  Yeah..thanks.
>
> I guess after I gather all the possible errors throughout the program,
> I would like to fully identify each one of them uniquely.
>
> Now in your experience, Do you recommend using arrays, hashes, or
> lists? or just references {a=>b}?

It would really depend on what your doing.  I normally just capture to
a string and pass it to subroutine that will log the problem then die.

open(.....) or Error("Didn't want to open: $!\n","ERROR") && die;
my Error sub would send out an email alert depending if it's a Warning
or Error and write to a logs file.



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

Date: Wed, 26 Sep 2007 21:56:18 -0000
From:  monk <rsarpi@gmail.com>
Subject: Re: add error to an array or list or hash
Message-Id: <1190843778.207782.89400@50g2000hsm.googlegroups.com>

> open(.....) or Error("Didn't want to open: $!\n","ERROR") && die;
> my Error sub would send out an email alert depending if it's a Warning
> or Error and write to a logs file.

Thanks a lot ebm.

>my Error sub would send out an email alert [..]
   ooo..ahhhh....I like that.

My original idea was to create a hash or array with a pile of error
messages, reference the messages to the real $! error, and send that
variable value as a subject/body in an email.

But I'd like to see how your idea ties in all together. It seems
simpler.
Do you have that error subroutine you mention?

Thanks again.








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

Date: Wed, 26 Sep 2007 23:33:41 -0000
From:  ebm <ebmarquez@gmail.com>
Subject: Re: add error to an array or list or hash
Message-Id: <1190849621.421829.138390@r29g2000hsg.googlegroups.com>

On Sep 26, 2:56 pm, monk <rsa...@gmail.com> wrote:
> > open(.....) or Error("Didn't want to open: $!\n","ERROR") && die;
> > my Error sub would send out an email alert depending if it's a Warning
> > or Error and write to a logs file.
>
> Thanks a lot ebm.
>
> >my Error sub would send out an email alert [..]
>
>    ooo..ahhhh....I like that.
>
> My original idea was to create a hash or array with a pile of error
> messages, reference the messages to the real $! error, and send that
> variable value as a subject/body in an email.
>
> But I'd like to see how your idea ties in all together. It seems
> simpler.
> Do you have that error subroutine you mention?
>
> Thanks again.

This should set you up.
enjoy!

use Net::SMTP;
use Time::Local;
use File::Path;
use Sys::Hostname;

$critical_email = 'critical@example.com';
$warning_email = 'warning@example.com';
$smtp='mail.example.com';
$from_email='user@example.com';

=pod

=item error($errorType, $subject, $description)

Checks to see if it's a criticality and send email message

 Input: Error Type, Subject of Error, Description of Error
 Return: True (1), False (0)

  error("CRITICAL","Some Subject","Details");
  error("WARNING","Some Subject","Details");

=cut

sub error{
  my ($type,$event,$description) = @_;


  chomp ($type, $event, $description);
  logEvent("");
  logEvent("$type\t$event \t$description\tServer: ".hostname);
  print STDERR "$type\t$event \t$description\tServer: ".hostname;

  if(uc($type) eq "CRITICAL"){
    alertEmail( $critical_email,"LogMover CRITICAL \n$event","CRITICAL
$description\nServer: ".hostname);
    return 1;
  }elsif(uc($type) eq "WARNING"){
    alertEmail($warning_email,"LogMover WARNING \n$event", "WARNING
$description\nServer: ".hostname);
    return 1;
  }
  return 0;
}

=pod

=item checkPath($path)

check that the path exists, Return boolean


  if( checkPath( $path ) ){ print "path exists" }

=cut

sub checkPath{
  my($path) = @_; # directory path
  #check the path exists
  if( -e $path ){
      return 1;
  }
return 0;
}

=pod

=item logEvent($event)

Log an event to the harvester log, this will request the time for each
entry

 Input: Event String
 Return: True (1)

 logEvent("Something to log");

=cut

sub logEvent{
  my ($event) = @_;                  # event line for the log
  chomp($event);

  #setup log dir
  checkPath("Logs") or mkpath("Logs");

  my($month, $day, $year, $hrminsec) = todayDate(0);
  my $LOG = 'Logs/'. $year.$month.$day . '.log';
  open(LOG,">>$LOG" ) ||
        die("CRITICAL". "unable to open $LOG","unable to open $LOG
$!");

  print(LOG "$month/$day/$year $hrminsec\t ". $event . "\n");
  close(LOG);
  return 1;
}

=pod

=item alertEmail($toAddressFromConfig, $subject, $messageBody)

Email error message

 Input: Address to send message to, Subject, Description of email
 Return: N/A

  alertEmail('to@example.com',"Some Subject","Details");

=cut

sub alertEmail{
  my ($to,$subject,$messageBody) = @_;
  chomp($to, $subject, $messageBody );


  my $smtp = Net::SMTP->new($smtp, Debug => 0 );
  $smtp->mail($from_email});
  $smtp->to($to);
  $smtp->datasend("\r\n");
  $smtp->data();
  $smtp->datasend("To: $to\n");
  $smtp->datasend("From: ".$from_email."\n");
  $smtp->datasend("Subject: $subject\r\n");
  $smtp->datasend("\r\n");
  $smtp->datasend("$messageBody\r\n");
  $smtp->data();
  $smtp->dataend();
  $smtp->quit();
  return 1;
}



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

Date: Wed, 26 Sep 2007 14:25:48 -0700
From:  kevincar <kevindotcar@gmail.com>
Subject: Re: How to set a COM Object property to TRUE
Message-Id: <1190841948.383382.57700@d55g2000hsg.googlegroups.com>

Hi-

On Sep 25, 1:03 pm, bmw...@gmail.com wrote:
> Hello,
>
> I am trying to set a WIN32 COM Object bool property true to enable a
> validation option.
>
> I can do it in VB like so.
>
 [---]
>
> Can anyone help?

A little code snippet that works for me;

use strict;
use Win32::OLE;
use Win32::OLE::Variant;
use constant FALSE => Variant( VT_BOOL, 0);
use constant TRUE  => Variant( VT_BOOL, 1);

 ... and depending upon the COM object's coding, you might have to set
the property like:

$crRpt->Invoke("YOUROBJPROPERYNAME", FALSE);

 ...or
$crRpt->Options->SetProperty("YOUROBJPROPERYNAME", FALSE);


All the best, HTH

KC





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

Date: Wed, 26 Sep 2007 20:17:44 -0000
From:  it_says_BALLS_on_your forehead <simon.chao@fmr.com>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <1190837864.944460.88530@w3g2000hsg.googlegroups.com>

On Sep 26, 3:46 pm, Mahesh Asolkar <asol...@gmail.com> wrote:
> On Sep 26, 9:42 am, rihad <ri...@mail.ru> wrote:
>
> > Programming Perl (The Camel Book) states that "String concatenation is
> > also implied by the interpolation that happens in double-quoted
> > strings."
>
> > print $a . ' is equal to ' . $b . ".\n";    # dot operator
> > print "$a is equal to $b.\n";               # interpolation
>
> > Can someone experienced in Perl source code confirm that they are
> > identical in terms of raw speed and memory use or not? The second one
> > is much cooler, and if so, I'm going to get rid of concatenation
> > altogether. (I'm not even considering the list variant separated by
> > commas, which is suboptimal).
> >From the benchmark below, it looks like interpolation and
>
> concatenation come pretty close.
>
> -------------------
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> no warnings 'syntax';
>
> use Benchmark qw 'cmpthese';
>
> cmpthese 2000000 => {
>     'interp'   => '$x=$y=303; $z = "$x $y"',
>     'concat'   => '$x=$y=303; $z = $x . " " . $y',
>     'listjn'   => '$x=$y=303; $z = $x," ",$y',
>
> };
>
> -------------- Results -------------------
>
>             Rate concat interp listjn
> concat 1428571/s     --    -1%   -56%
> interp 1438849/s     1%     --   -56%
> listjn 3278689/s   130%   128%     --
> ------------------
>

This is different than the tests the other posters conducted in that
you are not printing anything, and I don't think your listjn is doing
what you think it is.



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

Date: Wed, 26 Sep 2007 22:38:51 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <hkglf39ht5g7b3shpln3o6gjsfh203o0l6@4ax.com>

On Wed, 26 Sep 2007 09:42:11 -0700, rihad <rihad@mail.ru> wrote:

>Subject: string concatentation vs. interpolation: which one is more optimal?

Something can't be "more optimal" than something else. Perhaps
"optimized"?

>print $a . ' is equal to ' . $b . ".\n";    # dot operator
>print "$a is equal to $b.\n";               # interpolation

You forget

print $a, ' is equal to ', $b, ".\n";    # print() takes a list

>Can someone experienced in Perl source code confirm that they are
>identical in terms of raw speed and memory use or not? The second one
>is much cooler, and if so, I'm going to get rid of concatenation
>altogether. (I'm not even considering the list variant separated by
>commas, which is suboptimal).

Do you *really* care?!? I agree that sometimes it *is* worth to look
at optimizations, but if you have performance problems, then the
printing of a short thing is highly likely *not* to be the cause of
them, and if it is, then you'd better switch to a faster language
altogether.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 26 Sep 2007 22:41:24 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <3tglf3tc27igel6ua7n48mirdbm56c0klu@4ax.com>

On Wed, 26 Sep 2007 12:46:32 -0700, Mahesh Asolkar <asolkar@gmail.com>
wrote:

>cmpthese 2000000 => {
>    'interp'   => '$x=$y=303; $z = "$x $y"',
>    'concat'   => '$x=$y=303; $z = $x . " " . $y',
>    'listjn'   => '$x=$y=303; $z = $x," ",$y',

The last entry does something completely different altogether, because
the list is evaluated in scalar context, whereas in print() it's in
list context.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 26 Sep 2007 14:28:52 -0700
From:  Mahesh Asolkar <asolkar@gmail.com>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <1190842132.891939.9540@n39g2000hsh.googlegroups.com>

On Sep 26, 1:41 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On Wed, 26 Sep 2007 12:46:32 -0700, Mahesh Asolkar <asol...@gmail.com>
> wrote:
>
> >cmpthese 2000000 => {
> >    'interp'   => '$x=$y=303; $z = "$x $y"',
> >    'concat'   => '$x=$y=303; $z = $x . " " . $y',
> >    'listjn'   => '$x=$y=303; $z = $x," ",$y',
>
> The last entry does something completely different altogether, because
> the list is evaluated in scalar context, whereas in print() it's in
> list context.
>

Michele and it_says_BALLS_on_your forehead, yes listjn is really quite
different from what the OP wanted. I was trying to isolate performance
of concatenation and interpolation operations from the IO overhead of
print - if at all. I did not pay attention on the side effect on
listjn. My apologies.

/Mahesh.



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

Date: Wed, 26 Sep 2007 22:27:56 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <sfvqs4-b8b.ln1@osiris.mauzo.dyndns.org>


Quoth Michele Dondi <bik.mido@tiscalinet.it>:
> On Wed, 26 Sep 2007 09:42:11 -0700, rihad <rihad@mail.ru> wrote:
> 
> >Subject: string concatentation vs. interpolation: which one is more optimal?
> 
> Something can't be "more optimal" than something else. Perhaps
> "optimized"?

Yes it can. 'more optimal' implies 'better, in an absolute sense',
whereas 'more optimized' would imply 'has been improved more'. That is,
if you have A which executes 10 times a second and B which executes 20
times, and you improve this to A executing 15 times and B executing 21
times, then A is 'more optimized' than B even though B is still 'more
optimal' than A. (Did that make any sense? :) )

> >print $a . ' is equal to ' . $b . ".\n";    # dot operator
> >print "$a is equal to $b.\n";               # interpolation
> 
> You forget
> 
> print $a, ' is equal to ', $b, ".\n";    # print() takes a list

He(?) mentioned that he had already discarded this case.

> >Can someone experienced in Perl source code confirm that they are
> >identical in terms of raw speed and memory use or not? The second one
> >is much cooler, and if so, I'm going to get rid of concatenation
> >altogether. (I'm not even considering the list variant separated by
> >commas, which is suboptimal).
> 
> Do you *really* care?!? I agree that sometimes it *is* worth to look
> at optimizations, but if you have performance problems, then the
> printing of a short thing is highly likely *not* to be the cause of
> them, and if it is, then you'd better switch to a faster language
> altogether.

While I couldn't agree more, in the interests of answering the question
asked:

    ~% perl -MO=Concise -e'$a . " foo " . $b'
    8  <@> leave[1 ref] vKP/REFC ->(end)
    1     <0> enter ->2
    2     <;> nextstate(main 1 -e:1) v ->3
    7     <2> concat[t2] vKS/2 ->8
    5        <2> concat[t1] sK/2 ->6
    -           <1> ex-rv2sv sK/1 ->4
    3              <$> gvsv(*a) s ->4
    4           <$> const(PV " foo ") s ->5
    -        <1> ex-rv2sv sK/1 ->7
    6           <$> gvsv(*b) s ->7
    -e syntax OK
    ~% perl -MO=Concise -e'"$a foo $b"'
    8  <@> leave[1 ref] vKP/REFC ->(end)
    1     <0> enter ->2
    2     <;> nextstate(main 1 -e:1) v ->3
    -     <1> ex-stringify vK/1 ->8
    -        <0> ex-pushmark s ->3
    7        <2> concat[t2] sKS/2 ->8
    5           <2> concat[t1] sK/2 ->6
    -              <1> ex-rv2sv sK/1 ->4
    3                 <$> gvsv(*a) s ->4
    4              <$> const(PV " foo ") s ->5
    -           <1> ex-rv2sv sK/1 ->7
    6              <$> gvsv(*b) s ->7
    -e syntax OK

The ex-foo ops are those that have been optimized away, so they compile
to exactly the same optree, so have exactly the same performance. Any
differences found elsewhere in the thread are errors in benchmarking.

Ben



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

Date: Wed, 26 Sep 2007 23:59:56 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <fdeklc$f88$1@nserver.hrz.tu-freiberg.de>

it_says_BALLS_on_your forehead wrote:
> bash-2.03$ time perl -e '$x=$y=303; print $x," ",$y for 1..16777216'
>> /dev/null
> 
> real    1m18.498s
> user    1m18.310s
> sys     0m0.073s
> 
> MUCH slower for some reason...thoughts?

Interesting.

Seems to hang on perl stdout, consider ...
(taken from the other thread):
=>

  use Benchmark qw 'cmpthese';
  our $fh;
  open $fh, '>', '/dev/null' or die $!;
  cmpthese 2000000 => {
     #'spinterp'   => '$x=$y=303; $z = sprintf "%s", "$x $y"',
     #'spconcat'   => '$x=$y=303; $z = sprintf "%s", $x . " " . $y',
     #'spLISTjn'   => '$x=$y=303; $z = sprintf "%s", $x, " ", $y',
     #'spJOINjn'   => '$x=$y=303; $z = sprintf "%s", join("", $x," ",$y)',

      'printerp'   => '$x=$y=303; $z = print   $fh   "$x $y"',
      'prconcat'   => '$x=$y=303; $z = print   $fh   $x . " " . $y',
      'prLISTjn'   => '$x=$y=303; $z = print   $fh   $x," ",$y' ,
      'prJOINjn'   => '$x=$y=303; $z = print   $fh   join("", $x, " ", $y)',
  };
  close $fh;
<=

will give (here):

                Rate prJOINjn prconcat printerp prLISTjn
  prJOINjn 1298701/s       --     -12%     -24%     -34%
  prconcat 1481481/s      14%       --     -13%     -24%
  printerp 1709402/s      32%      15%       --     -13%
  prLISTjn 1960784/s      51%      32%      15%       --


"List" seems to be always fastest w/all print
varieties, except when going through stdio?

Regards

M.


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

Date: Thu, 27 Sep 2007 00:07:44 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <74hlf3pd9fbqh5flr7kq1pb1v1a9tdj8op@4ax.com>

On Wed, 26 Sep 2007 19:16:16 +0200, papahuhn <papahuhn@gmx.net> wrote:

>time perl -e '$a=$b=303; print "$a $b" for 1..39999999' > /dev/null
>real    0m14.500s
>user    0m14.460s
>sys     0m0.022s
>
>time perl -e '$a=$b=303; print $a." ".$b for 1..39999999' > /dev/null
>
>real    0m12.111s
>user    0m12.081s
>sys     0m0.014s

I think that using time is simply not reliable enough. Benchmark.pm is
not perfect either, but could come closer. I adapted another poster's
script as follows:

  pilsner:~ [22:54:10]$ cat bench.pl
  #!/usr/bin/perl
  
  use strict;
  use warnings;
  no warnings 'once';
  
  use Benchmark qw/cmpthese :hireswallclock/;
  
  open F, '>/dev/null' or die;
  
  cmpthese -20 => {
          'interp' => '$x=$y=303; print F "$x $y"',
          'concat' => '$x=$y=303; print F $x . " " . $y',
          'listjn' => '$x=$y=303; print F $x," ",$y',
  };
  
  __END__
  pilsner:~ [22:54:19]$ perl bench.pl
             Rate interp concat listjn
  interp 770456/s     --    -0%    -2%
  concat 773664/s     0%     --    -1%
  listjn 783474/s     2%     1%     --


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 27 Sep 2007 00:35:45 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <alnlf35jvug6sqfsdjlb8msonrjvs4pa48@4ax.com>

On Wed, 26 Sep 2007 23:59:56 +0200, Mirco Wahab
<wahab@chemie.uni-halle.de> wrote:

>"List" seems to be always fastest w/all print
>varieties, except when going through stdio?

Maybe one needs to $++?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 27 Sep 2007 00:38:13 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <ennlf39sf7akn939ruevje033tgsthcqsm@4ax.com>

On Wed, 26 Sep 2007 14:28:52 -0700, Mahesh Asolkar <asolkar@gmail.com>
wrote:

>Michele and it_says_BALLS_on_your forehead, yes listjn is really quite
>different from what the OP wanted. I was trying to isolate performance
>of concatenation and interpolation operations from the IO overhead of
>print - if at all. I did not pay attention on the side effect on
>listjn. My apologies.

(No need to apologize, you didn't offend anyone!) But you *can't*, for
the print() does the actual concatenation we're interested into.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 27 Sep 2007 01:02:16 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <fvnlf35j1m94jf9las8ljb5k3k3sd1tc2k@4ax.com>

On Wed, 26 Sep 2007 22:27:56 +0100, Ben Morrow <ben@morrow.me.uk>
wrote:

>Quoth Michele Dondi <bik.mido@tiscalinet.it>:
>> Something can't be "more optimal" than something else. Perhaps
>> "optimized"?
>
>Yes it can. 'more optimal' implies 'better, in an absolute sense',
>whereas 'more optimized' would imply 'has been improved more'. That is,
>if you have A which executes 10 times a second and B which executes 20
>times, and you improve this to A executing 15 times and B executing 21
>times, then A is 'more optimized' than B even though B is still 'more
>optimal' than A. (Did that make any sense? :) )

Well, "optimal" is an adjective of clear latin descent. In Italian it
maps to "ottimale" which is somewhat a variant (with a slightly
restricted acceptation) of "ottimo" (best) which in turn is the
superlative of "buono" (good) and IMHO still has attached the sense of
a superlative. I don't know if in English it's the same or I'm simply
biased by Italian grammar, but...

(/me realizes that he can check dict to be sure -\|/-\|/-\|/-\|/)

no, it seems it's the same in English:

: From The Collaborative International Dictionary of English v.0.48 :
: 
:   optimal \op"ti*mal\, a.
:      Best possible; most desirable; optimum; as, the optimal
:      concentration of a drug.
:      [PJC]
: 
: 
: From WordNet (r) 2.0 :
: 
:   optimal
:        adj : most desirable possible under a restriction expressed or
:              implied; "an optimum return on capital"; "optimal
:              concentration of a drug" [syn: optimum]

[other two entries snipped, but the concept is the same]

So to say that something is "more optimal" (than something else) is
like saying that something is "more best" (than something else). To
me, it's not correct.

>> print $a, ' is equal to ', $b, ".\n";    # print() takes a list
>
>He(?) mentioned that he had already discarded this case.

Sorry, didn't notice. Apologies to the OP.

>> Do you *really* care?!? I agree that sometimes it *is* worth to look
>> at optimizations, but if you have performance problems, then the
>> printing of a short thing is highly likely *not* to be the cause of
>> them, and if it is, then you'd better switch to a faster language
>> altogether.
>
>While I couldn't agree more, in the interests of answering the question
>asked:
>
>    ~% perl -MO=Concise -e'$a . " foo " . $b'
[snip]
>The ex-foo ops are those that have been optimized away, so they compile
>to exactly the same optree, so have exactly the same performance. Any
>differences found elsewhere in the thread are errors in benchmarking.

Very instructive, thanks!


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 26 Sep 2007 23:06:29 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: tail recursion (was: Re: why are references so slow ?)
Message-Id: <fdeoog.1fg.1@news.isolution.nl>

Michele Dondi schreef:

> (Mostly as an aside) if the recursion can be cast in the form of tail
> recursion than much hassle can be eliminated, but existing perls
> unfortunately don't handle it natively so one has to take care of that
> "manually" with *magic* goto()s.

Can you show an example?

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Thu, 27 Sep 2007 01:14:24 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: tail recursion (was: Re: why are references so slow ?)
Message-Id: <amplf35nh8l60cf8u9vdcaduatct4r58f3@4ax.com>

On Wed, 26 Sep 2007 23:06:29 +0200, "Dr.Ruud"
<rvtol+news@isolution.nl> wrote:

>Michele Dondi schreef:
>
>> (Mostly as an aside) if the recursion can be cast in the form of tail
>> recursion than much hassle can be eliminated, but existing perls
>> unfortunately don't handle it natively so one has to take care of that
>> "manually" with *magic* goto()s.
>
>Can you show an example?

It's surely discussed in HOP, but I don't know if it's online yet. No,
it isn't - see <http://hop.perl.plover.com/>. Then there's a free
online book (ongoing work as of when I bookmarked it) available at
<http://billhails.net/Book/> which talks about it, with examples, at
<http://billhails.net/Book/interpreter-0-0-10.html#tail-recursion>.


HTH,
Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

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 884
**************************************


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