Advertisement
Guest User

phase2

a guest
May 28th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #use warnings;
  2.  
  3. $file = 'phase2.txt';
  4. open(INFO, $file) or die ("Could not open file.");
  5.  
  6. print "Printing CSV\n";
  7. print "-------------------------------------------\n\n";
  8.  
  9.  
  10. print "Location,Source Subnet,Source Mask,Destination Subnet,Destination Mask\n";
  11.  
  12. foreach $line (<INFO>) {
  13. if ($line =~ /edit/) {
  14. chomp($line);
  15. $format = substr($line, 8);
  16. print "$format,";
  17. }
  18.  
  19.  
  20. if ($line =~ /src-name/) {
  21. chomp($line);
  22. @values = split(' ', $line);
  23. split @values, 0, 2;
  24. print "$values[2],";
  25. }
  26.  
  27. if ($line =~ /dst-name/) {
  28. chomp($line);
  29. @values = split(' ', $line);
  30. split @values, 0, 2;
  31. print "$values[2]\n";
  32. }
  33.  
  34.  
  35. if ($line =~ /src-subnet/) {
  36. chomp($line);
  37. @values = split(' ', $line);
  38. splice @values, 0, 2;
  39. foreach $val (@values) {
  40. print "$val,";
  41. }
  42.  
  43. }
  44.  
  45. if ($line =~ /dst-subnet/) {
  46. chomp($line);
  47. @values = split(' ', $line);
  48. split @values, 0, 2;
  49. print "$values[2],";
  50. print "$values[3]\n";
  51. }
  52.  
  53.  
  54.  
  55. }
  56.  
  57. print "\n\n-----------------------------------------------\n\n";
  58.  
  59. close(INFO);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement