print "Process \"$change_me\" ? (j/n) : "; $svar = ja_nei(<>); if ($svar) { fixer( 'anonymous_enable=YES','anonymous_enable=NO',"$change_me" ); fixer( '#nopriv_user=ftpsecure','nopriv_user=ftpsecure',"$change_me" ); doSystemCommand("useradd -m ftpsecure -s /bin/bash"); } ## # Subs ## sub ja_nei { #chomp( my $input = () ); my $input = (); if ( $input =~ /^j|^y/i ) { return 1; } else { return 0; } } sub fixer { my $pat = shift; my $to = shift; my $file = shift; my $count = 0; local $^I = ''; undef @ARGV; push @ARGV, $file; while (<>) { if (s/$pat/$to/g) { $count++; } print; } if ( $count == 0 ) { say "WARNING : No changes made to file \"$file\""; } elsif ( ($g_debug) && ($count) ) { say "\"$pat\" changed to \"$to\" in \"$file\""; } } sub doSystemCommand { my ($systemCommand) = @_; my $returnCode = system($systemCommand ); if ( $returnCode != 0 ) { die "Failed executing [$systemCommand] : $!\n"; } return; }