Could someone please tell me what's wrong with my use of the substr function below? I keep on getting "use of uninitialized value in substr". Thanks.
$newpsc = substr($PSC,0,$count); Here's the complete code: #!/usr/bin/perl use strict; use warnings; my $exclude_psc = 'exclude_psc.txt'; my $current_base = 'base.txt'; my $output = 'new_excludepsc.txt'; my %ex_psc; my $exkeyword; open EXCLUDE, '<', $exclude_psc or die "Could not open '$exclude_psc' $!"; while ( <EXCLUDE> ) { next if $. == 1; # exclude header chomp; my ($excpsc,$keyword) = split /\|/; %ex_psc = (exclpsc=>$excpsc,exkeyword =>$keyword ); } close EXCLUDE; open BASE, '<', $current_base or die "Could not open '$current_base' $!"; open OUT, '>', $output or die "Could not open '$output' $!"; while (<BASE>) { my ($base_no, $name, $description, $PSC) = split /\|/; my $newpsc; my $wordlength; my $expsc=$ex_psc{exclpsc}; my $count = $ex_psc{exclpsc}=~ s/([a-z])/$1/gi; if ($count eq 4){ $newpsc = substr($PSC,0,$count); if (uc($ex_psc{exclpsc}) eq uc($newpsc)){ $_= join '|',$base_no,$ex_psc{exclpsc},$ex_psc{exkeyword}; print OUT; } } } close(OUT); __END__ --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.