$i++

2005-12-11 Thread Octavian Rasnita
Hi, Can anyone explain why: $i++; is faster than: $i = 1; and even more faster than: $i += 1; Thanks. Teddy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: $i++

2005-12-11 Thread Chris Devers
On Sun, 11 Dec 2005, Octavian Rasnita wrote: > Can anyone explain why: > > $i++; > > is faster Not that I know for sure, but I'd imagine the explanation is that, deep in the bowels of Perl, the ++ operator is optimized in a way that a more generic operator like += or = can't be. But I could

Re: $i++

2005-12-11 Thread Octavian Rasnita
From: "Chris Devers" <[EMAIL PROTECTED]> Not that I know for sure, but I'd imagine the explanation is that, deep in the bowels of Perl, the ++ operator is optimized in a way that a more generic operator like += or = can't be. But I could be wrong. How much faster is it? -- Here is the test scr

Re: $i++

2005-12-11 Thread Chris Devers
On Sun, 11 Dec 2005, Octavian Rasnita wrote: > Here is the test script: > > for(1 .. 5000) { > $i += 1; > #$i = 1; > #$i++; > } > print times(); > > For $i += 1: 11.9210.03100 > > For $i = 1: 11.6250.01500 > > For $i++: 9.2960.03100 > > So, $i=1 takes 25.05% more time to run than $i++ and

Re: $i++

2005-12-11 Thread John W. Krahn
Octavian Rasnita wrote: > Hi, Hello, > Can anyone explain why: > > $i++; > > is faster than: > > $i = 1; > > and even more faster than: > > $i += 1; You have to understand how the CPU and Assembly Language works to truely understand why one instruction is faster than another. For example,

aliasing a function

2005-12-11 Thread JupiterHost.Net
Just a mental exercise :) What is the best way to "alias" a function, for instance: you can call it: sub say_it_loud( print @_ ); or use a type glob, etc What I'm trying to figure out is say you wanted to alias a function that is context sensitive? What I mean is say I wanted to have a fu

Re: aliasing a function

2005-12-11 Thread Wiggins d'Anconia
JupiterHost.Net wrote: Just a mental exercise :) What is the best way to "alias" a function, for instance: you can call it: sub say_it_loud( print @_ ); or use a type glob, etc What I'm trying to figure out is say you wanted to alias a function that is context sensitive? What I mean is s

Re: aliasing a function

2005-12-11 Thread JupiterHost.Net
perldoc -f goto I think the goto-&NAME form does exactly what you asked for. Sweet Wiggins, you rock :) thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Doubt

2005-12-11 Thread anand kumar
Hi I am new to perl .i have a doubt in analysing the following regex. (my $book = $ref_string) =~ s/\s*(\d+(?::\d+(?:-\d+(?::\d+)?)?)?)\Z//; here i want to know the meaning of '?:' thanks in advance Anand - Yahoo! Indi

Doubt

2005-12-11 Thread anand kumar
Hi I am new to perl .i have a doubt in analysing the following regex. (my $book = $ref_string) =~ s/\s*(\d+(?::\d+(?:-\d+(?::\d+)?)?)?)\Z//; here i want to know the meaning of '?:' thanks in advance Anand - Yahoo! Indi

Re: Doubt

2005-12-11 Thread Ricardo SIGNES
* anand kumar <[EMAIL PROTECTED]> [2005-12-11T22:38:00] > I am new to perl .i have a doubt in analysing the following regex. >(my $book = $ref_string) =~ s/\s*(\d+(?::\d+(?:-\d+(?::\d+)?)?)?)\Z//; > > here i want to know the meaning of '?:' Normally, something enclosed in parent

Input separator and block problem

2005-12-11 Thread Andrej Kastrin
Hi I want to count words in the following file: -- ID- some number TI- some text BB AB- some text AU- some text ID- some number TI- some GGG text AB- some text AU- some text ID- some number TI- some text AB- some text Z AU- some text -- So