i wanted to assign to variable $run in perl module and to have check in if condition.
Basically the $run variable is assigned with last value of the current working directory and in if condition if the perl script is checking with value assigned with variable $run
part of perl module code script snippet where exact issue has been seen.
ex.pm
-----
my $run = ${PWD##*/};
if ( $2 ne $run)
{
die "$0 should be run in a $run directory.";
}
with this code i am getting compilation issue. same thing if directly have if condition with last path value hardcoded its working good if ( $2 ne '4').
compilation issue messages
syntax error at bin/ex.pm line 44, near ")
{"
syntax error at bin/ex.pm line 49, near "$sitepath "
BEGIN not safe after errors--compilation aborted at bin/TestConstants.pm line 72.
Compilation failed in require at bin/ex1.pm line 13.
BEGIN failed--compilation aborted at bin/ex1.pm line 13.
Compilation failed in require at ./bin/test.pl line 26.
BEGIN failed--compilation aborted at ./bin/test.pl line 26 (#1)
(F) Probably means you had a syntax error. Common reasons include:
A keyword is misspelled.
A semicolon is missing.
A comma is missing.
An opening or closing parenthesis is missing.
An opening or closing brace is missing.
A closing quote is missing.
You can't use bash syntax in Perl.
The right hand side is a bash way of saying "Remove everything up to the last slash", which in Perl is written as
or