Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7159623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:15:42+00:00 2026-05-28T13:15:42+00:00

I am running a program that I would periodically like to restart. I prefer

  • 0

I am running a program that I would periodically like to restart. I prefer to pass exec a list so that the shell is not involved as follows:

    // Do stuff 
    .
    .
    exec $^X, $0, @ARGV;

When I do this (on Windows) and $^X contains spaces using the above it treats $^X as multiple items and fails.

The following works just fine, but starts a subshell in addition to the script:

    # Do stuff 
    .
    .
    exec "\"$^X\" $0 @ARGV" ;

This is not a huge deal, but I would like to learn how to execute in a list context if possible.

Things I have tried:

    exec "\"$^X\"", $0, @ARGV;
    exec "\\\"$^X\\\"", $0, @ARGV;
    exec "'$^X'", $0, @ARGV;  # Even though Windows doesn't like '

Also:

    push @restart, $^X, $0, @ARGV;
    print $restart[0];
    exec @restart;

The print statement correctly shows the executable with the space in it as the first item in the array.

I have copied the perl executable to a location that does not contain spaces in its path and from there exec given a list works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:15:43+00:00Added an answer on May 28, 2026 at 1:15 pm

    Windows files have a regular name and a “short” name for backwards compatibility with the golden age of DOS. For the specific case of $^X = 'C:\Program Files\perl\perl.exe, something like C:/Progra~1/perl/perl.exe would probably work.

    For a more general solution, see the Win32 and the GetShortPathName function. Then you could call

    exec Win32::GetShortPathName($^X), $0, @args;
    

    (in some cases you may want to wrap $0 and the arguments in GetShortPathName, too).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Matlab program that is running longer than I'd like it to.
I need to program a Background process that would periodically buffer certain types of
I am running a program that builds a very large object, and I would
Suppose I have a program running that periodically adds information to a .CSV file.
I am looking for a method to monitor a running program that I have
When running a Python program that reads from stdin, I get the following error:
I am running a java program that sets up a database connection to an
I'm running a java program that uses many vectors. I'm afraid my use of
I have an automated test running on my program that generates some large MPG
I am working on a background program that will be running for a long

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.