hi all,

> Harry Putnam wrote:
> > Shawn H Corey <shawnhco...@gmail.com> writes:
> > 
> >> 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
> >> }
> > 
> > Yikes, I'll be a week with perlre to get even close to 
> following that.
> > In fact I don't really understand whats happening there at all.
> > 
> > Also it doesn't appear to work with the data I posted unless the 
> > $extra is present, and that is supposed to be up to the ~/.events 
> > author.
> 
> Oops, you're right.  I forgot the extra was optional.  Try:
> 
> if ( my ( $year, $mnth, $mday, $extra ) = $_ =~ m{ \A \s* ev \s*
>       (\d\d)(\d\d)(\d\d) \s* (\d+)? \s* \Z }msx ) {
> 

just a little side question. i would have written 

(\d*)

instead of

(\d+)?

i mean, why using two quantifiers? is there a reason behind this?

cheers, gabi
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to