NAME
Remind::Parser - parse `remind -lp' output
SYNOPSIS
use Remind::Parser;
$parser = Remind::Parser->new(...);
$reminders = $parser->parse(\*STDIN);
foreach (@$reminders) {
...
}
DESCRIPTION
Remind::Parser parses an input stream produced by remind(1) and intended for back-end programs such as rem2ps(1) or wyrd(1).
For details on the input format, see rem2ps(1).
PUBLIC METHODS
- new(%args)
-
$parser = Remind::Parser->new; $parser = Remind::Parser->new('strict' => 1);
Create a new parser. A single (key, value) pair may be supplied:
If strict is specified, the parse method will complain of any lines of input following the
# rem2ps end
line. - strict([boolean])
-
$is_strict = $parser->strict; $parser->strict(1); # Be strict $parser->strict(0); # Don't be strict
Get or set the parser's strict property. If strict is specified, the parse method will complain of any lines of input following the
# rem2ps end
line. - parse($filehandle)
-
$events = Remind::Parser->parse(\*STDIN);
Parse the contents of a filehandle, returning a reference to a list of reminders. The input must have been produced by invoking remind -l -p[num]; otherwise, it will not be parsed correctly. (If remind's -pa option was used, "pre-notification" reminders are correctly parsed but cannot be distinguished from other reminders.)
Each reminder returned is a hash containing the following elements:
- day
- month
- year
-
The day, month, and year of the reminder.
- description
-
The reminder description (taken from the MSG portion of the remind(1) source).
- all_day
-
If this element is present and has a true value, the reminder is an all-day event. Otherwise, it's a timed event.
- hour
- minute
-
The hour and minute of the reminder, if it's a timed reminder. Absent otherwise.
- duration
-
If the reminder has a duration, this is set to a reference to a hash with hours, minutes, and seconds elements with the appropriate values.
- tag
-
The TAG string from the remind(1) source. Absent if no TAG string was present.
- special
-
The SPECIAL string from the remind(1) source. Absent if no SPECIAL string was present.
- line
- file
-
The line number and file name of the file containing the reminder.
- event
- instance
-
These two elements together uniquely identify a reminder. Reminders triggered from a single file and line share the same event identifier but have distinct instance identifiers.
BUGS
There are no known bugs. Please report any bugs or feature requests via RT at http://rt.cpan.org/NoAuth/Bugs.html?Queue=Remind-Parser; bugs will be automatically passed on to the author via e-mail.
TO DO
Parse formats other than that produced by remind -l -p[a|num]
?
Add an option to skip reminders with unrecognized SPECIALs?
AUTHOR
Paul Hoffman (nkuitse AT cpan DOT org)
COPYRIGHT
Copyright 2007 Paul M. Hoffman.
This is free software, and is made available under the same terms as Perl itself.