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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtain variables from a file.

Status
Not open for further replies.

misho88

Technical User
Feb 26, 2006
2
CA
I have a file with a number of lines in the form:

varname=value

What's the easiest way to make this translate into a variable $varname=value ?
 
Code:
open FH, "<file.txt";
my %vars;
while (<FH>) {
  my ($key,$value)=split /=/,$_;
  $vars{$key}=$value;
}
close FH;

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top