in reply to Re: Re: regex-matching the date
in thread regex-matching the date

Brother dep has covered the downside of $&, but on your split question, the beauty there is that you don't need to match the (sometimes) complex target of your interest, just the separators that mark where your interest ends, and that's often a lot easier. In this case, if you're going to verify the date anyway, there is not much sense in going to great lengths to do that in the regex, so you can just split on whitespace instead.

As you noted, split won't be able to find your dates at all. It is a great option if you are parsing some sort of log file in which the lines always start with that date format, but if you want to get that date out of the middle of a lot of other text, a specific regex would be my choice, and instead of split you can use $1 etc. to get your date components, like:

if /(\w{3})\s+(\w{3})\s+(\d+)/){ ($day, $month, $daynum) = ($1, $2, $3); }
Finally, while we're talking about OWTDI, you might also consider unpack for jobs like this as it is usually faster, though it is even more fussy about the format of the data being consistent. It is however ideal for fixed-width columns of data (anyone else still dealing with data in card images?).

--
I'd like to be able to assign to an luser