Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Why does system("mv $x $y") not work when it works at the command line? (updated)

by haukex (Archbishop)
on Feb 03, 2023 at 04:58 UTC ( [id://11150115]=note: print w/replies, xml ) Need Help??


in reply to Why does system("mv $x $y") not work when it works at the command line?

First, you shouldn't be using system for that operation, you should be using Perl's builtin rename, or move from the core module File::Copy.

Second, if you ever do need to run an external command, see my node Calling External Commands More Safely.

Update: Additionally, when you run your Perl script from the command line, you need to properly escape/quote the filename (e.g. in single quotes) to prevent special characters in the filename (like the brackets) from being interpreted by the shell. Modern shells' tab completion can do this for you.

  • Comment on Re: Why does system("mv $x $y") not work when it works at the command line? (updated)
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-23 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found