You don't tell us what errors you get. Also, you have no error checking when you eval your script. Even more, the code is horribly ugly and unformatted and not at all self-contained so it's quite hard to guess what it does. I'm rewriting it with more legible syntax and some added error checking - that might help you to diagnose the exact error you get:

subfile('iocommon'); sub subfile { my($f)=@_; my($w); # %GOT_HA seems to be a variable emulating %INC maybe? if(!$GOT_HA{$f}){ # where do $my_base_loc, $subslocation and $ds come from? # is that a case for using File::Spec instead? $f=("$my_base_loc$subslocation$ds$f.sub"); # you need error handling here in case the file is not found: # Are $t and $rep global variables? What are they used for? $t=open (IE,"$f") or die "Couldn't open '$f': $!"; $rep=($t)?'OK':$!; # What does that do? Maybe you want to look in that log for th +e error report? db("subfile $f",$rep); # Are you using strict; at all? You really should! # This whole section is likely better written as # my $w = do { local $/; <IE> }; @tt=<IE>; close(IE); while(@tt){ $l=trim(shift @tt); $w.=$l."\n"; } eval($w); if (my $err = $@) { die "Error in evaluating '$f': $!"; }; $GOT_HA{$f}=1; } }

Update: The below recommendations of using do or Module::Pluggable sound very good to me and especially do or require should have occurred to me had I looked at the bigger picture...


In reply to Re: Subroutine problems by Corion
in thread Subroutine problems by anir_pandit

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.