vendredi 28 avril 2017

Perl: Can not compare two strings if one of them is with special chars

I am new to Perl. Trying to check whether an existing variable $file_path is equal to a specific path or not in if condition.

my $PRODPATH = '/path/to/prod';
if ( $file_path eq "$PRODPATH/specific/path/to/file" )
{
  print "File is same as earlier \n\n";
}
else
{
  print "File is not same as earlier \n\n";
}

But the flow is not going to any of the conditions because of the special character $ in the string which I am comparing with $file_path. Is these / in the path are also creating any issues?

Aucun commentaire:

Enregistrer un commentaire