I have some perl modules that were left behind by some consultants. They didn't use strict (and when they set stuff up I didn't know enough to make them). I'm trying to extend their work and reuse their code, but it's kludgey, doesn't use strict and some of it just doesn't work.

So I've set about to refactor. I'm trying to build in some safety nets and I'm trying to do some things right. Here's what I've done:

I'm getting a little stuck on the baselining and test harnessing. I haven't used Test::Anything before and am reading those. I started with:
perl -lne "print $1 if /^\W*sub (.*)/i" harcommon.pm
to get a list of subs and then wrote this (with help from chatterboxers) to test them:

#!/usr/bin/perl use harcommon; my @funclist = qw(udpinifile colsep remove_duplicates runsql runhsql get_ini_setting create_min_ini delete_min_ini get_ini_file get_os get_tempdir get_s +lash file_exists display_text debug trim rtrim ltrim date_string extension_in_list string_in_list unlock_user exiterror capture_file + transfer_file delete_file execute_cmd find_user_home version get_cl +ear_pass get_pass get_vp get_full_item get_item get_version_num get_ext get_item_minus_ext); my %dispatch; #$dispatch{$_}=*{$_}{'CODE'} foreach @funclist; #also works $dispatch{$_}=\&{"harcommon::$_"} foreach @funclist; { local $\="\n"; foreach my $func (@funclist) { print '==========================='; print $func; #print $dispatch{$func}; print '==========================='; print harcommon->$func() } }

(I'm not using strict because they're not using strict and it just blows up totally; I intend to use strict after I've got the baseline of what they do now).

Some of their functions run without args, some work without args but give screwy results, some kill the script and block the rest of the tests. I want to go function by function and make a set of test args so at least I'm calling them in good faith for the baseline. What data structure should I use to represent the function args?


I humbly seek wisdom.

In reply to Data Structures design help to represent function args for testing by goibhniu

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.