print "username: ";
chomp ($uname = <STDIN>);
print "\npassword: ";
chomp ($password = <STDIN>);
print "\nYou entered username $uname and password $password\n";
answer.txt
someusername
somepassword
And I'm calling it like this:
perl script.pl < answer.txt
...which produces this:
C:\test\scratch>perl script.pl < answer.txt
username:
password:
You entered username someusername and password somepassword
...which is the expected output.
"One word of warning: if you meet a bunch of Perl programmers on the bus or something, don't look them in the eye. They've been known to try to convert the young into Perl monks." - Frank Willison |