in reply to Re: How to use file copy with wild card characters
in thread How to use file copy with wild card characters

File::Copy won't function without a $to and $from argument, so some naming convention for the new files is needed. I would approach it in this manner:

map { copy($_, $_ . '.new') } glob("*.ext");

Replies are listed 'Best First'.
Re^3: How to use file copy with wild card characters
by thor (Priest) on Dec 31, 2004 at 22:39 UTC
    While I agree that that is probably a good idea, it doesn't answer the question that I asked. It could be that the OP only wants to save one archived log. So, in that case, you could move every file in the glob to a static file name i.e.
    foreach my $file (glob('*.log')) { rename $file, "oldlog" or die "Oops: $!"; }
    I don't know about you, but I'm not psychic.

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

Re^3: How to use file copy with wild card characters
by Anonymous Monk on Jan 01, 2005 at 00:17 UTC

    Danger, Will Robinson! map in void context! I would write that like this instead:

    copy($_, "$_.new") for glob "*.ext";

    I think it's much easier to look at.

      what´s wrong with map in void context?

        what´s wrong with map in void context?

        Nothing if you are using 5.8.1 or later. See perl581delta.