Anish Kumar K. <[EMAIL PROTECTED]> asked:
> Say I have a string called returned from the text file..
I don't understand this part. I assume from context that
you want to use a template.
> I could very well use substition for the variables
> individually. But it will be nice If I could substitute this at bulk..
If you don't want to use big guns to shoot sparrows
(i.e. use Template::Toolkit) then you could do it
easily like this:
#!/usr/bin/perl -w
use strict;
# put your key/value pairs into a hash
my %var = qw( name Thomas foo bar );
my $template;
# slurp in template
{
local $/ = undef;
$template = <DATA>;
}
# do bulk substitution
$template =~ s/##(.*?)##/$var{$1}/eg;
print $template;
__DATA__
Hello ##name##,
The value of foo is '##foo##'.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>