doing chomp should solve your problem
$novar = `env | grep VAR`;
chomp $novar;
if ( $novar eq "VAR=1" or $novar =~ /s*/ ) {
#something
}
else {
#something
}
HTH
On 3/21/07, perl_1978 < perl_1978%40yahoo.com">perl_1978
yahoo.com> wrote:
>
> I'm trying to do a conditional if statement but the results I'm
> getting back are not the desired ones.
>
> $novar = `env | grep VAR`;
>
> if (($novar eq "VAR=1") || ($novar =~ m/s/)) {
> something
> }else
> {
> something
> }
>
>
> If I run the command "env | grep VAR" at the command line this VAR
> is not set it will come back with nothing. For example -
>
> $ env | grep VAR
> $
>
> I thought that was considered whitespace so I did an OR with $novar
> =~ m/s/ but it's not catching it and dropping to my esle line.
> Could someone help me out and let me know what I'm doing wrong?
>
> Thanks
>
>
>
--
~ Kishore Balla
[Non-text portions of this message have been removed]
.