#!/usr/bin/env perl use warnings; use strict; my $filename = 'test.html'; my @to_insert = ( '
Hello,', 'World! It is '.gmtime(time).' UTC
' ); use Tie::File; tie my @lines, 'Tie::File', $filename or die "tie $filename: $!"; my $found; for (my $i=0; defined($lines[$i]); $i++) { if ($lines[$i]=~//i) { $found=1; splice @lines, $i+1, 0, @to_insert; last; } } die "Marker not found" unless $found; untie @lines;