in reply to Find the last item in a series of files
Anyway, you might avoid a sort with something like this:
The if ... else statement could be reduced to a simple if statement and a Boolean operator:my %hash for my $file (glob("*.*")) { my ($root, $ext) = split /\./, $file; if (defined $hash{root) { $hash{$root} = $ext if $ext > $hash{$root}; } else { $hash{$root} = $ext; } }
but I wanted to make it as easy to read as possible.$hash{$root} = $ext if (not defined $hash{$root}) or $ext > $hash{$roo +t};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Find the last item in a series of files
by Marshall (Canon) on Jun 16, 2017 at 23:54 UTC | |
by Laurent_R (Canon) on Jun 17, 2017 at 09:21 UTC | |
by CountZero (Bishop) on Jun 22, 2017 at 05:54 UTC | |
by Marshall (Canon) on Jun 22, 2017 at 22:13 UTC | |
by CountZero (Bishop) on Jun 24, 2017 at 08:16 UTC |