Jeff 'Japhy' Pinyan wrote: > > On May 13, Lee Johnson said: > > > ># > ># End date is a year after start date > ># > >$edate = $sdate; > >$edate =~ s/\///g; > >$edate++; > >$edate =~ s/.*(\d{4})$/01\/04\/$1/; > > Are you sure you want to just use April 1st (or January 4th) always? You > don't want to use the day and month in $sdate? > > >where $sdate is a UK date of the type "dd/mm/yyyy" > > > >I've tried ($edate = $sdate) =~ s/(.*)(\d)$/$1($2++)/e; to no avail. I think > >I'm misunderstanding the /e modifier here? > > A little bit, yes. The /e modifier makes the right-hand side Perl code, > and you should recognize that > > $1($2++) > > isn't valid Perl code. You'd need > > $1 . ($2++) > > but that won't work for two reasons. First, $x++ returns its OLD value, > and THEN increments it, so you wouldn't get a changed value. The second > reason is that you can't modify the $DIGIT variables. > > Finally, your code is making a mistake in the regex. What if the year is > 2009? You're only matching the LAST digit of the year, and adding one to > it. Your string would end up being "...20010", which is wrong. Match the > whole four-digit year, and add one to it. When it rolls around to 9999, > then come back to me and complain about my bad code. ;)
Also, if the current date is 29/02/2004 and you increment the year to 2005... John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>