Starting a browser from a perl program

I suspect my problem is more with the Yahoo website or the DOS box, than with perl, but I see no forum devoted to those matters.

Basically, I’m trying to start a yahoo web page out of a perl program, using backquotes.

That actually works quite well, but somewhere between the Dos box and Yahoo the url gets mangled.

Example:

I can get the page I want by typing into a browser the url: finance.yahoo.com/q/hp?s=CNX&a=05

I can get it also by putting it in backquotes in my perl program like so:
$cmd = "start chrome.exe finance.yahoo.com/q/hp?s=CNX\%26a=05;
$null = $cmd;

However, somewhere along the line, the ‘q/hp’ gets replaced with ‘lookup’, and Yahoo says it can’t find the page.

However, if I leave off the argument as: $cmd = "start chrome.exe finance.yahoo.com/q/hp?s=CNX,
the ‘q/hp’ is left in place, and the page comes up beautifully.

There’s nothing wrong with the arguments, since, if I manually edit the address bar to replace ‘lookup’ with ‘q/hp’, the argument is accepted and the page works fine.

Has anyone else had experience starting a browser from the command line with a url that includes arguments?

Instead of the frightening backticks, you might want to use something like URI::Escape.

You could go this route:

$cmd = ‘start chrome.exe “finance.yahoo.com/q/hp?s=CNX&a=05”’; # the end of the string is a double quote followed by a single quote
system($cmd);

as long as nothing inside of the single quotes is meant to be evaluated (i.e. no variables allowed).