Let's look at my code:
Starting at the top, I assemble the command and parameter list in the @args array. The start command on Win32 takes the command to run as the first or second parameter, depending no the shell/OS. command.com takes it as the first parameter while cmd.exe takes it as the second parameter. So you can consider it as an old habit to put the file twice there. Typing help start in cmd.exe will tell you lots about other options.
my @args = ("start",$file,$file);
Next, I put all parameters that have spaces in them into double quotes. This is a very crude mechanism, because it doesn't pay attention to other characters that might confuse the shell, like ?,&,| or %. To prepend and append a double quote, I use alternative double quotes by using the qq quoting operator, see perlop or perldoc perlop, in case the link doesn't work.
for (@args) { # Apply smart-ish double quotes if (/ /) { $_ = qq{"$_"}; } };
Two alternative ways to achieve the same quoting would be :
$_ = '"' . $_ . '"'; # or $_ = "\"$_\"";
So I think you should see why I prefer $_ = qq{"$_"} over that.
The only thing that remains is to hand the parameter list to the shell:
system(@args) == 0 or warn "Couldn't launch '$file' : $!/$?/$^E";
In reply to Re^3: Perl Tk: opening a file in its original format
by Corion
in thread Perl Tk: opening a file in its original format
by FM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |