<> is an abbreviation for "read from files specified in @ARGV , or if @ARGV empty, then read from STDIN ". In your program, @ARGV contains the value ("sample_argument") , and so Perl tries to read from this file when you use the <> operator.
You can fix this by clearing @ARGV before going to the <> line:
$firstarg = shift @ARGV; print $firstarg; $input = <>; # now @ARGV is empty, so read from STDIN print $input;
source share