#!/usr/bin/perl -w use strict; open my $config, '+<', 'stanza' or die "stanza: $!\n"; my $ip = '12.34.56.78'; my $seen; while (<$config>){ if (m{^$}){ $seen = 1; } if ($seen && m{}){ print "\tMy new data\n"; $seen = 0; } print; } close $config;