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`;