The reason your CGI object isn't getting into the package global $q variable is because print_at_form has it's own private lexical (my-created) $q variable, seperate from the package. You can fix this problem by removing the my from the my $q = $_[0];.

That said, you have very bad design here. Subroutines should be independent and reusable whenever possible. You are requiring another, unreleated subroutine to have been used for this to work. For example, what if you wanted to modify your program in the future so it would not always print_at_form when it got the info to make an at job? It would be better to have create_at_job take $q as an argument, and pass it to _untaint as an argument (it would also be nice to rename _untaint into a more informative name like _get_untainted_time, so you can get an idea what it does just be looking at it's name.) It's not going to be much more code to do this, and it makes your code much easier to maintain.

Another note, I don't think letting people start at jobs like this is a good idea -- it opens you up to mean people who would overload your webserver with at started programs.


In reply to Re: accessing CGI object from a subroutine in another package. by wog
in thread accessing CGI object from a subroutine in another package. by kingman

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.