A lot of guessing, but it sounds like you're looking for something like this:
To clarify: I'm not sure if you're always looking for the same month, an abbreviation, a series of months, or a series of month abbreviations. This little example will work for a series of month abbreviations. Substitute whatever you need for the (Jan|Mar|Dec). (Keep the parentheses).my ($month, $day, $year) = $line =~ / (Jan|Mar|Dec) # the month abbreviations we want \s+ # followed by one or more spaces (\d+) # then one or more digits \s+ # then one or more spaces (\d+) # then one or more digits /x;
Next, I'm assuming that by "fields" you mean space separators for the month and year, which always appear in that order, as numbers. If you meant something else by "fields", you need to be more specific. This statement will assign those three parts to the three variables $month, $day, and $year. (Assuming your input string is in $line.)
If you haven't seen it before, the /x at the end of the pattern allows embedding comments and whitespace. It increases readability a lot.
As I said, there's a lot of guessing here on my part. If you want to be more general (for example, being able to handle more date formats), take a look at the many date-handling routines on CPAN.
HTH
In reply to Re: Pulling Date out of String
by VSarkiss
in thread Pulling Date out of String
by GreatWhite
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |