in reply to Reversing of list through STDIN
Hi gaurav,
...it should return the reverse of whatever the list has been entered by the user...
True if and only if the user didn't enter all the list on a single line on the CLI. Because with that the array will only have one "value". See what I mean below, using a modified toolic example.
But if otherwise, your script should work as you intended.use warnings; use strict; print "Enter some lines, then press Ctrl-D:\n"; # or maybe Ctrl-Z my @lines = <STDIN>; my @reverse_lines = reverse (@lines); print @reverse_lines; __END__ Enter some lines, then press Ctrl-D: 1 2 3 # entered by the user 1 2 3 # printed back
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reversing of list through STDIN
by gaurav (Sexton) on Jul 05, 2013 at 22:32 UTC |