For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > December 2005 > use vars









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author use vars
Beast

2005-12-15, 7:55 am


In perlmodlib :

vars Predeclare global variable names (obsolete)

If this is obselete then what is the newer version of predeclare global
variables?


Basically I just want to include config file (variables which can be
changed by users, ie. path ) and it should available to all
programs/modules.

Any better way other than use vars?



myconfig:
---------
$input_dir = "/home/yourname/data";
$tmp_dir = "/home/yourname/tmp";
# etc...
return 1;


myprogram.pl
------------
#!/usr/bin/perl

use strict;
use warnings;

use vars qw( $input_dir $tmp_dir);

require "/etc/myprogram/myconfig";

# etc...
#




--

--beast

Adriano Ferreira

2005-12-15, 6:57 pm

On 12/15/05, Beast <beast@i6x.org> wrote:
> In perlmodlib :
> vars Predeclare global variable names (obsolete)


> If this is obselete then what is the newer version of predeclare global
> variables?


Replace things like

use vars qw($FOO)

with

our $FOO;

(unless you need to assure compatibility for versions before 5.6).
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com