in reply to how to open a file with space in its name

I amd assuming that you are using Windows - A file path with embedded spaces needs to be delimited by double quotes. Add escaped double quotes around your $file. This is what you would have to do if you typed in the command yourself.

sub{system "start soffice \"$file\""})

As mentioned previously, the new style of system command removes this ambiguity and will make for a more portable program.

Replies are listed 'Best First'.
Re^2: how to open a file with space in its name
by suaveant (Parson) on Jan 05, 2006 at 15:35 UTC
    If one is trying to escape filenames etc in a situation like this I prefer
    "start soffice \Q$file\E";
    to
    "start soffice \"$file\"";
    that way anything weird in the string is escaped, including " chars that may be in it... of course, the list version of system is safer.

                    - Ant
                    - Some of my best work - (1 2 3)

      Which will not work for Win32 filenames, as a file named c\:\\autoexec\.bat does not exist.

      Also, the quoting rule of double quotes (") is different for cmd.exe too - "" gets converted to ", """ gets converted to "" and so on. I think. In any case, quotemeta is not what you want when quoting strings for cmd.exe or command.com.

        Too true... I have written Perl on Windows all of about twice, so I tend to be biased towards Unix-style programming, my bad.

                        - Ant
                        - Some of my best work - (1 2 3)

Re^2: how to open a file with space in its name
by Anonymous Monk on Nov 04, 2008 at 13:30 UTC
    In unix , how can we open a file with space in its name. Please paste the command and help me out.
      Use the multiple argument version of system