"I think I still have some questions to this code"

I'm pleased to see that you are not a cargo cult programmer. See "Cargo cult programming" if you are unfamiliar with that term.

I provided a variety of links which you should follow. The one to perlsec explains the inclusion of the BEGIN block. If you're stumped by the meaning of the BEGIN itself, read "perlmod: BEGIN, UNITCHECK, CHECK, INIT and END". You may also want to look at: the delete() function; "perldata: Slices"; "perlvar: %ENV"; and, perlop for qw (search the page: qw appears in a number of places). You can also try commenting out the BEGIN line, running with the taint checking I showed (perl -T ...); then checking the messages output.

I'm not too sure about "sub_" as it doesn't appear in my code (perhaps a typo in your code). There are two subroutine declarations of the form sub _name {...}. These are called earlier in the code with _name(...). Prefixing a subroutine name with an underscore is an informal way of indicating it is intended to be private (used by the code itself, but not directly called by the user of the code): this is fairly common practice and you're likely to encounter it in many places. Also look at perlsub; in particular, the To declare subroutines: and To call subroutines: sections of its SYNOPSIS.

If you have GetOptions::LONG in your code, it's a fairly major typo: the first 'O' should be lowercase; there's no 'ions'; and, the last part is capitalised, not all uppercase. Case and spelling matter. I wrote: "use Getopt::Long;" at line 14 and "GetOptions(...);" at line 17. You may have somehow confused those two lines, omitted a semicolon near those lines, or something else: without seeing exactly what code you wrote, I'm completely guessing.

That covers everything you enquired about. If more questions arise, feel free to ask.

— Ken


In reply to Re^3: Defining directory/Datas the perl script should work with by kcott
in thread Defining directory/Datas the perl script should work with by perlnewbie

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.