sarshads has asked for the wisdom of the Perl Monks concerning the following question:
I got this question during perl test.
Write a program that accepts a number of ASCII values between 40 and 125 (both inclusive) and concatenates the corresponding characters to form a string. The program accepts a multi-line input. The first line contains a number representing how many ASCII values are in the input. The subsequent lines contain the ASCII values themselves (one ASCII value per line).
The following is an example of a valid input:
INPUT ------ 5 (this indicates the total number of ASCII values in the input set)
65
67
69
70
71
I have some other solution to this question. But i am very much confusing how to read multi line input in which the first line consider as number of times and subsequent lines contains ASCII values. I know my solutions is not correct, please help me in this regard.
#!/usr/bin/perl print "Enter the number of times : "; $times=<STDIN>; +@ascii=<STDIN>; foreach $s (@ascill) { print chr($s); }
I know the above solution is not suitable what question is asked above.
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with reading multi-line
by BrowserUk (Patriarch) on May 01, 2010 at 22:53 UTC | |
by jwkrahn (Abbot) on May 02, 2010 at 00:27 UTC | |
by sarshads (Novice) on May 02, 2010 at 14:41 UTC | |
|
Re: Problem with reading multi-line
by Corion (Patriarch) on May 01, 2010 at 22:22 UTC | |
| |
|
Re: Problem with reading multi-line
by ww (Archbishop) on May 02, 2010 at 01:54 UTC | |
| |
|
Re: Problem with reading multi-line
by Khen1950fx (Canon) on May 03, 2010 at 01:00 UTC | |
by jwkrahn (Abbot) on May 03, 2010 at 02:16 UTC | |
by sarshads (Novice) on May 03, 2010 at 20:53 UTC | |
by bobf (Monsignor) on May 04, 2010 at 02:56 UTC | |
by sarshads (Novice) on May 04, 2010 at 18:42 UTC |