in reply to simple pattern match ?

In perl6.....

#!/usr/bin/pugs use v6; rule minute { <[1..5]>?\d | <[*]> }; rule hour { <[1..2]>?\d | <[*]> }; rule day { 31 | 30 | <[1..2]>?\d | <[*]> } rule month { 1?\d | <[*]> } rule day_of_week { <[0..6]> | <[*]> } rule crontab { <minute> \s+ <hour> \s+ <day> \s+ <month> \s+ <day_of_w +eek> } my $crontab = "0 10 * * *" ~~ /<crontab>/; my $match = $crontab<crontab>; say "Minute: $match<minute>\nHour: $match<hour>\n" ~ "Day: $match<day>\nMonth: $match<month>\n" ~ "Day of Week: $match<day_of_week>";
1;0 eric256@feather:~/tests$ pugs crontab.p6 Minute: 0 Hour: 10 Day: * Month: * Day of Week: *

___________
Eric Hodges

Replies are listed 'Best First'.
Re^2: simple pattern match ?
by Anonymous Monk on Mar 15, 2006 at 22:48 UTC

    rule hour { [1\d | 2<[0..4]>] | 0?\d | <[*]> } rather, assuming that the range for hours is 1..24 and not 0..23.

    similarly,

    rule day { 31 | 30 | <[0..2]>?\d | <[*]> } rule month { 1<[210]> | 0?\d | <[*]> }