(a)
my ($date,$mon,$year,$hour,$min,$sec,$tz) =
  ($ap =~
    m/.*?(\d+)\s*(\S*)\s*(\S*)\s*(\d*)\:(\d*)\:(\d*)\s*(\S*)/);

(b)
my ($weekday,$date,$mon,$year,$hour,$min,$sec,$tz) =
  ($ap =~
m/(\w\w\w\),\s(\d+)\s*(\S*)\s*(\S*)\s*(\d*)\:(\d*)\:(\d*)\s*(\S*)/);

Example 4: (a) Perl regular expression to parse an RFC 822 date that does not include the weekday; (b) parsing a date that contains the weekday.

Back to Article