Guest User

Untitled

a guest
May 21st, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. START
  2.  
  3. #!/usr/bin/env perl
  4. use strict;
  5. use warnings;
  6.  
  7. while (<>) {
  8. if (/START/../END/) {
  9. next if /START/ || /END/;
  10. print;
  11. }
  12. }
  13.  
  14. perl -ne 'print if /START/ .. /END/' file1 file2 ...
  15.  
  16. perl -0777 -ne 'print "$1n" while /START(.*?)END/gs' file1 file2 ...
  17.  
  18. while (<>) {
  19. $in_header = 1 .. /^$/;
  20. $in_body = /^$/ .. eof;
  21. # now choose between them
  22. } continue {
  23. $. = 0 if eof; # fix $.
  24. }
  25.  
  26. #!/usr/bin/perl
  27.  
  28. use strict;
  29. use warnings;
  30.  
  31. my $start='CINFILE=$';
  32. my $stop='^#$';
  33. my $filename;
  34. my $output;
  35. my $counter=1;
  36. my $found=0;
  37.  
  38. while (<>) {
  39.  
  40. # Find block of lines to extract
  41. if( /$start/../$stop/ ) {
  42.  
  43. # Start of block
  44. if( /$start/ ) {
  45. $filename=sprintf("boletim_%06d.log",$counter);
  46. open($output,'>>'.$filename) or die $!;
  47. }
  48. # End of block
  49. elsif ( /$end/ ) {
  50. close($output);
  51. $counter++;
  52. $found = 0;
  53. }
  54. # Middle of block
  55. else{
  56. if($found == 0) {
  57. print $output (split(/ /))[1];
  58. $found=1;
  59. }
  60. else {
  61. print $output $_;
  62. }
  63. }
  64.  
  65. }
  66. # Find block of lines to extract
  67.  
  68. }
  69.  
  70. while (<>) {
  71. chomp; # strip record separator
  72. if(/END/) { $f=0;}
  73. if (/START/) {
  74. s/.*START//g;
  75. $f=1;
  76. }
  77. print $_ ."n" if $f;
  78. }
  79.  
  80. #!/usr/bin/env perl
  81. use strict;
  82. use warnings;
  83.  
  84. my $start='CINFILE=$';
  85. my $stop='^#$';
  86. my $filename;
  87. my $output;
  88. my $counter=1;
  89. my $found=0;
  90.  
  91. while (<>) {
  92. if (/$start/../$stop/) {
  93. $filename=sprintf("boletim_%06d.log",$counter);
  94. open($output,'>>'.$filename) or die $!;
  95. next if /$start/ || /$stop/;
  96. if($found == 0) { print $output (split(/ /))[1]; }
  97. else { print $output $_; }
  98. $found=1;
  99. } else { if($found == 1) { close($output); $counter++; $found=0; } }
  100. }
Add Comment
Please, Sign In to add comment