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

tos has asked for the wisdom of the Perl Monks concerning the following question:

Hi folks,

so you don't think i'm deceased here a sign of life.

The problem is to pick some decided elements out of an array and put them into another.

My own solution works, but as far as i know perl, there must be a more elegant way to do this.

# perl -we '$i=0;$x="klops";@a=(qw|apfel klops klops börne joghurt klo +ps nüß|);for ($i=$#a;$i>=0;$i--) {print "$i:",$a[$i],"\n";$a[$i]=~/$x +/ && push @e, (splice @a, $i, 1)};print "@e\n@a\n"' 6:nüß 5:klops 4:joghurt 3:börne 2:klops 1:klops 0:apfel klops klops klops apfel börne joghurt nüß
Suggestions ?

regards, Thomas


Is simplicity best or simply the easiest Martin L. Gore