Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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 musing on the Monastery: (6)
As of 2020-06-03 09:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (22 votes). Check out past polls.

    Notices?