http://qs321.pair.com?node_id=1219619


in reply to Grabbing year and month from filename

Use regular expression and parse the year and month from the file name.

$filename =~ /^(\d+)-(\d+)-(.*)/; my $year = $1; my $mon = $2; print("$year-$mon");
(OR)

Use split() method

my $filename = "2010-7-this-is-an.html"; my ($year, $mon) = split('-', $filename); print("$year-$mon");

All is well. I learn by answering your questions...