Dug out a primitive little helper function I wrote years ago in case it's of use. Just does a simple non-recursive copy of wild card files from one dir to another. Not proud of it but it still seems to work fine. Might be useful if you just need something small and simple:

use strict; use warnings; use File::Copy; use File::Basename; =head2 copy_files_wild FROMDIR TODIR VERBOSE WILD Copy files in wildcard WILD from FROMDIR to TODIR. Return the number of files successfully copied. Die if something goes wrong. =cut sub copy_files_wild { my ( $fromdir, $todir, $verbose, $wild ) = @_; print "copy '$fromdir/$wild' to '$todir'.\n"; -d $fromdir or die "error: dir '$fromdir' not found\n"; -d $todir or die "error: dir '$todir' not found\n"; $fromdir =~ s/ /\\ /g; # Escape any spaces in $fromdir my $ncopy = 0; while ( glob("$fromdir/$wild") ) { next unless -f; my $fname = File::Basename::basename($_); my $targ = "$todir/$fname"; $verbose and print "$fname\n"; if ( File::Copy::copy( $_, $targ ) ) { ++$ncopy; } else { die "error: copy '$_' to '$targ':$!"; } } print "done.\n"; return $ncopy; } # Example my $ncopied = copy_files_wild( 'DIR1', 'DIR2', 1, '*.txt' ); print "$ncopied files copied\n";


In reply to Re: File::Copy and wildcards by eyepopslikeamosquito
in thread File::Copy and wildcards by RickNak

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.