in reply to Re: Re^6: Substituting Newline Characters
in thread Substituting Newline Characters

No no, I mean eval to generate two near-identical subs at compile time — no AUTOLOAD funkiness or anything.
BEGIN { my $merge_code = <<'EOC'; sub %s { my ($data) = @_; while ( $some_condition ) { # big loop, no embedded loops $count = $count1 %s $count2; } } EOC eval sprintf $merge_code, merge => '+'; eval sprintf $merge_code, unmerge => '-'; }
I think it's very clear what's going on here, and you still get the benefit of only maintaining a single copy of the code.

Makeshifts last the longest.