in reply to Re: Re: VarStructor II -- Abbreviation tool
in thread VarStructor II -- Abbreviation tool

No. There is every need to speculate with your code, Wassercrats. My code was not meant to replace yours, or even reproduce 100% of the functionality. It was to show you that you can do what you are trying to do with much less code! How about this instead: it truncates the string to the first two letters (lowercased) and adds incremented numbers for each collision. And this time i won't require you to use a module!

my (%symbol,@old,@new); while (<DATA>) { chomp($_ = substr lc($_),0,2); push @old, $_; $symbol{$_}++; push @new, $_ . $symbol{$_}; } print "$_\n" for @new; __DATA__ Line one Line two xxxxxxxxxxx Another line xxxxxxxxxxx Lines end here not xxxxxxxxxxx Fourth line (used to be) Line five Lines end here Lines end here too
Of course, while i find this to be quite silly -- it is more intuitive than what you have. Besides, you already have your arguable better way.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.