Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Grabbing year and month from filename

by vinoth.ree (Monsignor)
on Aug 01, 2018 at 05:26 UTC ( #1219619=note: print w/replies, xml ) Need Help??


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...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1219619]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2020-09-19 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (114 votes). Check out past polls.

    Notices?