tarunlewis has asked for the wisdom of the Perl Monks concerning the following question:

What is:-
use 5.005; use strict; use integer; use Getopt::Std;
I have read up on the material that I have on Perl, and found out what "use strict" means. It prompts the programmer to declare all variables. Does "use integer" mean that all variables declared are integers by default?

I am going to be hired in a Clinical Trials company next month. Hopefully by then I'll have something worth while to contribute to this forum. Sorry I don't have the expertise to do that so far.

Cheers,
Tarun Lewis

janitored by ybiC: Minor format tweaks, including balanced <code> tags around code snippet, for legibility

Replies are listed 'Best First'.
Re: Trouble with understanding code
by jpeg (Chaplain) on Mar 03, 2005 at 08:23 UTC
    use 5.005
    means the script requires 5.005 or better.

    use integer
    is a pragma. It doesn't mean that all variables are integers, but it's a directive that instructs perl's arithmetic and comparison operators to pretend they're working on integers.

    use Getopt::Std
    tells perl to use the Getopt::Std module.

    If you're learning perl, it would be a great idea to get familiar with perldoc. just type 'perldoc Getopt::Std' for modules you see or 'perldoc -f split' for functions.

Re: Trouble with understanding code
by holli (Abbot) on Mar 03, 2005 at 08:07 UTC
    From perldoc integer
    This tells the compiler to use integer operations from here to the end of the enclosing BLOCK. On many machines, this doesn't matter a great deal for most computations, but on those without floating point hardware, it can make a big difference in performance.


    holli, /regexed monk/
Re: Trouble with understanding code
by manav (Scribe) on Mar 03, 2005 at 10:38 UTC
    Apart from all the comments posted, see
    perldoc -f use
    That has answers to most of the questions you have.
    Also see
    perldoc perlmodlib
    for a list of standad modules and pragmas

    Manav
Re: Trouble with understanding code
by jbrugger (Parson) on Mar 03, 2005 at 08:14 UTC
    You could look at cpan, for the modules:
    Getopt::Std - The getopt() function processes single-character switches with switch clustering. Pass one argument which is a string containing all switches that take an argument. For each switch found, sets $opt_x (where x is the switch name) to the value of the argument if an argument is expected, or 1 otherwise. Switches which take an argument don't care whether there is a space between the switch and the argument.

    The getopts() function is similar, but you should pass to it the list of all switches to be recognized. If unspecified switches are found on the command-line, the user will be warned that an unknown option was given.

    Note that, if your code is running under the recommended use strict 'vars' pragma, you will need to declare these package variables with "our":

    integer - Perl pragma to use integer arithmetic instead of floating point