[Boston.pm] underused perl feature

2011-05-31 Thread Uri Guttman
hi all, i just saw a post on the perl beginner's list and it was prepending a dir to a filename with the usual $x = $dir/$x. i replied that 4 arg substr is usually faster. i wanted to make sure so i ran a simple benchmark on this. the code and results are below. it is faster because it knows

Re: [Boston.pm] underused perl feature

2011-05-31 Thread Chris Devers
On Tue, May 31, 2011 at 4:44 PM, Uri Guttman u...@stemsystems.com wrote:                assign = sub { my $x = 'abc' ; $x = qwerty/$x },                substr = sub { my $x = 'abc' ; substr( $x, 0, 0, 'qwerty/') }, The substr version doesn't look very readable or maintainable. You're teaching

Re: [Boston.pm] underused perl feature

2011-05-31 Thread Uri Guttman
CD == Chris Devers cdev...@pobox.com writes: CD On Tue, May 31, 2011 at 4:44 PM, Uri Guttman u...@stemsystems.com wrote:                assign = sub { my $x = 'abc' ; $x = qwerty/$x },                substr = sub { my $x = 'abc' ; substr( $x, 0, 0, 'qwerty/') }, CD The substr version