in reply to search and replace with a variable

What is the content of @lines? My guess is the problem lies there. You shouldn't need the /e modifier.

This works, for example:

#!/usr/bin/perl use warnings; use strict; my $fqdn = 'first'; my $address = 'second'; my @lines = ('RECORDNAME', 'RECORDIP', 'third'); print STDERR "BEFORE: @lines\n"; foreach(@lines) { $_ =~ s/RECORDNAME/$fqdn/; $_ =~ s/RECORDIP/$address/; } print STDERR "AFTER: @lines\n";