You could just reverse the order of the lines in the file...
use strict; use warnings; my @lines = reverse(<DATA>); my %test; foreach (@lines) { my ($name, $number) = split / /; $test{$name} = $number; } print %test; __DATA__ nick 5 nick 10 nick 20 john 78 erik 9 erik 12
This gives the result...
nick5 john78 erik9
In reply to Re: How can I keep the first occurrence from duplicated strings?
by Bod
in thread How can I keep the first occurrence from duplicated strings?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |