| [reply] [d/l] |
See the vars pragma docs for an explanation (Many Perl docs can be found on http://www.perldoc.com/).
In short, use vars qw($opt_h); declares the global variable $opt_h. In Perl one doesn't need to declare variables prior to using them, but for anything non-trivial it's strongly advised to do so nevertheless. This can be enforced by using the strict pragma (use strict;), from this line on, all variables must be declared with my or our (see the docs for the strict pragma).
Hope this helps, -gjb-
| [reply] [d/l] [select] |
The script you're looking at is probably using the Getopt::Std module, which makes it easy to pass in parameters as flags from the command line. For example, a program called like this:
./grobilize.pl -t 20 -n 44
will end up containing the variables $opt_t and $opt_n, set to the appropriate value. Like the earlier posts have explained, if you have use strict on (as you should), you need to pre-declare those as globals to avoid getting a compile-time error.
| [reply] [d/l] [select] |
Hi ,
The vars is for the package scoped global variable and usually used like you say when the program is to be run with options ,the use vars being used for globally scoped options and variables | [reply] |