Perl is not doing what I expect.
I have a script that accepts 2 commandline arguments. Both of them will happen to be filenames, but according to my concept of standard input, the input to the script itself will just be the strings entered as arguments. If the commandline arguments happen to be filenames, the shell will not actually expand the commandline arguments to the contents of the files they are filenames for.
The first thing I do in the script is assign the values of $ARGV[0] and $ARGV[1] to variables. I don't need to access the commandline arguments after that.
Later in the script, I want to prompt the user for some input. The usual way I do this is
Code:
$userinput = <STDIN>;
However, when I do this, $userinput gets loaded with not just the first commandline argument I supplied, but since Perl is so eager to help, my variable actually gets loaded with the CONTENT of the file! Since my first argument is an image file, this is what I get. I guess there must be a carriage return embedded in the jpeg file after a few characters:
Code:
ÿØÿà^@^PJFIF^@^A^A^A^Aà^Aà^@^@ÿá£vExif^@^@II*^@^H^@^@^@
Anyway, is there some way I can flush the STDIN buffer after I assign the commandline arguments to variables, so that I can prompt for user input from the keyboard later?