in reply to Re: Re: Re: counting occurances
in thread counting occurances

Since we're spewing bilge today, thought I'd post what I'd been thinking to do to avoid the RE recompiles.   I know others have done it (many times) before, but ...
my $magic = 'sub { '; foreach my $char (@chars) { $magic .= "\$cnts{$char} += ()= \$_[0] =~ m/$char/g;"; } $magic .= '}'; my $magicsub = eval "$magic"; die "eval to create anon sub failed '$@'" unless defined $magicsub; while( <DATA> ) { $magicsub->($_); }

And in honor of the day:
@pieces=split //, 'eight'; print "@pieces squawk!\n" for(1..2);