in reply to Re^2: Parsing a string from a file
in thread Parsing a string from a file

Ah, so these are self-created data files? In that case (since you can format the data any way you want) you may want to consider using an existing template solution like Template Toolkit. This way you don't need to worry about eval or anything like that, plus you gets tons of other functionality.
my @time = (1, 2, 3); my $counter = 5; my $data = { counter => $counter, time => \@time, }; my $s = 'Today is [% time.1 %] and you have seen this [% counter %] ti +me[% "s" IF counter > 1 %]!'; warn $s; use Template; my $template = Template->new(); my $out = ''; $template->process(\$s, $data, \$out) or die $template->error; warn $out; __END__ ~~~Output~~~: Today is [% time.1 %] and you have seen this [% counter %] time[% "s" +IF counter > 1 %]! at /tmp/t line 8. Today is 2 and you have seen this 5 times! at /tmp/t line 13.