Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Thank you for your time.#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @times = qw(1000 1000 1000 1010 1010 1010); my $hash = {}; my $seen = {}; for my $time (@times) { if ($seen->{$time}) { HACK: $time++; if ($seen->{$time}) { goto HACK } else { $seen->{$time}++ } } else { $seen->{$time}++ } $hash->{$time}->{one} = 1; $hash->{$time}->{two} = 2; } print Dumper $hash;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: goto HACK
by dave_the_m (Monsignor) on Sep 25, 2018 at 07:37 UTC | |
by Anonymous Monk on Sep 25, 2018 at 09:24 UTC | |
by dave_the_m (Monsignor) on Sep 25, 2018 at 11:53 UTC | |
|
Re: goto HACK
by Eily (Monsignor) on Sep 25, 2018 at 08:29 UTC | |
|
Re: goto HACK
by choroba (Cardinal) on Sep 25, 2018 at 08:31 UTC | |
|
Re: goto HACK
by cavac (Prior) on Sep 25, 2018 at 09:30 UTC | |
|
Re: goto HACK
by bliako (Abbot) on Sep 25, 2018 at 11:50 UTC | |
|
Re: goto HACK
by dsheroh (Monsignor) on Sep 26, 2018 at 07:27 UTC |