in reply to Processing CSV File
The important changes I made to your code:#!/usr/bin/perl use warnings; use strict; open my $TEMPLATE, '<', 'rtr-template.txt' or die "Template: $!"; my @template = <$TEMPLATE>; while (<>) { chomp; my ($location, $name, $lo0ip, $frameip, $framedlci, $eth0ip) = split (/,/); my $ofile_name = $name . ".txt"; open my $OUT, '>', $ofile_name or die "Output: $!"; for my $line (@template) { $_ = $line; s/##location##/$location/; s/##rtrname##/$name/; s/##eth0-ip##/$eth0ip/; s/##loop0-ip##/$lo0ip/; s/##frame-ip##/$frameip/; s/##frame-DLCI##/$framedlci/; print {$OUT} $_; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Processing CSV File
by Perl3r (Novice) on Oct 03, 2012 at 23:21 UTC | |
by runrig (Abbot) on Oct 03, 2012 at 23:32 UTC | |
by choroba (Cardinal) on Oct 04, 2012 at 07:54 UTC |