So im trying to learn how to use regular expressions in Perl. I have a textfile.txt that contains information and i want to access specific portions of that textfile. The textfile.txt contains the following entry (first 3 lines):
Jan 2016-01-01 Friday 12:00
Feb 2016-02-01 Monday 23:45
Mar 2016-03-01 Tuesday 15:30
What I want to do is to put the names of the month "Jan/feb/mar" in one array, their numerical value "2016-01-01" in a second array. My current script takes the entire first line and puts it in the same element. This is my code for writing to the array so far:
while (<FILE>) {
push (@newArray, $_);
}
close FILE
How would I go about only putting the entries of the date (2016-01-01) or the name of the month (Jan/feb/mar) into the array from the file, instead of putting the entire line into the array element?
regex? Becausesplitwould work quite nicely.splitwould be better.