Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^4: Win32 wperl open Console when system

by soonix (Canon)
on Jan 21, 2020 at 12:26 UTC ( #11111676=note: print w/replies, xml ) Need Help??

in reply to Re^3: Win32 wperl open Console when system
in thread Win32 wperl open Console when system

perl -e "qx(explorer.exe C:\Path\To\my.pdf)"
opens the explorer, but
perl -e "qx'explorer.exe C:\Path\To\my.pdf'"
opens my pdf

only difference is the qx delimiter. (insert smiley with gaping open mouth here)

Perl 5.28.1 MSWin32-x64-multi-thread on Windows [Version 10.0.18363.535]

Replies are listed 'Best First'.
Re^5: Win32 wperl open Console when system
by sn1987a (Chaplain) on Jan 21, 2020 at 12:44 UTC
    From perlop qx:
    Using single-quote as a delimiter protects the command from Perl's double-quote interpolation, passing it on to the shell instead:

    perl -e "qx(explorer.exe C:\\Path\\To\\my.pdf)"


      I finally got it work the way I want by using:

      sub ShowPDF { my $pdf=shift; my $action = { MSWin32 => sub { $pdf=~s/\//\\/g; qx/explorer.exe "$url"/; }, darwin => sub { system qq{open "$pdf" >/dev/null 2>&1 &} }, }->{$^O} || sub { system qq{xdg-open "$pdf" >/dev/null 2>&1 &} }; $action->(); }

      I just had to add the RE to make sure there is only '\' in the path (its porting from Unices).

      Using "explorer" command did the trick and solved my issue !

      Many, many , thank to you all :-))


      Aaah! Yes, of course.
      And explorer.exe seems to be one of the few programs who don't understand forward slashes in paths :-(

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11111676]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2020-06-03 13:36 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (23 votes). Check out past polls.