in reply to Re: Year-month for file names
in thread Year-month for file names

It needs to generate the file names when it runs, and there is no parameters that needs to be passed to the sub, I don't understand your comments.
"Your subroutine takes no parameters, so no variation is possible. In other words, why waste time generating this at runtime, the returned array is constant...".

Replies are listed 'Best First'.
Re^3: Year-month for file names
by BrowserUk (Patriarch) on Nov 26, 2013 at 15:52 UTC

    Seems my prompt was too obscure. See if this makes sense:

    use constant DATE_TEMPLATE => "file_name_%4d%02d"; sub buildEm{ my $year = shift; my @dates = sprintf DATE_TEMPLATE", $year-1, 12; push @dates, sprintf DATE_TEMPLATE, $year, $_ for 1 .. 11; return \@dates; };; $dates = buildEm( substr localtime, -4 );; print for @{ $dates };; file_name_201212 file_name_201301 file_name_201302 file_name_201303 file_name_201304 file_name_201305 file_name_201306 file_name_201307 file_name_201308 file_name_201309 file_name_201310 file_name_201311

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.