Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- START
- #!/usr/bin/env perl
- use strict;
- use warnings;
- while (<>) {
- if (/START/../END/) {
- next if /START/ || /END/;
- print;
- }
- }
- perl -ne 'print if /START/ .. /END/' file1 file2 ...
- perl -0777 -ne 'print "$1n" while /START(.*?)END/gs' file1 file2 ...
- while (<>) {
- $in_header = 1 .. /^$/;
- $in_body = /^$/ .. eof;
- # now choose between them
- } continue {
- $. = 0 if eof; # fix $.
- }
- #!/usr/bin/perl
- use strict;
- use warnings;
- my $start='CINFILE=$';
- my $stop='^#$';
- my $filename;
- my $output;
- my $counter=1;
- my $found=0;
- while (<>) {
- # Find block of lines to extract
- if( /$start/../$stop/ ) {
- # Start of block
- if( /$start/ ) {
- $filename=sprintf("boletim_%06d.log",$counter);
- open($output,'>>'.$filename) or die $!;
- }
- # End of block
- elsif ( /$end/ ) {
- close($output);
- $counter++;
- $found = 0;
- }
- # Middle of block
- else{
- if($found == 0) {
- print $output (split(/ /))[1];
- $found=1;
- }
- else {
- print $output $_;
- }
- }
- }
- # Find block of lines to extract
- }
- while (<>) {
- chomp; # strip record separator
- if(/END/) { $f=0;}
- if (/START/) {
- s/.*START//g;
- $f=1;
- }
- print $_ ."n" if $f;
- }
- #!/usr/bin/env perl
- use strict;
- use warnings;
- my $start='CINFILE=$';
- my $stop='^#$';
- my $filename;
- my $output;
- my $counter=1;
- my $found=0;
- while (<>) {
- if (/$start/../$stop/) {
- $filename=sprintf("boletim_%06d.log",$counter);
- open($output,'>>'.$filename) or die $!;
- next if /$start/ || /$stop/;
- if($found == 0) { print $output (split(/ /))[1]; }
- else { print $output $_; }
- $found=1;
- } else { if($found == 1) { close($output); $counter++; $found=0; } }
- }
Add Comment
Please, Sign In to add comment