"Eri Mendz" <[EMAIL PROTECTED]> wrote in message 3E2D45F0.14555.14A0579@localhost">news:3E2D45F0.14555.14A0579@localhost... > chomp(my @input = <STDIN>); > my $total_elements = scalar(@input);
Assigning to a scalar variable puts the right-hand-side in scalar context anyway. my $total_elements = @input; will do. > print "You have entered $total_elements arguments.\n"; > print "They are: \n"; > > foreach(1..$total_elements){ > print "\t\[$_\] my $input[$_ - 1 ]\n"; > } > > Just a quickie. Why did scalar $input in the foreach loop > "works" without predeclaring it with my? I tried running both > and it runs as expected. No scoping required for this control > variable? You're not actually using scalar $input, you're using $input[$_-1], which is a scalar element of the array @input. You declared this in your chomp() line at the start. Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]