use warnings; use strict; while (1) { system("clear"); print "Enter P to process a file or Q to quit: "; chomp( my $ans= ); if ( $ans =~ /^p$/i ) { print "What file would you look to open? "; chomp( my $file= ); next if !-e $file; open(my $fh, '<', $file) or die "Could not open file: $!"; print "What text would you like to search for? "; chomp( my $find= ); print "What text would you like it replaced with? "; chomp( my $replace= ); while ( my $line=<$fh> ) { if ( $line =~ /$find/i ) { $line =~ s/\b$find\b/$replace/g; } print $line; } next; } elsif ( $ans =~ /^q$/ ) { exit; } else { next; } }