Help for this page

Select Code to Download


  1. or download this
    $line = "On January 1 1970 the unix epoch commenced.";
    my @months = qw(
    ...
    my ($month, $day, $year) = $line =~ m/($months)\s+(\d+)\s+(\d+)/i;
    print "month\t$month\nday \t$day\nyear\t$year\n";
    
  2. or download this
    $line = "On January 1 1970 the unix epoch commenced.";
    my @months = qw(
    ...
    my $months = join "|", @months;
    my ($month, $day, $year) = $line =~ m/((?:$months)\w+)\s+(\d+)\s+(\d+)
    +/i;
    print "month\t$month\nday \t$day\nyear\t$year\n";