What is the difference between @ARGV and asking the user for input?
$num = $ARGV[0];
and
$_ = <STDIN>;
Either way a user has to put an input isn't it?
How are they different?
|
What is the difference between
and
Either way a user has to put an input isn't it? How are they different? |
||||
closed as off topic by Michael Mrozek♦ Jun 7 '13 at 2:41Questions on Unix & Linux Stack Exchange are expected to relate to Unix or Linux within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question. |
||||
|
|
||||
|
They don't address the same needs for the program. A command-line argument is known by the program at the moment it starts. Getting a input from a user through stdin can be done at any moment of the execution of the program. What the user inputs could depend on what the program had output so far. And command line arguments are usually short inputs whereas through stdin you can get any content, for example if a user redirects the standard input from a file. Usually, command-line arguments are options for the program whereas sandard input are data to be processed. Sometimes, you can use one or the other and do the same thing, sometimes not. |
|||
|
|