Stories
Slash Boxes
Comments
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

use Perl Log In

Log In

[ Create a new account ]

cog (4665)

Journal of cog (4665)

Thursday February 19, 2004
12:20 PM

Victory (on a mini Perl contest)

[ #17498 ]

Mini Perl contest. The smallest amount of characters wins. The purpose is to convert every word with more than two characters to the following format: (first_letter)(number_of_letters_in_between)(last_letter).

Input:

this is an input line

Output:

t2s is an i3t l2e

Someone had already come up with this:

#!/usr/bin/perl -p
s!(\w)(\w+)(\w)!$1.(length$2).$3!eg

and I considered it (for personal reasons) to be a personal matter. It took me a while (some minutes, I mean), but I finally came up with:

#!/usr/bin/perl -p
s!(?<=\w)\w+(?=\w)!length$&!eg

Any other suggestion? :-)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.