DieringerC has asked for the wisdom of the Perl Monks concerning the following question:
I have not used Perl in several years and decided it would be the best choice for my project; I am not getting any output or warnings any assistance would be greatly appreciated.
hosts.csv data: R17N6340-C04-1;10.1.70.1 R17N6340-C04-2,10.1.70.2 R17N6340-C04-3,10.1.70.3 #!/usr/bin/perl #use strict; #use warnings; my $xml_file = 'template.txt'; my $list_file = 'hosts.csv'; my $out_file = 'newhost.xml'; # open( XML, '<:utf8', $xml_file ); open( LIST, '<:utf8', $list_file ); open( OUT, '>>:utf8', $out_file ); my $xml; { local $/ = undef; $xml = <XML>; }; my $line; foreach $line ( <LIST> ) { # Skipping if the line is empty or a comment next if $line =~ /^\s*$/ ; next if $line =~ /^\s*#/ ; my ($hostname, $interface) = split(/,/, $lin); $xml =~ s/hostname/$hostname/g; $xml =~ s/interface/$interface/g; } print XML $xml; close
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: no output
by toolic (Bishop) on Apr 06, 2016 at 16:48 UTC | |
|
Re: no output
by Eily (Monsignor) on Apr 06, 2016 at 16:53 UTC | |
|
Re: no output
by jellisii2 (Hermit) on Apr 06, 2016 at 21:54 UTC | |
|
Re: no output
by stevieb (Canon) on Apr 06, 2016 at 17:04 UTC | |
by DieringerC (Initiate) on Apr 06, 2016 at 20:46 UTC | |
by GrandFather (Saint) on Apr 07, 2016 at 01:22 UTC | |
|
Re: no output
by Anonymous Monk on Apr 06, 2016 at 18:04 UTC | |
|
Re: no output
by marto (Cardinal) on Apr 06, 2016 at 17:27 UTC |