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: 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-D:\n";
> chomp(my @input = <STDIN>);
> my $total_elements = scalar(@input);
> print "You have entered $total_elements arguments.\n";
> print "They are: \n";
> 
> foreach(1..$total_elements){
>     print "\t\[", $_, "\] $_\n";
> }
> 
> #foreach(@input){
> #    print "\t\[", $_, "\] $_\n";
> #}
> 
> print "Press enter to see inputs in reverse order: ";
> chomp(my $press = <STDIN>);
> @input = reverse(@input);
> print "The reverse -> @input \n";
> 
> ##########<\result>##########
> Please enter any string, to quit press Ctrl-D:
> just
> another
> perl
> newbie
> ^D
> 
> You have entered 4 arguments.
> They are:
>       [1] 1
>       [2] 2
>       [3] 3
>       [4] 4
> Press enter to see inputs in reverse order:
> The reverse -> newbie perl another just
> ##########<result>##########
> 
        Since you are receiving the input into @input from the screen, so
each time you would do the input, it will always start at $input[0] and
increment until control d.  

        You can pick your way of indexing, but what you are really after (
from your point of view ) is printing out the words and having the index
number print which is really secondary. So use @input for the looping and
some type variable for the indexing.

You said you didn't want code but to make you think.

Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to