in reply to How to set $ENV{'DISPLAY'} variable programatically?

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!

Replies are listed 'Best First'.
Re^2: How to set $ENV{'DISPLAY'} variable programatically?
by nysus (Parson) on Apr 20, 2016 at 23:34 UTC

    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!

        Sorry, here is the script that I use to create an EventRepository object which extends my FFMech class (see OP for that code).

        #!/usr/bin/perl package Mech; $ENV{'DISPLAY'} = ':3.0'; use Modern::Perl; use EventRepository2; my $er = EventRepository2->new(display => 0, fast_mode => 1, launch => + ['firefox', '-P', "CCAgenda", '-rep', '4244'], repl => 'localhost:42 +44'); $er->get ('http://slashdot.org'); $er->mySendKeys("^(l)slashdottiejksdjf");

        When I run this code, I get the error noted in my last post.

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