Hi! I have a list of files with sequential naming. I've brought this file list into an array. I need to create a smaller arrays based on the filename structure--grouping like filenames... and then do 'something' to each array. To be clearer, here's an example:
@array = (001.file.a, 001.file.b, 002.file.a, 002.file.b)
I need to extract those files with matching prefixes (ie. 001) into a separate array, and do 'something'. When finished, extract those files with the next prefix (ie. 002) and then do 'something'... and on and on. I can't rely on the prefixes following sequentially (ie. 001, 004, 018), so I'll have to do some sort of compare of $array
1 to $array[0] and then push if necessary i think...
I don't need help with the regex/grep portion, but moreso how to iterate through and extract matches, do 'something', then repeat with the next set of matches.
Thanks in advance for any help!
a:)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.