use vars qw( $q $db $html

Hi experts,
I have q few scripts that all need the variables declared with use vars qw( $q $db $html ..........

Now since the variables are more than 300 and all the scripts use the same variables I just wnated to save all the variables in a file and then call the file directly from each script something like:

foreach $line (@filewithvariables) {
print "use vars qw( $line)";
}

so that I do not have to waste 300 lines in any script.

Do you have any suggestions?


thanks for your time
rcinformaticaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
use declatations;

where declarations.pm contains

use vars qw( $q $db $html);
1;
rcinformaticaAuthor Commented:
Thanks for the answer, but  I get the message

Global symbol "$database" requires explicit package name at /var/  ..... and the same for all the other variables

I need the use stricts for variables

any clue?

thanks
MysidiaCommented:
I can't help but think that "300 variables" all declared out globally
is very big indication of a poor design.

Perhaps you really want

  do 'declarations.pm';

instead of  use declarations;
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

ahoffmannCommented:
# or
require 'declarations.pm';
rcinformaticaAuthor Commented:
still getting the same error,

 I agree with you about the poor design, those variables are language translation to make the script multilanguage
ahoffmannCommented:
# quick&dirty:
use vars qw( $::q $::db $::html);
rcinformaticaAuthor Commented:
sorry I don 't understand use vars qw( $::q $::db $::html);

maybe I did not make myself clear enough, this is what I need to have in each file:

#!/usr/bin/perl
use CGI;
use strict;
use vars qw(
$q
$db
$html
$database
$msg1
$msg2
$msg3
$msg4
$msg5
$msg6
$msg7
$msg8
$msg9
..........
.........
$msg300
);

and I would lke not to have all 300 lines written in each file

thanks
MysidiaCommented:
BEGIN { require 'declarations_file'; }
...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rcinformaticaAuthor Commented:
thanks guys it works now


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.