From your description you gave in the CB, you're looking for it to print 6 lines according to the layout of the template.
It is doing that, bu not as I assume you wish. I'm not all that knowledgeable about Text::Template, but this is what I see happening. You're defining your fields..
@fields = qw(map proto uri1 uri2);
..then you are parsing and passing your data..
if ( @vars{@fields} = $line=~m!(map|reverse_map)\s+(\w+)://(.*?)\s
++\2://(.*?)$! )
{
$result = $template->fill_in(HASH => \%vars);
}
...and your template looks like this..
{$map} {$proto}://{$uri1} {$proto}://{$uri2}
{$map} {$proto}://{$uri1} {$proto}://{$uri2}
{$map} {$proto}://{$uri1} {$proto}://{$uri2}
{$map} {$proto}://{$uri1} {$proto}://{$uri2}
{$map} {$proto}://{$uri2} {$proto}://{$uri1}
{$map} {$proto}://{$uri2} {$proto}://{$uri1}
Now, you read one(1) line, parsed it and passed it to fill in the template. For the first line, your values are going to look like this..
$map => map
$proto =>http
$uri1 => www.digitalcity.com
$uri2 => origin-www.digitalcity.com
When you pass it to $template->fill_in(), it fills in the whole template. So on the line, the template is filled in completely (all six lines) and the results are the first 6 that are printed. Rinse, wash and repeat for the rest of the lines you're parsing.
I assume that this isn't the effect that you want. But to fix it you're going to have to take a different approach. Namely, reading in 6 lines and using different variables on each line to designate which values go where.
There might be a better way using Text::Template but I'm really not all that familiar with the module.
Hope this helps..
Rich
|