#!/usr/bin/perl use strict; use warnings; use Tie::File; use File::Copy; my $f = 'ipconn.conf'; my $location = '/'; # Was an attempt to parameterize the location field that way I can toggle through it once I have the below loop working. tie my @filelines, 'Tie::File', "$f", autochomp => 0 or die $!; foreach ( @filelines ) { if (!/^#/ && m/\/ && /^\s*MaxConnPerIP\s*/) { $_ = '#' . localtime . $_; $_ .= "\n\t\tMaxConnPerIP 10"; } else { print "in else"; } } untie @filelines or die $!;