NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Lines of code? (Score:1)
while () { print unless
Of course, you could match his argument conventions precisely, but why bother? This form is the normal Perl way to do it, and the author's Perl and Java arguments were already different.
I haven't benchmarked this one-liner, but I bet it's faster than the author's Perl version, and likely faster than the Java code as well. It might be a
Deven
"Simple things should be simple, and complex things should be possible." - Alan Kay
Re:Lines of code? (Score:1)
As someone said somewhere (petdance iirc), when making optimized solutions, test. It's something a lot of people seem to not be doing in this thread (either here or in davorg's journal). If you're going to make it more efficient, you might as well make it produce the same results.
At work, I produced a shiny new version of a previous routine. I couldn't really benchmark them though: the previous version processed much less data due to a bug in its impleme
---ict / Spoon
Re:Lines of code? (Score:1)
Unfortunately, when I put them back in, I put the opening paren after the ^ (force of habit) when that's not what I meant. My bad!
I also lost the <> operator inside the while (), while we're being pedantic.
To be really pedantic, I should point out that the case-insensitive part matches other capitalizations like "Css" that the original code didn't -- to be completely identical, I should have kept it case-sensitive and listed just the particular variations used in the original code, but I thought case-insensitive was more true to the intent of the original...
The only reason I didn't test it was because I didn't have any available data to run it on, and I didn't feel like constructing some sample test data. I left it as "an exercise for the reader".
But hey, you knew what I meant! The point was that in a minute or two, you can make a one-liner in Perl that does the same as the Java 100-liner, and probably quite a bit faster, too.
Deven
"Simple things should be simple, and complex things should be possible." - Alan Kay
Reply to This
Parent