Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using "do" to include a file with variable declarations 1

Status
Not open for further replies.

whitshea

Programmer
Sep 16, 2001
7
0
0
US
I have a perl script which telnets to remote hosts and starts up other scripts on these hosts. Currently, I have a text config file, which I have to read in line by line and parse to get host names, user names, passwords, etc. I would rather just have this info in a separate file, with the variables already given values... I don't want to just hard code this info in my main script, because the data is likely to change in the future. Would I be able to use the "do" function to include a perl file full of variable declarations into my main script? Or will these variables disappear as soon as the included script is read? I have no idea. Please help or give other advice. Thanks!
 
here's a setup i've used.
first, in the actual script, i put the lines:[tt]
use vars qw($database $background $foreground ...);
require "setup.pl";
[/tt]
then, in setup.pl, i just have:[tt]
$database = "/usr/local/data/details.db";
$background = "00f03e";
$foreground = "ffff00";
# &c.
[/tt]
and the variables will be set. "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top