http://qs321.pair.com?node_id=183871


in reply to Returning Variables from files

What format is the data in?

Assuming var_name=var_value format, and only working with scalars, try the following:

open HEADER, "header.txt" or die $!; my %variables; while (<HEADER>) { chomp; my ($name, $value) = split /=/; $variables{$name} = $value; } close HEADER; print <<EOF; <html> <head> <title>$variables{title}</title> </head> <body> <p>Hello $variables{name}</p> </body> </html> EOF

That should work if each name/value pair is separated by a newline.