{$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} #### map http://chat.yahoo.com http://origin-chat.yahoo.com map tunnel://chat.yahoo.com tunnel://origin-chat.yahoo.com map http://10.0.2.7 http://origin-chat.yahoo.com map tunnel://10.0.2.7 tunnel://origin-chat.yahoo.com reverse_map http://origin-chat.yahoo.com http://chat.yahoo.com reverse_map tunnel://origin-chat.yahoo.com tunnel://chat.yahoo.com map http://shop.yahoo.com http://origin-shop.yahoo.com map tunnel://shop.yahoo.com tunnel://origin-shop.yahoo.com map http://10.0.2.8 http://origin-shop.yahoo.com map tunnel://10.0.2.8 tunnel://origin-shop.yahoo.com reverse_map http://origin-shop.yahoo.com http://shop.yahoo.com reverse_map tunnel://origin-shop.yahoo.com tunnel://shop.yahoo.com #### #!/usr/bin/perl -w use strict; use Text::Template; my %vars; my $lines; my @lines; my $file = "/home/trixee/remap.config"; my $template = new Text::Template (TYPE => 'FILE' , SOURCE => $file) or die "Couldn't construct template: $Text::Template::ERROR"; open FH, "$file" or die "$!\n"; while ($lines = ) { chomp $lines; next if ($lines =~ /^\#/); if ($lines=~/(\d+)(\s+)(map|reverse_map)(\s+)(\w+)\:\/\/(.*?)(\s+)(\5)\:\/\/(.*?)$/) { $vars{'d'} = $1; $vars{'map'} = $3; $vars{'proto'} = $5; $vars{'uri1'} = $6; $vars{'uri2'} = $8; } } my $result = $template->fill_in(HASH => \%vars); if (defined $result) { print $result } else { die "Couldn't fill in template: $Text::Template::ERROR" }