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

I have an instrumented browser in which I would like to open list of URLs. All the APIs provided by perl open a default browser. Is there anyway I could open my instrumented browser and then open my URLs in it

Replies are listed 'Best First'.
Re: Opening URL in instrumented browser
by Corion (Patriarch) on Sep 17, 2013 at 15:58 UTC

    I would assume that this depends on your "instrumented browser", and what methods its API offers.

Re: Opening URL in instrumented browser
by Arunbear (Prior) on Sep 17, 2013 at 16:20 UTC
    system perhaps? e.g.
    perl -e 'system(q[opera --remote "openURL(http://www.perlmonks.org/)"] +)'
      I need to get the control back to my perl program. I guess the above call is a blocking call??

        From the documentation on system:

        Does exactly the same thing as exec LIST , except that a fork is done first and the parent process waits for the child process to exit.

        Another alternative would be to use backticks instead of system. I personally consider this as a "quick" and "dirty" method even though I do use it a lot. There are some potential problems with using this method. Off hand I don't remember what all of the issues are, but I believe that there are better ways to launch another program and return control back to the Perl script without waiting for the launched program to return control.

        Yes, it is a blocking call:
        % perl -E 'system(q[opera http://www.perlmonks.org/]); say "hello!" ' + hello!
        That only prints "hello!" once Opera exists. Non-blocking alternatives are:
        % perl -E 'system(q[opera http://www.perlmonks.org/ &]); say "hello!" +' hello!
        i.e. launching in the background, or
        % perl -E '$r = fork; if($r == 0) { exec(q[opera http://www.perlmonks. +org/]) } elsif(defined $r) { say "hello!" }' hello!
        which forks off a child process, and uses exec (so the child process doesn't hang around waiting for the browser process to end).
Re: Opening URL in instrumented browser
by bulk88 (Priest) on Sep 18, 2013 at 04:15 UTC
    On Windows use the "start" command. It will return immediately without waiting for the child process to exit.