See perldoc perlvar for the variable $>, which can be set to 0 to change your effective user to root. However, (and I'm not a sudo expert), I believe this will require that the admins allow you to use Perl as root, which basically means letting you do anything as root, which they don't appear to want to do. I don't know if there's a way to lock Perl down so you can only do things like testing file existence as root, but not things like system('rm -rf /');.

I'd add that if they want you to have read access to some files, there are better ways to do that than giving you sudo to root for certain commands. It'd probably make more sense to set global or group execute permission on the directories in question and read permission on the files, and not involve root access at all. An awful lot of seemingly harmless commands can be dangerous when run as root by someone who knows what he's doing (or doesn't).

Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.


In reply to Re: perl file status and sudo by aaron_baugher
in thread perl file status and sudo by Saved

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.