in reply to Returning Variables from files
You can obviously get a bit more fancy with the get_value subroutine --Dave.my %values = (title => "A Title"); sub get_value { my $key = shift; return exists($values{$key}) ? $values{$key} : "UNKNOWN"; } my $file = "User.htm"; open IN, "<$file" or die "can't read file: $file"; while (<IN>) { s/\$(\w+)/get_value($1)/ge; print; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Returning Variables from files
by Anonymous Monk on Jul 21, 2002 at 22:10 UTC |