[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] TPJ One-Liner #39



Ronald J Kimball wrote;
>I don't know that reading the entire file into memory at once is an
>improvement.  :)

Depends on what your after? Efficiency comes in many guises (yes, I'm
kidding, sort of.. :-) Although I thought the usage of a temporary array to
store the words was pretty ugly as well! Anyway, I couldn't come up with
another, short piece of code to get the exact same print out as the original
piece of code. That is with out any extra white spaces...

> \w* will already match up to the next word break, so the second \b was
> redundant.

Why, of course, how come I missed out on that! :-(

So if one was to combine all the best improvements so far one would get
(albeit with an extra white space at the end);

perl -ne'$,=$";print/(\b[A-Z]\w*)/g,""'

Looks pretty good! A part from the extra white space (yes, that bugs me for
some reason :-). Also I wish that the [A-Z]  part was internationalized
somehow.

So can it get even better? Or is that as fun as it gets? :-)


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe