Dear Monks,
1. '$first' and '$second' are 2 different variables. Why is
'$_[0] . $_1' used instead of '$_[0] . $_[0]' to combine
two strings? Doesn't the first '$_' for '$first' and the
second '$_' for '$second'?
2. In this code " . $_[0] . $_1 . "\n"; I understand why there
are two dots. But I don't understand why the third dot is
there.
#!/usr/bin/perl #prompt user for two strings. Remove newline and #store into variables print "\nEnter the first string: "; chomp($first = <STDIN>); print "\nEnter the second string: "; chomp($second = <STDIN>); sub combine{ print "\nThe combined strings are: " . $_[0] . $_[1] . "\n"; } &combine($first,$second);
C:\JPARK\JPERL>sub-ex.pl
Enter the first string: I go
Enter the second string: to school.
The combined strings are: I go to school.
In reply to subroutine function by truthseeker66
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |