tony said:
I tried both the commnds and its not working
Both of _what_ "commands"?
Please quote some context in followups like everybody else does.
Have you seen the Posting Guidelines that are posted here frequently?
1) When used "Properly_set($display)" cmd it throws following error, ^
^
Undefined subroutine &main:
roperly_set called at ex_pl.pl line 5
^
^
Those are *different* subroutines.
Case matters.
2) When used if ($ENV{Display} ne $ProperValueForEnvVariable)..no ^^^^^^^
^^^^^^^
errror is thrwon..
That is not what was in the earlier answer.
Case matters!!
I'm guessing you would have gotten some helpful messages if
you had warnings and strict enabled...
But eventhough display is set perplry
What does "properly" mean in this case?
That is, exactly what value do you _want_ DISPLAY to have?
it says Display
is not set properly
Programs don't "say" things.
They can _output_ things though, which is what I think you meant.
But the bit of code that you have shown us does not have any
output statements, so it still can't really be "saying" anything.
Please help if i am using the cmd correctly
We cannot tell you if you are using it correctly, we need more information.
1) what is the "correct" value for your situation?
2) how, exactly, are you setting variable values, doing the
comparison and making output?
If you post a short and complete program that we can run, then
we surely *could* help you fix the problem.
As it is, we cannot even see the place where the problem is.
use PSI::ESP;
You copied the answers verbatim, when they contained "meta" parts
that you did not change to match your actual situation. (We had
to do that because you have never told us the actual situation.)
That is, we do not know what value you want to accept as "proper".
So, I will assume that the value that you want is the 4-char string:
:0.0
if my assumption is wrong, then you will need to modify the
code to accept whatever the correct string is.
Here is a short and complete program that _you_ can run.
You may need to modify it to get it to work of course.
------------------------
#!/usr/bin/perl
use warnings;
use strict;
# direct comparison
if ( $ENV{DISPLAY} eq ':0.0' )
{ print "set properly\n" }
else
{ print "NOT set properly\n" }
# subroutine does comparison
if ( set_properly($ENV{DISPLAY}) )
{ print "set properly (func)\n" }
else
{ print "NOT set properly (func)\n" }
sub set_properly {
my($display) = @_;
return $display eq ':0.0';
}