Below is what i get when i tried to print just the $PSC variable. So the $PSC column has the value of (PSC, FCSD2, ADEK1, ADEZ2). I did put in a check for alphanumeric in $PSC if ($PSC =~ /^[a-zA-Z0-9]+$/) before doing the substr but still have same issue.
What i'm trying to do is to look for a substr of $PSC and print something to the out file. I used $count because the user input for $PSC (exclude_psc.txt) could be any alphanumeric from 1 to 5 characters long. If $PSC only has one letter like "A" then $count=1, so used substr to look for the first letter in $PSC if they are the same then print to out file. If $count=2 then look for first two letter in $PSC, and so on... $newpsc = substr($PSC,0,$count); Maybe you guys have a better way for me to accomplish this in Perl. This is the only way i know how to do this right now. Thanks for all your suggestions. ------------ PSC FCSD2 ADEK1 ADEZ2 Use of uninitialized value in concatenation (.) or string at generatePsc.pl line 48, <BASE> line 5. Use of uninitialized value in concatenation (.) or string at generatePsc.pl line 48, <BASE> line 6. ADEM2 Use of uninitialized value in concatenation (.) or string at generatePsc.pl line 48, <BASE> line 8. Richard Lee <[EMAIL PROTECTED]> wrote: >> >>> *What not just like below? As long as you have unique key, it would >>> retain all the information.* >> $ex_psc{"$excpsc"} = "$keyword"; > > $ex_psc{"$excpsc"} is superfluous because *all* hash keys are strings. > > perldoc -q quoting > > WhatÂ’s wrong with always quoting "$vars"? > > > > John Thank you John, Also, can you explain why below is wrong? Otherwise, besides slowing you down, you're going to break code when the thing in the scalar is actually neither a string nor a number, but a reference: func([EMAIL PROTECTED]); sub func { my $aref = shift; my $oref = "$aref"; # WRONG <----- why is it wrong? } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ --------------------------------- Never miss a thing. Make Yahoo your homepage.