use warnings; use strict; for my $file ( glob("*.pl") ) { open my $fh, '<', $file or die $!; while ( defined( $_ = <$fh> ) ) { print $_; print "adding value=key\n" if $. == 3; } }