in reply to Generate list with array elements repeated x times

Use this simplified sub (stealing choroba's map):
sub date_list { my ( $from, $to ) = @_; my @dates = $from; my $intermediate = $from; while ( $intermediate ne $to ) { $intermediate = sprintf "%04d-%02d-%02d", Add_Delta_Days( spli +t( /-/, $intermediate ), 1 ); push @dates, $intermediate; } my $first = shift(@dates); my $last = pop(@dates); return map { ($_) x 10 } @dates; }

Outputs for me using 2014-01-02 and 2014-01-06:

2014-01-03 2014-01-03 2014-01-03 2014-01-03 2014-01-03 2014-01-03 2014-01-03 2014-01-03 2014-01-03 2014-01-03 2014-01-04 2014-01-04 2014-01-04 2014-01-04 2014-01-04 2014-01-04 2014-01-04 2014-01-04 2014-01-04 2014-01-04 2014-01-05 2014-01-05 2014-01-05 2014-01-05 2014-01-05 2014-01-05 2014-01-05 2014-01-05 2014-01-05 2014-01-05

Replies are listed 'Best First'.
Re^2: Generate list with array elements repeated x times
by Anonymous Monk on Oct 16, 2014 at 20:55 UTC

    Even simpler. I took out what was below my $last and used the same return line from my response to choroba with @dates instead of @mults. Works perfectly. Thanks toolic.

      You're welcome. I was wondering if there was a way to get rid of your pop/shift, and it turns out you could use splice instead. You determine if this is too clever or not:
      return map { ($_) x 10 } splice @dates, 1, -1;