http://qs321.pair.com?node_id=777660


in reply to LaTeX Abbreviations for Linguists

if ( $abbr =~ m/[A-Z]{2,}/ ) { my @inlist; push(@inlist, $abbr); foreach (@inlist) { if ( $_ =~ /\./ ) { my @dumm = split(/\./, $_); $inlist[0] =~ s/\.//g; foreach (@dumm) { push(@inlist, $_); }; }; };

From perlsyn:

If any part of LIST is an array, foreach will get very confused if you add or remove elements within the loop body, for example with splice. So don't do that.
You are pushing items onto @inlist at the same time that you at iterating over @inlist.   You shouldn't do that!