SPUG: Petty perl obfuscation question
ced at carios2.ca.boeing.com
ced at carios2.ca.boeing.com
Sat Oct 12 21:57:16 CDT 2002
> $string = "Prefix-3C2B1A";
> $string =~ s/(?<=-).+/join'',sort$&=~m{(..)}g/e;
>This simply replaces the tokens in place. I had trouble getting it into a
>subroutine as one line though. It seems like we should be able to drop the
>join() call too.
Not nearly as elegant... but avoids the join ;)
my($p, at s) = $string=~/(.*-|..)/g;$p.=$_ for sort @s;$p
Rgds,
--
Charles DeRykus
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list