##
#!/usr/bin/perl -w
use strict;
open my $config, '+<', 'stanza' or die "stanza: $!\n";
my @all = <$config>;
seek $config, 0, 0;
splice @all, -1, 0, "\tMy new data\n";
print $config @all;
close $config;
##
##
#!/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;