Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. 1 #!/usr/bin/perl
  2. 2
  3. 3 use strict;
  4. 4 use warnings;
  5. 5 use diagnostics;
  6. 6 use Excel::Writer::XLSX;
  7. 7
  8. 8 #open text file and get all the EDI IDs
  9. 9 #based on the @ARGV selected, populate the selected column in Excel
  10. 10 # if value is found in the initial row, populate that row instead
  11. 11 #
  12. 12 #
  13. 13
  14. 14 #Initialize Values
  15. 15 #
  16. 16 if (@ARGV == 0){
  17. 17 die "Please input which tool you would like to check";
  18. 18 }
  19. 19
  20. 20 if ($ARGV[0] eq "JP"){
  21. 21 &Juniper();
  22. 22
  23. 23 };
  24. 24 if ($ARGV[0] eq "GP"){
  25. 25 print "Updating GlobalProtect Column";
  26. 26 };
  27. 27 if ($ARGV[0] eq "WS"){
  28. 28 print "Updating Webservices Column";
  29. 29
  30. 30 };
  31. 31
  32. 32 sub Juniper {
  33. 33 print "Updating Spreadsheet with Juniper\n";
  34. 34 open(DATA, "<file.txt") || die "Couldn't open file file.txt, $!\n";
  35. 35 my @line = <DATA>;
  36. 36 foreach my $line (@line){
  37. 37 if($line =~ /\b\w\w\d{4}\w\b/){
  38. 38 print "Found ". $line ;
  39. 39 my $Cell_Value;
  40. 40 my $workbook = Excel::Writer::XLSX->new('migration.xlsx');
  41. 41 my $worksheet = $workbook->add_worksheet();
  42. 42 $worksheet->write($Cell_Value , 0 , $line );
  43. 43 $Cell_Value+= 1;
  44. 44 $workbook->close() || die "Unable to close $!";
  45. 45 };
  46. 46 }
  47. 47 close(DATA) || die "Couldn't close file properly\n";
  48. 48 print "Exiting Subroutine\n";
  49. 49 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement