in reply to [untitled node, ID 150523]
Update: Ok this is the scoundrels way of doing it :)use strict; use warnings; my @words = qw(Richard Rolled All Over Rondas Red Carpet); my @r_words; print "Example 1:\n\n"; foreach (@words) { if(/^R/) { push @r_words,$_; } } foreach (@r_words) { print $_,"\n"; } @r_words = ();
HTHprint "Example 2:\n\n"; map { push @r_words, $_ if /^R/ }@words; foreach (@r_words) { print $_,"\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Array culling - simple question
by rob_au (Abbot) on Mar 09, 2002 at 10:48 UTC |