#!/usr/bin/perl -i.bak # in-place editing; save the original file with a .bak extension use Win32::Console; use strict; open(STDERR, ">error.log") or die "Can't open error log: $!\n"; my $con = Win32::Console->new(); $con->Mode(ENABLE_WINDOW_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT); $con->Display; $con->Write("Please enter the agent ID number: "); chomp(my $port = ); $con->Write("The port number to use is $port.\n"); #Debug stuff, this works { local @ARGV = "c:\\blah.txt"; # set up a temporary @ARGV for in-place editing while (<>) { s/serverport 111$/serverport $port/; print; } }