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..
..then you are parsing and passing your data..@fields = qw(map proto uri1 uri2);
...and your template looks like this..if ( @vars{@fields} = $line=~m!(map|reverse_map)\s+(\w+)://(.*?)\s ++\2://(.*?)$! ) { $result = $template->fill_in(HASH => \%vars); }
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} {$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}
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.$map => map $proto =>http $uri1 => www.digitalcity.com $uri2 => origin-www.digitalcity.com
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
In reply to Re: Re: Re: Reading in N lines at a time
by rchiav
in thread Reading in N lines at a time
by Tuna
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |