Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Returning Variables from files

by cjf (Parson)
on Jul 21, 2002 at 21:01 UTC ( #183871=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Returning Variables from files
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://183871]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2015-07-31 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls