for further reference i will attach these pattern files and a slightly modified version of my code using your regex.
use strict; use warnings; use diagnostics; use File::Slurp; use File::Copy::Recursive qw(rcopy fcopy); use File::Basename; my @dirs; my @patterns; my $dir1 = $ARGV[0]; get_filelist($dir1); get_patterns(); move_files(); mkdir('./ripped'); sub get_filelist { my ($dir) = @_; my ($dh); if ( !opendir( $dh, $dir ) ) { return; } while ( my $file = readdir($dh) ) { next if ( -d $file ); my $path = "$dir/$file"; if ( -d $path ) { get_filelist("$path"); } else { push( @dirs, "$dir/$file" ); } } } sub get_patterns{ my @files = read_dir('patterns'); foreach my $element(@files){ open my $file, '<', "patterns/$element"; while(<$file>){ #$_ =~s/[*]/.*/g; #$_ =~s/\\/\//g; $_ =~ s[\\/][\\\\/]g; $_ =~ s/\\/\\\//g; $_ =~ s/\./\\./g; $_ =~ s/^\*//; $_ .= '$' if $_ !~ s/\*$//; $_ =~ s/\*/.*/g; $_ =~ s/\?/./g; chomp $_; $_ = $_.'|'; push @patterns, $_; } close($file); } } sub move_files{ my $regex = join('', @patterns); print $regex; for my $element(@dirs){ if ($element =~ $regex){ print "Found $element\n"; # rcopy($element, "ripped/$element"); } } }
here is the compelet pattern set. pattern files I thought i had it working, but it was still missing alot of files, and still copying alot of files it wasnt suppose to and i am unsure on which way to go with it now. i have tried replacing '*' with '.*' and '?' with '.', but it is still failing because it is replacing all instances of * and ?

i have also found Regexp::Wildcards i will see how that works as well

In reply to Re^3: Using an array that contains wildcard characters for pattern matching. by james28909
in thread Using an array that contains wildcard characters for pattern matching. by james28909

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.