Hi,

I need another set of eyes to help look over the codes below. I have a 
subroutine that check for a comma in $strA and do some regex replacement, if 
there's no comma then return the values of the two arguments passed to it. The 
IF in my sub worked but the Else part didn't return any thing when i have 
records in my data set that doesn't have a comma in it.  Records #(pid) 1,4,5 
didn't returned anything (else statement); the rest did the text substitution 
correctly(If statement). Thanks in advance for any suggestions. 

example data set of $strA:
pid|PSC_L0
1|A
2|A,F,G,H
3|A1,a2
4|F
5|G
6|A,G
 

#search for comma and replace
sub replaceComma{
   my ($strA)= shift;
   my ($strLevel) = shift;
   my $strPSC;
   if($strA =~ m/,/){
    $strPSC = ",(AND($strLevel:";
    $strA =~ s/,/$strPSC/g;
    $strA =~ s/,/)),/g;
    $strPSC = "$strLevel:$strA)";
    return $strPSC;
        }
   else {
    $strPSC = "$strLevel:$strA)";
    return $strPSC;
   }
}#end sub replace

#Call sub replaceComma
#$PSC_L0 is read in from a text file, see sample above

if ($PSC_L0 =~ m/[^a-zA-Z0-9]/){
    my $PSC_Level = 'PSC_L0';
    my $strURL0 = &replaceComma($PSC_L0,$PSC_Level);
    print OUT "$strURL0";



 
       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

Reply via email to