#!/usr/bin/perl use strict; my @output; my $stuff; if ( and @ARGV == 0 ) { print "This is how you use this perl script...\n"; exit; } while () { if ($_ =~ m/start/ ) { push @output, chomp; $stuff = 1; } elsif ( $_ =~ m/end/ ) { push @output, chomp; changout(@output); undef $stuff; } elsif ($stuff) { push @output, chomp; } else { print STDOUT $_; } } sub changout { foreach my $line (@_) { if ( $line =~ m/something/ ) { print STDOUT $line; } else { print STDOUT $line."\n"; } } }