RE: how to print array element & count

2003-01-21 Thread Bob Showalter
R. Joseph Newton wrote: > "... > foreach(1..$total_elements){ > print "\t\[$_\] my $input[$_ - 1 ]\n"; > } > ...Why did scalar $input in the foreach loop > "works" without predeclaring it with my?" --Eri > > HI Eri, > > The my is probably not doing what you think it is. Otherwise > it would

Re: how to print array element & count

2003-01-21 Thread R. Joseph Newton
"... foreach(1..$total_elements){ print "\t\[$_\] my $input[$_ - 1 ]\n"; } ...Why did scalar $input in the foreach loop "works" without predeclaring it with my?" --Eri HI Eri, The my is probably not doing what you think it is. Otherwise it would constitute a redeclaration error. My guess

Re: how to print array element & count

2003-01-21 Thread John W. Krahn
Eri Mendz wrote: > > Dear All, > > I'm greatly overwhelmed by your quick help to my problem. > Here's the corrected code: > > #!/usr/bin/perl -w > use strict; > > # filename: reverse_string.pl > # editor: # VIM - Vi IMproved 6.1 > # description: get user input and reverse input > > print "Plea

Re: how to print array element & count

2003-01-21 Thread Rob Dixon
"Eri Mendz" <[EMAIL PROTECTED]> wrote in message 3E2D45F0.14555.14A0579@localhost">news:3E2D45F0.14555.14A0579@localhost... > chomp(my @input = ); > my $total_elements = scalar(@input); Assigning to a scalar variable puts the right-hand-side in scalar context anyway. my $total_elements = @in

RE: how to print array element & count

2003-01-21 Thread Eri Mendz
Dear All, I'm greatly overwhelmed by your quick help to my problem. Here's the corrected code: #!/usr/bin/perl -w use strict; # filename: reverse_string.pl # editor: # VIM - Vi IMproved 6.1 # description: get user input and reverse input print "Please enter any string, to quit press Ctrl-Z:\

RE: how to print array element & count

2003-01-20 Thread Bob Showalter
Eri Mendez wrote: > hi all, > > another newbie here. im having problem how to print to stdout the > string[s] entered by user and appending a subscript integer after that > string. this is my modification to exercise 1 chapter 3 of Llama book: > > #!/usr/bin/perl -w > use strict; > > # filename:

Re: how to print array element & count

2003-01-20 Thread John W. Krahn
Eri Mendez wrote: > > hi all, Hello, > another newbie here. im having problem how to print to stdout the > string[s] entered by user and appending a subscript integer after that > string. this is my modification to exercise 1 chapter 3 of Llama book: > > #!/usr/bin/perl -w > use strict; > > #

Re: how to print array element & count

2003-01-20 Thread R. Joseph Newton
"print "\t\[", $_, "\] $_\n";" Hi Eri, I would suggest dispensing with the comma operators. They can have some rather unexpected effects in this context. Remember--variables within full quotes are interpolated before the string is taken. So you could write the above as: print "\t\[$_

RE: how to print array element & count

2003-01-20 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Eri Mendez wrote: > hi all, > > another newbie here. im having problem how to print to stdout the > string[s] entered by user and appending a subscript integer after that > string. this is my modification to exercise 1 chapter 3 of Llama book: > > #!/usr/bin/perl -w > use strict; > > # filename: