1833858 Members
3774 Online
110063 Solutions
New Discussion

perl scripting?

 
SOLVED
Go to solution
Ridzuan Zakaria
Frequent Advisor

perl scripting?

Hi all,

How do we check for null string and "/" in perl?

i.e

if [ "${DEL}" = "" -a "${PATH}" = '/' ]; then
echo "BLANK and /"
fi

Thanks.
ridzuan
quest for perfections
4 REPLIES 4
H.Merijn Brand (procura
Honored Contributor

Re: perl scripting?

if ($ENV{DEL} eq "" && $ENV{PATH} eq "/") {
print "BLANK and /\n";
}

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Brian Bergstrand
Honored Contributor
Solution

Re: perl scripting?

#!/opt/perl/bin/perl

$del="Your String Here";
$path="Your String Here";
if ($del =~ /^$/ && $path =~ /^\/$/) {printf "BLANK and /";}

HTH.
A. Clay Stephenson
Acclaimed Contributor

Re: perl scripting?

The key is that "eq" and "ne" compare strings while "=" and "!=" compare numeric values.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: perl scripting?

Ooops, I meant "==" and "!=" are used for numeric comparisons. "=" always means assignment.

If it ain't broke, I can fix that.