Apart from use and require it as also possible to do a file. On the file include spectrum, do would be the rawest method, and use would be the most refined.

It should be noted in passing that #include as a concept doesn't really pan out in Perl. Yes, you can embed perl code in external files, but then you must ensure that the code is run a perfectly trusted environment, otherwise Really Bad Shi^WThings can happen. That is, even if a user cannot modify your code, if they can edit a config file that is Perl code waiting to be eval'ed, then you are wide open in terms of security vulnerabilities.

A better approach is to use configuration files to store data, and parse it all. There are a number of modules that make this simple to do. For instance, if you are familiar with Win32-style .ini files, there is a module to do that, and a few more besides.

In any event, you should also read perlsec and tainting, to be make sure that people don't try and make your program do naughty things, like rm -rf /.

--
g r i n d e r
just another bofh

print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u';

In reply to Re: Include statement in Perl? by grinder
in thread Include statement in Perl? by Ashte

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.