Hello, I have files and directories that share a regex.
For every directory there are 2-4 files that share an id number.
Example:

Directory: 11355 Zfp71
files: 11355_SU, 11355_SD, 11355_pGk, 11355_LacZ
The files and directories exist in different different
directories. A hash is probably the best solution. I need
to copy the files into the directory when the key value pairs match.
I could use a little direction. Check out my code.
#!/usr/bin/perl use strict; use File::Copy; =for Create a hash to match the primer files with the maid folder. When a match occurs, copy it to the maid folder. Next create a new folder and populate it with the files to be processed by the sequence assembler. path to sequence files: "/Data/Sequencing_Results/RESULTS 2009/New Version 2009/Amanda Li"; =cut my %fields_hash; $lt_vec_seq = "/Data/Velocigene/Production Design/KOMP"; # Location of + the maid files $seq_results = "/Data/Velocigene/Production Design/KOMP/SequenceAssemb +lies"; # create hash consisting of maids as keys and sequence files as values sub seq_assembly{ # create a hash with maid folders as keys and the primer seq files as +values my %sequence_hash; $sequence_hash{$lt_vec_seq} = $seq_results; my @sorted_keys = sort { $a <=> $b || $b cmp $a } keys %sequence_h +ash; foreach my $key (@sorted_keys) { # Could use some direction concerning copying the $seq_results(whe +re files # exist) into $lt_vec_seq(directory) copy(); } }
I humbly seek you wisdom.

In reply to Files and Directories that share a regex variable by lomSpace

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.