in reply to Pattern Matching in Arrays
#!/usr/bin/perl use strict; use warnings; my @data = qw/12345_-v1.pdf 12345_Av1.pdf 123456_-v1.pdf 123456_Av1.pd +f 123456_Bv1.pdf/; my %hash; for my $f (sort @data) { my ($key,$version) = split /_/,$f; $hash{$key} = $version; } for my $key (keys %hash) { print $key . '_' . $hash{$key} . "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pattern Matching in Arrays
by aj.kohler (Initiate) on May 12, 2009 at 13:49 UTC | |
by przemo (Scribe) on May 12, 2009 at 17:59 UTC | |
by aj.kohler (Initiate) on May 12, 2009 at 20:09 UTC | |
by przemo (Scribe) on May 12, 2009 at 22:44 UTC | |
by aj.kohler (Initiate) on May 13, 2009 at 18:28 UTC | |
by ciderpunx (Vicar) on May 13, 2009 at 17:01 UTC |