On Wed, May 04, 2011 at 07:57:12PM -0500, Jesse Luehrs wrote:
> On Thu, May 05, 2011 at 02:08:35AM +0200, Adam Borowski wrote:
> > /enum monster_type\s*{\s*((?:\w+\s*(?:\s*=\s*\w+)?,\s*)+)}/
> for my $line (split /\n/, $source) {
> last if $line =~ /}/;
>
> my ($enum) = $line =~ /(\w+).*?,/;
> next unless $enum;
> my $lc_enum = lc($enum);
> print qq{$enum => "$lc_enum"\n};
> }
This assumes there can be ever only one enum per line. C++, unlike Python,
doesn't suffer from Fortranitis and lets you format the source any way you
want.
> Perl doesn't have to be unreadable, you know d:
Well, I admit my version was perhaps too terse, but I'd still call yours
_less_ readable. Comments and /x are better than merely doing the same
thing a roundabout way.
--
1KB // Microsoft corollary to Hanlon's razor:
// Never attribute to stupidity what can be
// adequately explained by malice.
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Crawl-ref-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crawl-ref-discuss