Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. use warnings;
  2. use File::Compare;
  3. use File::Copy;
  4.  
  5. sub loop {
  6. $pid= system("start gvim $script");
  7. print "$pid\n";
  8. $exists=kill 0, $pid;
  9. print "PID existe\n" if ($exists);
  10. # system("cls");
  11. $compare=compare("$script","$script_bkp" );
  12. print "$compare\n";
  13. while(1){
  14. # system("cls");
  15. system("$comando $script $archivo" );
  16. sleep 3;
  17. $x=1;
  18. # print "$compare\n";
  19. $compare=compare("$script","$script_bkp" );
  20. while($compare==0){
  21. sleep 1;
  22. print "$x segundos dentro del loop...\n";
  23. $x++;
  24. $compare=compare("$script","$script_bkp" );
  25. print "$exists todavia existe.." if($exloop;ists);
  26. }
  27. # unless ($exists) {last}
  28. copy($script,$script_bkp)
  29. }
  30. }
  31.  
  32. print "#### TIPO DE ARCHIVO PARA EDITAR ####\n";
  33. print "\n";
  34. print "Nombre del Script: ";
  35. $input=<STDIN>;
  36. chomp($input);
  37.  
  38. print "Nombre del archivo a filtrar: ";
  39. $archivo=<STDIN>;
  40. print "\n";
  41.  
  42.  
  43. print "Tipo de script?\n";
  44. print "Opciones: AWK,SED o PERL :";
  45.  
  46. while(<>){
  47. if(m/^(sed)$/i){
  48. $comando="sed -f";
  49. $ext_1=".sed";
  50. $ext_2="_bkp.sed";
  51. last;
  52. }
  53. elsif(m/^(awk)$/i){
  54. $comando="awk -f";
  55. $ext_1=".awk";
  56. $ext_2="_bkp.awk";
  57. last;
  58. }
  59. elsif(m/^(perl)$/i){
  60. $comando="perl -f";
  61. $ext_1=".pl";
  62. $ext_2="_bkp.pl";
  63. last;
  64. }
  65. else{
  66. exit;
  67. }
  68. }
  69. $script="$input$ext_1";
  70. $script_bkp="$input$ext_2";
  71. print "$script\n";
  72. if ( -e $script){
  73. print "archivo existe, desa editarlo?\nSi/No\n";
  74. while (<>){
  75. if(m/^(si)$/i){
  76. loop;last;
  77. }
  78. elsif(m/^(no)$/i){
  79. last;
  80. }
  81. else{
  82. print "Debe escojer si o no\n";
  83. sleep 1;
  84. }
  85. }
  86. }else{
  87. print "no existe\n";
  88. open(FILE, ">$script");
  89. print FILE 'print "hola\n";';
  90. close(FILE);
  91.  
  92. unless ( -e $script_bkp ){
  93. copy($script,$script_bkp);
  94.  
  95. }
  96. loop;last;
  97. }
  98. exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement