Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: unix mv command

by xmanamit (Initiate)
on Jun 15, 2007 at 12:09 UTC ( [id://621446]=note: print w/replies, xml ) Need Help??


in reply to Re: unix mv command
in thread unix mv command

I have tested the paths, and they are fine as I used the perl mv command using File::copy module with the same variables. But can't understand why this doesn't work.

Replies are listed 'Best First'.
Re^3: unix mv command
by clinton (Priest) on Jun 15, 2007 at 12:26 UTC
    If you let us see the paths, then we may be able to explain it.

    Clint

Re^3: unix mv command
by blazar (Canon) on Jun 16, 2007 at 12:05 UTC
    I have tested the paths, and they are fine as I used the perl mv command using File::copy module with the same variables. But can't understand why this doesn't work.

    Non sequitur. Suppose that $from='foo' and $to='bar baz'. If you pass these arguments to F::C's mv(), then it will try to move the the file named foo to that called bar baz - with a space in it. If you do

    system("mv $from $to");

    as in your first post, a shell will be started which in turn will call the external mv program with the three cmd line arguments foo, bar and baz. (Well, upon a closer look to the docs it seems that it will call the shell only if there are shell metacharacters, but the final result won't change.) This may not be your case, but it serves as an instructive example. Alternatively use the LIST form of system, which will avoid the shell in any case and more likely do the Right Thing™ - and check its return value:

    0 == system 'mv', $from, $to or warn "Something wrong: $?\n";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-25 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found