On Wed, Jan 10, 2007 at 12:47:25PM +0700, beast wrote:
> I have these following data:
>
> a 100
> a 102
> c 100
> a 102
> b 111
> c 100
> c 102
> c 100
> c 100
> a 102
> ...
>
> I would like to have a list (either array or hash) with unique line .
> Any help would appreciated.
> Thanks.
>
1. You need to read the data
2. You need to split it into its components
3. Then create a hash with the component
This is untested off top of head
my %data_hash;
while(<DATA>){
chomp; # Get rid of line feeds
my @bits = split;
$data_hash{$bits[0]} = $bits[1];
}
foreach my $data(keys %data_hash){print "$data $data_hash{$data}\n" }
Owen
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/