in reply to Year-month for file names

"My code works but I am not sure if I am over doing it or if there would be a better and more straight forward way to accomplish the same thing more efficiently."

Using the core module Time::Piece, I think you'd agree this is more straightforward:

#!/usr/bin/env perl -l use strict; use warnings; use Time::Piece; my $this_year = localtime->year; my @filenames = ('file_name_' . ($this_year - 1) . 12); push @filenames, "file_name_$this_year$_" for '01' .. '11'; print for @filenames;

Output:

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

Whether it's "better" is somewhat subjective; however, I think I'd prefer to maintain the three lines I use to generate the array of filenames to all the code you posted.

Use Benchmark (also a core module) to compare the running times.

-- Ken