From "perldoc perlsub":
Any arguments passed in show up in the array @_ . Therefore, if you called a function with two arguments, those would be stored in $_[0] and $_1 .
From "perldoc -f shift":
Shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down. If there are no elements in the array, returns the undefined value. If ARRAY is omitted, shifts the @_ array ..
Don't use <STDIN> instead of shift(). You CAN use
chomp(my $value = <STDIN>); # Instead of hard coding "5"
If you want the input from the keyboard.
Profanity is the one language all programmers know best.
|