copying multiple files

Discussion in 'Perl' started by yaduraj, Aug 9, 2004.

  1. yaduraj

    yaduraj Guest

    hello all,

    How can i copy files with a particular extension.

    For eg:
    I am using

    copy ("$HOME_DIR/file1.txt" ,"$LOCAL_DIR/") or warn "Cannot copy file:
    $!";

    to copy a file, but if i have to copy all the files with the extension
    *.txt how do i do it...

    Thanx in advance
    yaduraj, Aug 9, 2004
    #1
    1. Advertising

  2. yaduraj

    Jim Gibson Guest

    In article <>, yaduraj
    <> wrote:

    > hello all,
    >
    > How can i copy files with a particular extension.
    >
    > For eg:
    > I am using
    >
    > copy ("$HOME_DIR/file1.txt" ,"$LOCAL_DIR/") or warn "Cannot copy file:
    > $!";
    >
    > to copy a file, but if i have to copy all the files with the extension
    > *.txt how do i do it...


    Perl doesn't have a built-in copy function, so you must be using
    File::Copy, If you were to post a complete, minimal program that
    demonstrates your problem, people trying to help you wouldn't have to
    guess about the details.

    To apply a function to different files, check out the glob function or
    the File::Find module. You probably want to wrap your copy command in a
    loop of some sort, because perl doesn't know whether you want to copy
    the each file to a file of the same name in a different directory, or
    to a different name in the same directory, or copy all of the files to
    a single, concatenated file. You will have to tell it.

    FYI: this newsgroup is defunct; try comp.lang.perl.misc in the future.
    Jim Gibson, Aug 9, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ALPO

    Copying files .........

    ALPO, Dec 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    440
    Jim Hughes
    Dec 20, 2003
  2. John Lundrigan

    Copying files in the root with Copy Project

    John Lundrigan, May 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    298
    John Lundrigan
    May 20, 2004
  3. Replies:
    0
    Views:
    481
  4. Replies:
    4
    Views:
    938
    M.E.Farmer
    Feb 13, 2005
  5. Shawn Mcclain
    Replies:
    0
    Views:
    177
    Shawn Mcclain
    Sep 28, 2007
Loading...

Share This Page