The essential functionality is not reusable, except as a command-line tool. Extract it into a module, or at least a perl library file, so that I can call it from other perl code.
Well, basically you're tempting me to let my hubris take over my laziness. However consider that
  1. as a general rule I still consider myself to be at most an advanced newbie,
  2. unfortunately time is not really an option. See for example this article in clpmisc, also available from Google groups or Google groups-beta.
The expander is hard-coded to expect only "-[1:10]-{a:b:c}-" patterns.
No, it isn't!
What about "-{a:b:c}-[1:10]-" or "-[1:10]-[2:11]-" or "-{a:b:c}-{d:e:f}-" or even "-[1:10]-" or "-{a:b:c}-", etc? Make the expander recognize and expand any number of "[1:10]" and "{a:b:c}" patterns in the string.

But it already does!! (Maybe you missed the point in which I stated that I wrote this as a general purpose solution to avoid having to create many ad hoc ones.)

I apologize for I did not pinpoint all the details and only hinted to the "format" of input strings...

However:

  1. a range of "numbers" (but not only, thanks to Perl's smart .. operator) [<num1>:<num2>] expands to the list of numbers from <num1> to <num2> in a smart way, e.g. with the correct number of leading zeroes,
  2. a colon separated list of "words" {<word1>:<word2>:...:<wordn>} expands to that list.
I am perfectly aware that this description is not too clear and foolproof either, but I'm confident it will shed some light on the damned thing.

I am aware it could be improved in many other ways as well. As I wrote in the first place it is well suited to the use I'm making of it. Of course I'd be curious to see any suggestion about it both from the UI and the implementation POVs.


In reply to Re^2: String expansion script by blazar
in thread String expansion script by blazar

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.