in reply to pushing to array

Use a hash to eliminate duplicates. I have written a demo below to show how this can be done. There are other ways too of course.
use strict; use warnings; use Data::Dumper; <DATA>; my @products = keys %{{ map { /^\d+\s+(\w+)$/ ? ($1,1) : () } <DATA> } +}; print Dumper(\@products); __DATA__ price product 200 shoe 20 shirt 10 shirt 5 hat

And the output:
$VAR1 = [ 'hat', 'shirt', 'shoe' ];

Replies are listed 'Best First'.
Re: Re: pushing to array
by aquarium (Curate) on Mar 02, 2004 at 12:25 UTC
    ...in case you also get "belt buckle" as a product...then replace the above posted excellent code with "..*" where "\w+" is.