Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #use warnings;
- $file = 'phase2.txt';
- open(INFO, $file) or die ("Could not open file.");
- print "Printing CSV\n";
- print "-------------------------------------------\n\n";
- print "Location,Source Subnet,Source Mask,Destination Subnet,Destination Mask\n";
- foreach $line (<INFO>) {
- if ($line =~ /edit/) {
- chomp($line);
- $format = substr($line, 8);
- print "$format,";
- }
- if ($line =~ /src-name/) {
- chomp($line);
- @values = split(' ', $line);
- split @values, 0, 2;
- print "$values[2],";
- }
- if ($line =~ /dst-name/) {
- chomp($line);
- @values = split(' ', $line);
- split @values, 0, 2;
- print "$values[2]\n";
- }
- if ($line =~ /src-subnet/) {
- chomp($line);
- @values = split(' ', $line);
- splice @values, 0, 2;
- foreach $val (@values) {
- print "$val,";
- }
- }
- if ($line =~ /dst-subnet/) {
- chomp($line);
- @values = split(' ', $line);
- split @values, 0, 2;
- print "$values[2],";
- print "$values[3]\n";
- }
- }
- print "\n\n-----------------------------------------------\n\n";
- close(INFO);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement