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

Dear Monks,

maybe the following is more a MS issue than a perl one.

As anyone experienced problem starting an extra application from a perl script running on a Windows 7 machine? The following:

sub open { $url = 'http://www.perlmonks.com'; system ("explorer $url"); }

works fine on XP & co. but it fails on 7. What I see is just a DOS istance popping up for a second. On a DOS shell the same command works fine.

Anyone has an idea? Thanks, cla

UPDATE: please change "open"->"call_webpage"

Replies are listed 'Best First'.
Re: System command under Windows 7
by cdarke (Prior) on Aug 10, 2010 at 09:04 UTC
    use warnings; use strict; Ambiguous call resolved as CORE::open(), ....blah, blah
    Nothing to do with Windows 7, don't call your subroutines the same as built-in functions! I changed the name of the subroutine and it worked fine for me on Windows 7.

      Thanks for your reply.

      I changed here the name of the subrutine only for the sake of clarity (bad idea!). Mine is called "call_blablabla". Anyway interesting that it works fine for you. Maybe there are some restriction on the machine I am now working on (even if this sound strange to me).

        Indeed, that is a bad idea. When posting code, post exactly what you have, or even better a minimal example which recreates the problem. Giving us something you aren't running is clearly a waste of our time. See How do I post a question effectively?.

Re: System command under Windows 7
by marto (Cardinal) on Aug 10, 2010 at 09:14 UTC
      Thank you indeed.
Re: System command under Windows 7
by fanticla (Scribe) on Aug 10, 2010 at 10:32 UTC

    Thank you for all your replies.

    After applying some good practices to my script as suggested the subrutine works now fine on 7. The problem was indeed in the variable's scope. From now on: "use strict" will always be at its place!

Re: System command under Windows 7
by psini (Deacon) on Aug 10, 2010 at 09:41 UTC

    This is probably a stupid question, but... did you check the command "explorer <url>" from a command prompt?

    I'm not sure whether "explorer" is a valid command, in W2K/XP I've always used "iexplore" and I don't know which is the "standard" one.

    Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

      explorer http://perlmonks.org will open the url in Internet Explorer. IIRC start http://perlmonks.org will open the url in the users default browser, rather than force the use of Internet Explorer.

      "iexplore" does not appear to work on Windows 7.

      What else could it be? First, make sure you
      use strict; use warnings;
      as others have said. We know you are not doing that because otherwise $url = would be my $url =. Second, how are you launching your script? Try it from cmd.exe if possible so you can see error messages. Failing that, if you can only launch from Windows Explorer for some reason, then on the last line on your script place:
      <STDIN>;
      which will pause the script so you can see perl's console window (commonly, but incorrectly, called a "DOS box"). Hit <RETURN> to exit the script.