hmmm. Something is wrong that I can't figure out:

#!/usr/bin/perl -w use strict; use Text::Template; my %vars; my $line; my @fields; my $result; my $file = "/home/trixee/20010814/remap.tmpl"; my $cfg = "/home/trixee/20010814/remap.config"; my $template = new Text::Template (SOURCE => $file) or die "Couldn't construct template: $Text::Template::ERROR"; open FH, "$cfg" or die "$!\n"; while ($line = <DATA>) { chomp $line; next if ($line =~ /^\#/); @fields = qw(map proto uri1 uri2); if ( @vars{@fields} = $line=~m!(map|reverse_map)\s+(\w+)://(.*?)\s ++\2://(.*?)$! ) { $result = $template->fill_in(HASH => \%vars); } if ($result) { print "$result\n"; } else { die "Couldn't fill in template: $Text::Template::ERROR" } } __DATA__ # Automatic mapping tables generated from Magma map http://www.digitalcity.com http://origin-www.digitalcity.com map tunnel://www.digitalcity.com tunnel://origin-www.digitalcity.com map http://10.0.2.1 http://origin-www.digitalcity.com map tunnel://10.0.2.1 tunnel://origin-www.digitalcity.com reverse_map http://origin-www.digitalcity.com http://www.digitalcity.c +om reverse_map tunnel://origin-www.digitalcity.com tunnel://www.digitalci +ty.com Template: {$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}

prints

map http://www.digitalcity.com http://origin-www.digitalcity.com map http://www.digitalcity.com http://origin-www.digitalcity.com map http://www.digitalcity.com http://origin-www.digitalcity.com map http://www.digitalcity.com http://origin-www.digitalcity.com map http://origin-www.digitalcity.com http://www.digitalcity.com map http://origin-www.digitalcity.com http://www.digitalcity.com map tunnel://www.digitalcity.com tunnel://origin-www.digitalcity.com map tunnel://www.digitalcity.com tunnel://origin-www.digitalcity.com map tunnel://www.digitalcity.com tunnel://origin-www.digitalcity.com map tunnel://www.digitalcity.com tunnel://origin-www.digitalcity.com map tunnel://origin-www.digitalcity.com tunnel://www.digitalcity.com map tunnel://origin-www.digitalcity.com tunnel://www.digitalcity.com map http://10.0.2.1 http://origin-www.digitalcity.com map http://10.0.2.1 http://origin-www.digitalcity.com map http://10.0.2.1 http://origin-www.digitalcity.com map http://10.0.2.1 http://origin-www.digitalcity.com map http://origin-www.digitalcity.com http://10.0.2.1 map http://origin-www.digitalcity.com http://10.0.2.1 map tunnel://10.0.2.1 tunnel://origin-www.digitalcity.com map tunnel://10.0.2.1 tunnel://origin-www.digitalcity.com map tunnel://10.0.2.1 tunnel://origin-www.digitalcity.com map tunnel://10.0.2.1 tunnel://origin-www.digitalcity.com map tunnel://origin-www.digitalcity.com tunnel://10.0.2.1 map tunnel://origin-www.digitalcity.com tunnel://10.0.2.1 reverse_map http://origin-www.digitalcity.com http://www.digitalcity.c +om reverse_map http://origin-www.digitalcity.com http://www.digitalcity.c +om reverse_map http://origin-www.digitalcity.com http://www.digitalcity.c +om reverse_map http://origin-www.digitalcity.com http://www.digitalcity.c +om reverse_map http://www.digitalcity.com http://origin-www.digitalcity.c +om reverse_map http://www.digitalcity.com http://origin-www.digitalcity.c +om reverse_map tunnel://origin-www.digitalcity.com tunnel://www.digitalci +ty.com reverse_map tunnel://origin-www.digitalcity.com tunnel://www.digitalci +ty.com reverse_map tunnel://origin-www.digitalcity.com tunnel://www.digitalci +ty.com reverse_map tunnel://origin-www.digitalcity.com tunnel://www.digitalci +ty.com reverse_map tunnel://www.digitalcity.com tunnel://origin-www.digitalci +ty.com reverse_map tunnel://www.digitalcity.com tunnel://origin-www.digitalci +ty.com

Why?


In reply to Re: Re: Reading in N lines at a time by Tuna
in thread Reading in N lines at a time by Tuna

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.