Re: Y2K Again ??

Rick Klement <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
Rick Klement wrote:
> 
> Brian Morgan wrote:
> >
> > ($Yr = $FieldA) =~ s/^(\d{2}).*/$1/;
> > if($Yr > 20){
> >     $Yr = "19$Yr";
> > }else{
> >     $Yr = "20$Yr";
> > }
> >
> > #Concat year to FieldB
> 
> There is no need for a regex
> 
>         $Yr = ($FieldA > 20 ? 1900 : 2000) + $FieldA;
> 
> Or just get $FieldB directly if you don't need a separate $Yr
> 
>         $FieldB = ($FieldA < 21) + 19 . $FieldA;
> 
> --
> Rick Klement

Another "straight to FieldB" given that the year range is only 1970 to 2004

	$FieldB = 19 + $FieldA=~/^0/ . $FieldA;

-- 
Rick Klement
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.