[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] Tighter/cleaner way to do this? map { grep {} } ?



This works. But does anyone have a better solution than my foreach / if / push?

j



$ cat j.pl
my @a = qw(
  junk:gold_17:junk
  junk:junk:junk
  junk:gold_blah9:junk
);
my @b;
foreach (@a) {
  if (/(gold\w+)/) {
     push @b, $1;
  }
}
print join ", ", @b;
print "\n";


$ perl j.pl
gold_17, gold_blah9