Re: Faster perl operation?

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Lynn Newton
Date:  
To: Main PLUG discussion list
Subject: Re: Faster perl operation?
my $var = "";
my $start = 1000;
$var = sprintf("%s", "." x ($start - 1));
print $var . "\n";

Works for me, but I don't know about speed. If anything
it's probably slower. You still have the "." x ($start - 1)
component, which takes as long as it takes in either
case. In the second case all you're doing is incorporating
the extra overhead of a call to sprintf(), which I'm
sure is fast in most ordinary cases, but it's just more
code to execute. So I doubt that it's the key to any
increased speed.

On 1/17/07, Kevin Brown <> wrote:
> I'm working on a small script (so far only about 1000 lines long) and
> I'm finding that I'd like a faster way to do:
>
> $variable = "." x ($start - 1);
>
> which is incredibly slow since it is creating sometimes on the order of
> 100,000 to 3,000,000 (yes, Million) periods to fill up the needed string.
>
> I've tried using:
> sprintf +("%s" x ($start - 1)), ".";
>
> but I must not have the syntax correct as it doesn't create the needed
> "." characters.
>
> Any thoughts on what is wrong with the sprintf syntax or what else I
> could try to speed this up?
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change you mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss


--
Lynn David Newton
Phoenix, AZ
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss