Reversing a list/array and the CTRL+Z escape character --- David's Perl Project (Day 5 of 60)
Posted on 2006-04-02
I wrote the following after learning about lists & arrays. Now, when I run it at a a DOS prompt, because it doesn't run well on the Perl Express IDE I'm using. But when I run it in DOS, I have to hit CTRL+Z after typing my list, which gives me a ^Z symbol after my list, then I still have to hit ENTER one more time before the script continues, is there a way around this. I just don't want to see the ^Z symbol and I don't want to have to hit ENTER again after hitting CTRL+Z, I thought it would simply execute the reversal and print out the results when I hit CTRL+Z.
print 'Please type a multi-line list, at the end of each line hit ENTER
and at the end of the list hit CTRL+Z followed by ENTER'."\n";
@list = <STDIN>;
@revList = reverse @list;
print "Your list backwards is:\n @revList";
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Program Files\Perl Express\Scripts>perl ch3-1
Please type a multi-line list, at the end of each line hit ENTER
and at the end of the list hit CTRL+Z followed by ENTER
Your list backwards is:
C:\Program Files\Perl Express\Scripts>