I have been thinking this to death. Maybe one of you has an answer. I have a tool that extracts data from files of type A and writes it to files of type B. The user supplies file names and a "prefix" value that is used in the generatoin of the B files. The prefix goes
inside the file as part of the data. The rules are:
- If the input filename has no metacharacters (xxx.A) it is read and processed and the output file is generated. If no output file was specified use xxx.B.
- If the input filename has metacharacters, expand it (with glob) to generate a list of input files to process. If no output filename was specified apply the rule in step 1. (So if I have xx1-1.A and xx1-2.A, xx1-?.A processes those and generates xx1-1.B and xx1-2.B). Also, the user may want the output files to be xx1-data-1.B and xx1-data-2.B. I have to assume regular output filenames.
- If in either of the above cases an output file is specified, put all the output in that file.
- If a prefix was specified, use it to prefix the data in the output file. The trick is that the prefix needs to vary with the input filename, so if I have xx1-1.A and xx1-2.A the user needs to identify that the prefix for the first file is the 1 and the prefix for the second file is the 2.
Yes, this is an algorithm and human factors problem, but I am stuck. Right now I have a GUI with three entry windows: source, destination and prefix. I can handle a single input file and a single output file no problem. I can glob the filenames (this is in Windows) no problem. What I cannot seem to do is figure out how to specify the changing prefix, and how to specify the output file names. And of course, how to code the crazy thing...
I've tried specifying the input as xx1-{?}.A and parsing out the question mark and using it in the output file names, but I couldn't find a good way to generate them. I have the input filenames in an array (@src).
Any ideas about what I should do? --traveler
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.