I am probably reinventing the wheel here but I am attempting to correct a problem i glossed over earlier. I am basically making a call to a sub in another file that I have included using require. When i run it I get the error shown below.

Basically $request_hash is a hash of headers for use with mechanize and sometimes the request requires special handling (date updated and appended, particular cookie added, servers changed, etc.) so it needs to call a function in a another file. The function name is added to the headers as Logic: function_name. This is done manually and the function is added to the request_logic.pl. I am trying to figure out what I am doing wrong. I have used no strict "refs" here, the code works fine that way, and that is wrong. The code works great though, i just want the correct syntax. Any input, ideas, or help would be appreciated.

As a note nnnnn exists as a test function in request_logic.pl. I did not post the whole thing because its about 700 lines now. subs::dbg is the logging function i use.

thanks.

p.s. this is my first posted question, so please forgive me for any formatting mistakes in it. but perlmonks has been an awesome resource. thanks again.

if ($request_hash{Logic}) { no strict "refs"; subs::dbg($log_file, 0, "<$script_file> This is the Logic: $requ +est_hash{Logic} \n\n"); $function_name = "request_logic::".$request_hash{Logic}; + eval{$returned_hash_ref = &$function_name($request_hash_ref, $lo +g_file)}; #should call any set function name if ($@) { subs::dbg($log_file, 0, "<$script_file> Error from eval: $@"); #i +f there is an eval error } else { subs::dbg($log_file, 0, "<$script_file> Hash returned from +moodification from function $function_name"); subs::dbg($log_file, 0, Dumper $returned_hash_ref); } delete($request_hash{Logic}); #delete the ha +sh value with the logic in it }
This is the error.
201017 05:28 - <test_check.script> Error from eval: Can't use string ( +"request_l ogic::nnnnn") as a subroutine ref while "strict refs" in use at web_ac +torv.0755. pl line 282, <ACT> line 55.

In reply to use strict refs unless you can't figure out the syntax by theleftsock

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.