Harry Putnam wrote:
What I'm working on will eventually be a script that reads an `events'
file and lets me know about events I've entered there. It's my own
primitive but hopefully effective calendar reminder type of tool.
The format of entries look like this:
cat ~/.events
ev 100411 4
Wash behind ears
ev
ev 100421 4
Avoid a beating by taking out the garbage
this evening.
ev
[...]
The multidigit numbers represents YYMMDD,
if( my ( $year, $mnth, $mday, $extra ) = $line =~ m{ \A \s* ev \s*
(\d\d)(\d\d)(\d\d) \s* (\d+) \s* \Z }msx ){
# process event
}else{
# do something else
}
How well the regex works depends on whether the syntax is followed
correctly. Since you designed the syntax, you're the one who must
enforce it. :)
Perhaps you should consider writing the data in XML:
<ev year="2010" month="04" mday="11" extra="4">
Wash behind ears
</ev>
<ev year="2010" month="04" mday="21" extra="4">
Avoid a beating by taking out the garbage
this evening.
</ev>
There are tools like xmllint(1) and tidy
<http://www.w3.org/People/Raggett/tidy/> that can verify the syntax is
correct. And a whole mess of XML parsers in CPAN.
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
I like Perl; it's the only language where you can bless your
thingy.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/