in reply to Re^2: Defining directory/Datas the perl script should work with
in thread Defining directory/Datas the perl script should work with
"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
|
|---|