boo hiss! I hate seeing one Perl script calling another. Sloppy...

What might help you out is to do one of two things in descending levels of difficulty:

In the first case you'd have to take the time to examine what Cart.pl does and write a module for it that does the same thing. Not quite as easy as just doing
$ cp Cart.pl Cart.pm
you'd actually have to wrap the logic in some fashion that makes sense. For instance, here's a small Perl script I want to convert.
#!/usr/bin/perl -w use strict; # # This is the main part of the script here... my ($parm1,$parm2,$parm3,$parm4)=@ARGV; func1($parm1,$parm2) $func2($parm3,$parm4) exit(0); sub func1{ #logic here. } sub func2{ #logic here } | | etc |
which could become:
package Cart; sub new { shift; my $self={}; bless $self,"Cart"; return $self; } sub doCart { my ($self,$parm1,$parm2,$parm3,$parm4)=@_; # main part of original script goes here } sub func1{ } sub func2{ } 1;
You could then invoke it as:
#!/usr/bin/perl -w use strict; use lib qw @ /path/to/directory/my/binary/runs/from @; use Cart; my $cart = new Cart(); | | hand waving | $cart->doCart($arg1,$arg2,$arrg3,$arrr_ahoy_matey); | | etcetera... |
the important part is the use lib part which causes Perl to look for your module where it lives. In this case I'm saying the same place the script lives. You could also do
use FindBin qw/ $Bin /; use lib "$Bin"; | etc

Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

In reply to Re: system command with arguments Error by blue_cowdawg
in thread system command with arguments Error by ansh batra

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.