[29642] in Perl-Users-Digest
Perl-Users Digest, Issue: 886 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 27 18:09:50 2007
Date: Thu, 27 Sep 2007 15:09:09 -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 Thu, 27 Sep 2007 Volume: 11 Number: 886
Today's topics:
Re: [OT] optimal vs. optimized <helmut@wollmersdorfer.at>
Re: [OT] optimal vs. optimized <brian.d.foy@gmail.com>
Re: add error to an array or list or hash <tadmc@seesig.invalid>
Re: add error to an array or list or hash (Greg Bacon)
Re: Invalid top directory at d:\perl\lib\file\find.pm l <m@rtij.nl.invlalid>
Regex confusion... <guthrie@mum.edu>
Re: Regex confusion... <guthrie@mum.edu>
Re: Regex confusion... <Narthring@gmail.com>
Re: Regex confusion... <dummy@example.com>
Re: Regex confusion... <guthrie@mum.edu>
Re: Report to Event Viewer correctly using Win32::Event <nobull67@gmail.com>
Re: Report to Event Viewer correctly using Win32::Event <ebmarquez@gmail.com>
Re: Small doubt in perl <bik.mido@tiscalinet.it>
SOAP timing out <perl4hire@softouch.on.ca>
Re: string concatentation vs. interpolation: which one <rihad@mail.ru>
Re: string concatentation vs. interpolation: which one <brian.d.foy@gmail.com>
Re: tail recursion (was: Re: why are references so slow (Greg Bacon)
Re: tail recursion <uri@stemsystems.com>
Re: why are references so slow ? <brian.d.foy@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 27 Sep 2007 20:56:42 +0200
From: Helmut Wollmersdorfer <helmut@wollmersdorfer.at>
Subject: Re: [OT] optimal vs. optimized
Message-Id: <fdgudb$1d6k$1@geiz-ist-geil.priv.at>
Ben Morrow wrote:
> I think what has happened is that, in English, 'optimal' and
> 'optimized' have acquired something of a sense of 'efficient',
Both are meaningless.
I always try to exchange 'optimize' by 'maximize' or 'minimize', e.g.
- minimize runtime
- minimize memory usage
- maximize execution rate
- maximize readability
- maximize test coverage
Helmut Wollmersdorfer
------------------------------
Date: Thu, 27 Sep 2007 16:13:32 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: [OT] optimal vs. optimized
Message-Id: <270920071613323421%brian.d.foy@gmail.com>
In article <fdgudb$1d6k$1@geiz-ist-geil.priv.at>, Helmut Wollmersdorfer
<helmut@wollmersdorfer.at> wrote:
> Ben Morrow wrote:
> > I think what has happened is that, in English, 'optimal' and
> > 'optimized' have acquired something of a sense of 'efficient',
> Both are meaningless.
>
> I always try to exchange 'optimize' by 'maximize' or 'minimize', e.g.
>
> - minimize runtime
> - minimize memory usage
> - maximize execution rate
well, minimize and maximize work well for single dimensions, but when
you get into multi-dimensional concerns (say, memoery and speed), you
can't use those terms that well anymore. In the memory-speed surface
there will points where one or the other dimension are better, some
local minimums, and so on, but the optimal solution might not be the
one that has the absolute minumum for either of the factors.
I like "optimal" still, but people have to realize that it's a relative
and subjective term based on the assumptions and goals of the person
using it. It's not meaningless although it is often used without
context and with the implicit asumptions that everyone wants the same
thing. :)
------------------------------
Date: Wed, 26 Sep 2007 19:16:16 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: add error to an array or list or hash
Message-Id: <slrnffltig.5va.tadmc@tadmc30.sbcglobal.net>
monk <rsarpi@gmail.com> wrote:
> open (test.txt, /home/monk) or die $!;
You should put quotes around strings in Perl programs.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Thu, 27 Sep 2007 21:48:25 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: add error to an array or list or hash
Message-Id: <13fo999qgg4n2fc@corp.supernews.com>
In article <1190835465.990643.167840@w3g2000hsg.googlegroups.com>,
monk <rsarpi@gmail.com> wrote:
: Hi all, and thanks in advance.
:
: for example:
:
: open (test.txt, /home/monk) or die $!;
: blah blah blah
:
: If it dies $!, How can I output/add that error to an array or hash or
: list?
Something like the following?
#! /usr/bin/perl
use warnings;
use strict;
my @errors;
for (qw( /foo/bar /baz/quux )) {
if (open my $fh, "<", $_) {
while (<$fh>) {
print if /42/;
}
}
else {
push @errors, "open $_: $!\n";
}
}
warn @errors if @errors;
Hope this helps,
Greg
--
The possession of arms is the distinction between a freeman and a slave.
-- James Burgh
------------------------------
Date: Thu, 27 Sep 2007 13:10:24 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Invalid top directory at d:\perl\lib\file\find.pm line 562
Message-Id: <pan.2007.09.27.11.01.38@rtij.nl.invlalid>
On Thu, 27 Sep 2007 09:02:29 +0000, Perler wrote:
> Hi, i am using the following script to find a file entered by a user.
Not tested, just some general comments about the code.
use strict;
use warnings;
Don't ever post a script here without strict and warnings enabled. You'll
find a lot of errors yourself if you enable them, no need to ask the
group to solve problems you could have solved yourself.
>
> use Win32::DriveInfo;
> use File::Find;
>
> my @drives = Win32::DriveInfo::DrivesInUse(); #Get the drives on a
> Machine
>
> my $cnt=@drives; #Number of Drives
>
> my $i=$cnt; #Counter assignment
>
> #The following loop appends "/" to the drive letter #if the drive is
> a
> fixed drive.
>
> for($i;$i>0;$i--)
> {
> $type=Win32::DriveInfo::DriveType($drives[$i-1]); if($type==3)#fixed
> drives
> {
> $d[$i-1]=$drives[$i-1].":"."\\","\\";
> }
> }
Ouch. What is that comma there? ^^^^.
Also, array @d will have "holes" as you don't assign the entries that are
not corresponding to a fixed drive.
The concatenation is also not elegant, ":"."\\" is better written as ":\
\".
I would try something like:
my @d;
for (@drives) {
push @d, "$_:\\"
if Win32::DriveInfo::DriveType($_) == 3;
}
>
> $temp=$ARGV[0]; #store filename to be found
Very bad variable name. Also missing 'my'.
>
> my @t=split(/\./,$temp); #Split the filename to get the extension
>
> my $cnt=@t;
>
> $f=".".$t[$cnt-1]; #Append "." and extension
Very bad variable name.
my $extension = $tmp;
$extension =~ s/.*\././;
>
> find(\&cleanup,@d); #standard file find function
>
> sub cleanup {
>
> if ((/$f/))#$f= appneding "." and file extension for eg:
> $f=.pl,$f=.txt
I don't grok this comment at all. Also,m this will produce false
positives. ITYM
if (/$f$/)
> {
> $path=$File::Find::name; #$path will contain the
> complete
> path of a file
>
> @p=split(/\//,$path); #just get the file name
The filename is also in $_ here, no need to get it this way.
>
> $cnt=@p;
> if($p[$cnt-1] eq $temp)
> {
> print "\n File Found",$path;
> }
>
>
>
> }
>
> }
>
>
> If i run this script i am getting the error as "Invalid top directory
> at
> d:\perl\lib\file\find.pm line 562, <DATA> line164"
>
First make it run with strict and warnings enabled. Than put in some
print statements to confirm the variables contain what you think they
contain.
Also, this can be done much more simple. No need to check the extension.
It's part of the filename. Completely redundant. Get rid of all the
extension handling stuff. Something along these lines (untested):
use strict;
use warnings;
use Win32::DriveInfo;
use File::Find;
if (@ARGV != 1) {
die "usage:...";
}
my $file2find = $ARGV[0];
my @drives;
for (Win32::DriveInfo::DrivesInUse()) {
push @drives, "$_:\\"
if Win32::DriveInfo::DriveType($_) == 3;
}
find(\&cleanup,@drives); #standard file find function
sub cleanup {
if ($_ eq $file2find) {
my $path=$File::Find::name;
print "File Found: $path\n";
}
}
HTH,
M4
------------------------------
Date: Thu, 27 Sep 2007 20:42:22 -0000
From: guthrie <guthrie@mum.edu>
Subject: Regex confusion...
Message-Id: <1190925742.068294.244860@50g2000hsm.googlegroups.com>
sorry for the beginner question, but...
With this code
my $img = "0-12345-abc";
print " Match.1 ", (defined $img);
print " Match.2 ", ($img =~ /\S/);
print " Matched::", $1;
print " Match.3 ", ($img =~ /^(\d)-(\d+)-(\w)$/);
print " Matched::", $1, ", ", $2, ", ", $3;
I expected:
true, true, "012345-abc", true,
and then: 0, 12345, abc
Instead I get:
true true "" false
"" "" ""
Actually: img= (0-52557-wind)
Match.1 1 Match.2 1 Matched::
Match.3 Matched::, ,
Seems simple enough, what am I missing!
- why doesn't the full string first match against /\S/ return the
string
- why doesn't the second (extracting) match work.
The actual code I'm trying for is:
if(defined $img and $img =~ /\S/) {
if ($img =~ /^(\d)-(\d+)-(\w)$/)
{ my ($t, $zip, $type) = ($1, $2, $3); }
else { die "ERROR: invalid URL arguments :: ${img}\n";}
print "Debug: (", $t, ", ", $zip, ", ", $type, ")\n"; ##
Debug...
Thanks for any hints. Sorry for the confusion!
Greg
------------------------------
Date: Thu, 27 Sep 2007 20:59:20 -0000
From: guthrie <guthrie@mum.edu>
Subject: Re: Regex confusion...
Message-Id: <1190926760.455710.47960@k79g2000hse.googlegroups.com>
Oops, small correction;
> With this code
> my $img = "0-12345-abc";
> print " Match.1 ", (defined $img);
> print " Match.2 ", ($img =~ /\S/);
> print " Matched::", $&;
print " pre-Matched::", $`, "\n";
print " post-Matched::", $', "\n";
I get::
Match.1 1 Match.2 1 Matched::0
pre-Matched::
post-Matched::-52557-wind
I expected:
pre="", match="0-12345-abc", post=""
------------------------------
Date: Thu, 27 Sep 2007 14:02:41 -0700
From: Narthring <Narthring@gmail.com>
Subject: Re: Regex confusion...
Message-Id: <1190926961.517267.100050@d55g2000hsg.googlegroups.com>
On Sep 27, 3:42 pm, guthrie <guth...@mum.edu> wrote:
> sorry for the beginner question, but...
>
> With this code
> my $img = "0-12345-abc";
> print " Match.1 ", (defined $img);
> print " Match.2 ", ($img =~ /\S/);
> print " Matched::", $1;
> print " Match.3 ", ($img =~ /^(\d)-(\d+)-(\w)$/);
> print " Matched::", $1, ", ", $2, ", ", $3;
> I expected:
> true, true, "012345-abc", true,
> and then: 0, 12345, abc
>
> Instead I get:
> true true "" false
> "" "" ""
>
> Actually: img= (0-52557-wind)
> Match.1 1 Match.2 1 Matched::
> Match.3 Matched::, ,
>
> Seems simple enough, what am I missing!
> - why doesn't the full string first match against /\S/ return the
> string
> - why doesn't the second (extracting) match work.
>
> The actual code I'm trying for is:
> if(defined $img and $img =~ /\S/) {
> if ($img =~ /^(\d)-(\d+)-(\w)$/)
> { my ($t, $zip, $type) = ($1, $2, $3); }
> else { die "ERROR: invalid URL arguments :: ${img}\n";}
> print "Debug: (", $t, ", ", $zip, ", ", $type, ")\n"; ##
> Debug...
>
> Thanks for any hints. Sorry for the confusion!
> Greg
$img =~ /^(\d)-(\d+)-(\w+)$/
\w matches a single 'word' character, not an entire word.
------------------------------
Date: Thu, 27 Sep 2007 21:05:24 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: Regex confusion...
Message-Id: <oWUKi.20284$nO3.3617@edtnps90>
guthrie wrote:
> sorry for the beginner question, but...
>
> With this code
> my $img = "0-12345-abc";
> print " Match.1 ", (defined $img);
> print " Match.2 ", ($img =~ /\S/);
> print " Matched::", $1;
> print " Match.3 ", ($img =~ /^(\d)-(\d+)-(\w)$/);
> print " Matched::", $1, ", ", $2, ", ", $3;
> I expected:
> true, true, "012345-abc", true,
> and then: 0, 12345, abc
>
> Instead I get:
> true true "" false
> "" "" ""
>
> Actually: img= (0-52557-wind)
> Match.1 1 Match.2 1 Matched::
> Match.3 Matched::, ,
>
> Seems simple enough, what am I missing!
> - why doesn't the full string first match against /\S/ return the
> string
The character class \S matches a single character so it can't match the full
string. The expression ($img =~ /\S/) will only return "true" or "false"
because you don't use the /g global option and/or you don't have any capturing
parentheses in the pattern.
> - why doesn't the second (extracting) match work.
Because the pattern /^(\d)-(\d+)-(\w)$/ doesn't match the string
'0-52557-wind'. -(\w)$ will only match one character between a hyphen and
the end of the line but your string has four characters (wind) between the
hyphen and the end of the line.
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Thu, 27 Sep 2007 21:40:32 -0000
From: guthrie <guthrie@mum.edu>
Subject: Re: Regex confusion...
Message-Id: <1190929232.112669.300350@g4g2000hsf.googlegroups.com>
-- Many thanks, very silly of me.
I thought these were word & space matches, not just a single
character.
I did (mis-) read the documentation several times! :-)
Thanks again.
Greg
------------------------------
Date: Thu, 27 Sep 2007 17:56:59 -0000
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: Report to Event Viewer correctly using Win32::EventLog
Message-Id: <1190915819.802258.171130@k79g2000hse.googlegroups.com>
On Sep 26, 7:58 pm, ebm <ebmarq...@gmail.com> wrote:
> I'm writing a script that will run as a scheduled task on a win2k
> server. I would like the script to log to the Event Viewer on the
> server but when I use the Win32::EventLog module I get a bunch of
> garbage included in the Event that I log.
Actually if you read this "garbage" you'll realise that it's not in
the event that you log. It is a message that's being generated from
the Event Viewer program.
Windows events are not just plain text, they are an array of strings
that are used to populate a template and that template is looked up by
some mechanism using the event source and the event ID.
> Is there a away to do this with so I don't get the garbage...
Almost certainly but this question as nothing to do with Perl, the
answer would be the same however you log an event in Windows. Really,
therefore, you should try a forum that deals with Windows-related
questions.
However a quick Google search turned up these:
http://www.codeproject.com/dotnet/evtvwr.asp
http://technet2.microsoft.com/windowsserver/en/library/91e699f7-3574-475e-9615-bd74d99209b31033.mspx?mfr=true
------------------------------
Date: Thu, 27 Sep 2007 19:57:36 -0000
From: ebm <ebmarquez@gmail.com>
Subject: Re: Report to Event Viewer correctly using Win32::EventLog
Message-Id: <1190923056.927579.192820@n39g2000hsh.googlegroups.com>
On Sep 27, 10:56 am, Brian McCauley <nobul...@gmail.com> wrote:
> On Sep 26, 7:58 pm, ebm <ebmarq...@gmail.com> wrote:
>
> > I'm writing a script that will run as a scheduled task on a win2k
> > server. I would like the script to log to the Event Viewer on the
> > server but when I use the Win32::EventLog module I get a bunch of
> > garbage included in the Event that I log.
>
> Actually if you read this "garbage" you'll realise that it's not in
> the event that you log. It is a message that's being generated from
> the Event Viewer program.
>
> Windows events are not just plain text, they are an array of strings
> that are used to populate a template and that template is looked up by
> some mechanism using the event source and the event ID.
>
> > Is there a away to do this with so I don't get the garbage...
>
> Almost certainly but this question as nothing to do with Perl, the
> answer would be the same however you log an event in Windows. Really,
> therefore, you should try a forum that deals with Windows-related
> questions.
>
> However a quick Google search turned up these:
>
> http://www.codeproject.com/dotnet/evtvwr.asphttp://technet2.microsoft.com/windowsserver/en/library/91e699f7-3574-...
It had to do with the EventID. I made the EventID NULL and it cleaned
up the way I wanted.
my %Event = (
Length => NULL,
RecordNumber => NULL,
TimeGenerated => NULL,
EventID => NULL,
Category => NULL,
Source => "Weekly Report Script",
Strings => $Description,
);
Anyway this solves my problem.
------------------------------
Date: Thu, 27 Sep 2007 12:12:38 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Small doubt in perl
Message-Id: <660nf39bsekbsilt2u3kicq6kk267dfem5@4ax.com>
On Wed, 26 Sep 2007 22:55:59 -0700, anil <anilkumar.iitm@gmail.com>
wrote:
>Subject: Small doubt in perl
http://perlmonks.org/?node_id=444996
>system("sample.sh");
>system("java test");
>
>In the "sample.sh" i have set some environmental variables, but the
>environment variables which are set in the sample.sh are not used by
>the java pgm.
>
>Is there any other way to achieve this functionality?
system qw/sh -c/ => 'sample.sh; java test';
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 16:39:45 -0400
From: Amer Neely <perl4hire@softouch.on.ca>
Subject: SOAP timing out
Message-Id: <%wUKi.459$9F1.264@read1.cgocable.net>
I have a working script that successfully sends data from my home PC to
a SOAP server in a .NET environment. I run Win2K on this box.
When I upload the script to a Redhat server, it times out, and does not
submit any data.
Anyone have a clue what might be causing this?
-------------------------------8<---------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use lib 'PerlMods/SOAP-Lite-0.69/lib';
use SOAP::Lite ( +trace => 'all', maptype => {} );
my $FirstName='Amer';
my $LastName='Neely';
my $proxy = 'http://xxx.xxx.xxx.xxx:180/somescript.asmx'; # edited
my $soap = SOAP::Lite
-> uri('http://localhost:180/somewhere')
-> on_action( sub { join '/', 'http://localhost:180/somewhere','Insert'} )
-> proxy('http://xxx.xxx.xxx.xxx:180/somescript.asmx');
my $method = SOAP::Data->name('Insert')
->attr({xmlns => 'http://localhost:180/somewhere'});
my @params = (
SOAP::Data-> name(FirstName => $FirstName),
SOAP::Data-> name(LastName => $LastName));
print $soap->call($method => @params)->result;
-------------------------------8<---------------------------------
This prints 'OK', which is what is returned by the 'Insert' function
from the server.
--
Amer Neely
w: www.webmechanic.softouch.on.ca/
Perl | MySQL programming for all data entry forms.
"Others make web sites. We make web sites work!"
------------------------------
Date: Thu, 27 Sep 2007 03:14:30 -0700
From: rihad <rihad@mail.ru>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <1190888070.295841.55040@g4g2000hsf.googlegroups.com>
On Sep 27, 2:27 am, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Michele Dondi <bik.m...@tiscalinet.it>:
> He(?) mentioned that he had already discarded this case.
>
Yes, I'm a "he" :)
> > >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).
>
>
>
[snipped]
> 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
Thank you very much, Ben! Thanks everyone else for sparkling up the
topic too.
>Quoth Michele Dondi <bik.m...@tiscalinet.it>:
>> Something can't be "more optimal" than something else. Perhaps
>> "optimized"?
> 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...
My apologies if "more optimal" happens to not be proper English: I
simply mapped the Russian " " [boleye optimal'niy] to
"more optimal" verbatim, which happened to not be too far from the
truth, as Ben's counterarguments later showed :)
It's very amusing to learn English and Perl side by side. For example,
"unless (...)" Perl lingo doesn't ring the bell for non-native (non-
american?) English speakers too much (at least not for me), so I try
to avoid it and use "if (not ...)" instead. "California or bust" is
okay, though (open ... or die $!)
------------------------------
Date: Thu, 27 Sep 2007 16:03:46 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <270920071603468264%brian.d.foy@gmail.com>
In article <1190824931.665621.151990@50g2000hsm.googlegroups.com>,
rihad <rihad@mail.ru> wrote:
> Programming Perl (The Camel Book) states that "String concatenation is
> also implied by the interpolation that happens in double-quoted
> strings."
> Can someone experienced in Perl source code confirm that they are
> identical in terms of raw speed and memory use or not?
When you start looking at the speed of things like this and actaully
caring about the answer, you'll probably find that Perl is not the
right tool for the job. Perl is really fast, but if this sort of
operation is too slow for you, then the bigger tasks in Perl, uch as
using a module, will just kill your performance (relatively).
Before anyone gets too concerned about small details like this
(especially when Perl is not constrained to implement them in any way
and the next release of Perl might do it differently), try profiling
the application that you are concerned about. You'll find easier and
slower things to fix and worry about :)
------------------------------
Date: Thu, 27 Sep 2007 21:41:02 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: tail recursion (was: Re: why are references so slow ?)
Message-Id: <13fo8re69r3qb45@corp.supernews.com>
In article <amplf35nh8l60cf8u9vdcaduatct4r58f3@4ax.com>,
Michele Dondi <bik.mido@tiscalinet.it> wrote:
: >Can you show an example?
:
: It's surely discussed in HOP, but I don't know if it's online yet.
: [...]
It's my recollection that Dominus had planned to include a
section on eliminating tail-calls with goto-&NAME but
abandoned the idea. (Seems like he couldn't make it work.)
Greg
--
Rightful liberty is unobstructed action according to our will within limits
drawn around us by the equal rights of others. I do not add 'within the limits
of the law,' because law is often but the tyrant's will, and always so when it
violates the rights of the individual. -- Thomas Jefferson
------------------------------
Date: Thu, 27 Sep 2007 22:01:31 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: tail recursion
Message-Id: <x73awzydhg.fsf@mail.sysarch.com>
>>>>> "GB" == Greg Bacon <gbacon@hiwaay.net> writes:
GB> In article <amplf35nh8l60cf8u9vdcaduatct4r58f3@4ax.com>,
GB> Michele Dondi <bik.mido@tiscalinet.it> wrote:
GB> : >Can you show an example?
GB> :
GB> : It's surely discussed in HOP, but I don't know if it's online yet.
GB> : [...]
GB> It's my recollection that Dominus had planned to include a
GB> section on eliminating tail-calls with goto-&NAME but
GB> abandoned the idea. (Seems like he couldn't make it work.)
my guess is that the problem is setting up @_ is a pain. magic goto
leaves @_ to be passed to the called sub. many recursive calls will have
different @_ than they want to pass on so you have to mung @_ in some
wacky ways. surely it can be done but it will be fugly and maybe not
even efficient with the extra code needed.
for more speed i would rather unroll the recursion into a loop and use a
private stack. that is the classic way to speed up recursion which is
slow in perl due to all the sub calls. with this solution you don't have
tail recursion issues at all.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Thu, 27 Sep 2007 16:07:49 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: why are references so slow ?
Message-Id: <270920071607492866%brian.d.foy@gmail.com>
In article <20070926110818.0cb56f4f.dduenker@uni-koblenz.de>, Daniel
Dˆºnker <dduenker@uni-koblenz.de> wrote:
> Wow thanks, that's a very interesting tool, and of course you are right,
> there are still lot's of inefficient things in my script, but it seems that
> the slowest part's are actually really referencing and dereferencing, as for
> example:
> 4455 3.53946 3.40000 133: return \%pixels;
> which is the part that takes the most time.
remember that one line of a report like that doesn't mean much devoid
of the context of everything else going on. Feel free to post more of
the report :)
also, I don't know what is going on in that subroutine, but returning a
reference, which is just a scalar, shouldn't be talking up that much
time. Can you show the subroutine?
------------------------------
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 886
**************************************