Rodolfo
Rodolfo

Reputation: 593

Read User Input while also providing filenames as arguments

I am creating my first program in perl, and I wanted to request the user to input some information from the keyboard while also reading some files that would be provided as arguments.

Is there any way to specify to the diamond operator '<>' to only consider the user input?

This is the code that I wrote:

print "Enter a number: ";
my $input = <>;

# do something with the input

while(<>){
     print "line $.: $_";
}

Upvotes: 2

Views: 56

Answers (1)

mpapec
mpapec

Reputation: 50637

You can use <STDIN> instead of <>,

my $input = <STDIN>;

so later diamond usage will read files from @ARGV arguments array.

Upvotes: 4

Related Questions