mercredi 25 décembre 2019

uninitialized value in regex compilation in perl

The below code is giving an error when I use if-else block for the comparison of $valid. When if-else condition is not used the error is not there. The error is " Use of uninitialized value $value in regexp compilation".How to solve this?

...
if($valid eq 1){
print "Enter value\n" ;
my $value = <STDIN>;
}else{
  print " valid is not 1 \n";
}
if($line =~ /$string.*$value/){  --> error
    //code
}

Aucun commentaire:

Enregistrer un commentaire