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

Re: system(cp filenamewithspaces newplace/newname)

by ikegami (Patriarch)
on May 12, 2009 at 17:07 UTC ( [id://763543]=note: print w/replies, xml ) Need Help??


in reply to system(cp filenamewithspaces newplace/newname)

You didn't convert the file names into shell string literals when you created the shell command. There are two simpler alternatives:

You can use the multi-arg form of system which passes the arguments to the child without serializing them*:

system('cp', $oldname, "renamed/$newname") or die("cp: $!/$?\n");

You can use File::Copy:

copy($oldname, "renamed/$newname") or die("copy: $!\n");

* — Serialization will occur in Windows, but Perl will handle quoting and escaping for you (within the limits of Windows's command line abilities).

Replies are listed 'Best First'.
Re^2: system(cp filenamewithspaces newplace/newname)
by honeyeater (Initiate) on May 12, 2009 at 17:13 UTC
    Brilliant. Thank you so much.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2025-12-09 20:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (90 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.