BEGIN { $/ = undef; $\ = "\n"; } LINE: while (defined($_ = )) { chomp $_; s/.../.../; # <----- hier dein code } continue { print $_; }