* Rick Klement <[EMAIL PROTECTED]> [2004-05-14 17:26]:
> Brian Morgan wrote:
> > 
> > Good evening everybody,
> > I have been working on a small database project and have come across the
> > need to move some data from table A to table B, the year format in table
> > A is \d{2}\D{8} and in table B \d{4}\D{8}
> > 
> > Since the records in table A range from 1970 - 2004.  I want to be able
> > look at the date, and determine if it is a 2000 or 1900 date and make
> > the appropiate date change.
> > 
> > So here is my sollution (long):
> > #Pull the value out of the field
> > #For this example I don't care about the rest of FieldA I just want the
> > 1st 2 digits,
> > #but I need to preserve FieldA for later use in the program.
> > 
> > ($Yr = $FieldA) =~ s/^(\d{2}).*/$1/;
> > if($Yr > 20){
> >     $Yr = "19$Yr";
> > }else{
> >     $Yr = "20$Yr";
> > }
> > 
> > #Concat year to FieldB
> > 
> > I guess I am looking for a way to combine a substitution with the if
> > statement but haven't come up with a working solution.
> > 
> > Anyways, I am looking forward to see what the outcome is.
> > 
> > Brian
> 
> There is no need for a regex
> 
>       $Yr = ($FieldA > 20 ? 1900 : 2000) + $FieldA;

That will generate a warning à la 

    Argument "94foobar" isn't numeric in addition (+) at baz.pl line 42

Of course you could always

        $Yr = do { no warnings 'numeric'; ($FieldA > 20 ? 1900 : 2000) } + $FieldA;

-- 
Regards,
Aristotle
 
"If you can't laugh at yourself, you don't take life seriously enough."

Reply via email to