Dear All, I am in the process of converting about 150 individual data conversion scripts to a single, common script. I have concluded that 99% of the code is common to all users, and just 1% is user-specific. What I want to be able to do is to pass the user-name as a parameter, like "convert client1" and have a sub in the script hook out the relevant block of conversion code. Like so..
common code; include $ARGV[0].code; more common code;
Here's an example of my user-specific code:
if ( m/(\S+),(\S+),(\S+),(\S+),(\S+),(\S+)/o ) { @fields = split(/,/); $CLI = $fields[0]; $key = $fields[1]; $product = $fields[2]; $quantity = $fields[3]; $price = $fields[4]; $salesdate = $fields[5]; }
Problem is, I am not aware of an "include" facility in Perl (called include), and can't think of an obvious workaround. The problem as I see it is that the code segment needs to be pulled in and executed as patr of the main script: will this work ? TIA

In reply to How can i "include" an executable section of code by mildewhall

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.