Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: Move or rename script

by Anonymous Monk
on May 24, 2002 at 15:07 UTC ( [id://169096]=note: print w/replies, xml ) Need Help??


in reply to Re: Move or rename script
in thread Move or rename script

Actually I would like to try and do it within a perl script without using modules similiar to how I did my create directory:
#!/usr/local/bin/perl sub mak { !system "/bin/mkdir", @_; } print "Enter name of Directory you want to create: "; chomp($newb = <STDIN>); mak $newb; print "$newb directory created.\n";
Can the same be done with the move command except I want to use command line arguments when the script is invoked???

Replies are listed 'Best First'.
Re: Re: Re: Move or rename script
by Jenda (Abbot) on May 24, 2002 at 15:55 UTC

    You say you want to "move or rename" something.

    Let's see

     # perldoc -f move
     No documentation for perl function `move' found
    
    
    ok, so let's try the other
    
     # perldoc -f rename
        rename OLDNAME,NEWNAME
                Changes the name of a file; an existing file NEWNAME will be
                clobbered. Returns true for success, false otherwise.
                ...
    

      Jenda

Re: Re: Re: Move or rename script
by IOrdy (Friar) on May 24, 2002 at 15:58 UTC
    use backticks `` to make your system calls. (sorry I cant find a good link)

    any arguments can just be passed into the backtick.

    i.e. a recursive list of files that could be split with "\n" into an array.<br /
    @foo = `find $path -name $ftype`;

    And for move:

    $where = '/home/iordy/public_html/';
    $what = '/home/iordy/whatever.pl';
    @foo = `mv $args $what $where`;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found