nysus has asked for the wisdom of the Perl Monks concerning the following question:

I have a box with 4 X11 servers running on it with the following designations: :3.0, :2.0, :1.0, :0.0

I have a Moose class that launches an application (a Firefox browser) and then uses the X11::GUITest module to perform some operations on the application. I can change which display the application runs on and which display X11::GUITest operations are sent to by setting the $ENV{'DISPLAY} system variable like so:

package FFMech; $ENV{'DISPLAY'} = ':3.0'; # open app in display #3 and send X11::GUITe +st operations to it use X11::GUITest qw(SendKeys ClickWindow); use Moose;

Instead of hard coding the DISPLAY variable, I'd like my FFMech object to be able to set this variable. How do I achieve this?

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re: How to set $ENV{'DISPLAY'} variable programatically?
by LanX (Saint) on Apr 20, 2016 at 21:16 UTC
    I don't understand your question %ENV is alsways magically in main:: so you should be able to set it in any occasion (ie package).

    Which bug/problem did you encounter?

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      When I move the DISPLAY variable to the script that creates the object I get:

      X11::GUITest - This program is designed to run in X Windows! INIT failed--call queue aborted.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
      $nysus = $PM . ' ' . $MCF;
      Click here if you love Perl Monks

        Looks like a timing problem for me.

        "the script that creates the object" is obscure for me, I can't see where this happens.

        Anyway you seem to call it too late.

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!