CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
No output display for Array input from STDIN

 



PerlUser12
Novice

Oct 11, 2012, 4:59 AM

Post #1 of 2 (530 views)
No output display for Array input from STDIN Can't Post

Hi,

I tried to run a sample program which gets an array input from the user using the Perl Express tool. But After entering the input in the Interactive I/O window, the output is not getting displayed. I tried to enter CTRL+D to indicate the end of the file. But I am getting a beep sound like its a invalid operation.

@input = <STDIN>;

print (@input);



Kindly let me where I went wrong. Thanks in advance!


BillKSmith
Veteran

Oct 11, 2012, 5:23 AM

Post #2 of 2 (528 views)
Re: [PerlUser12] No output display for Array input from STDIN [In reply to] Can't Post

windows uses CTRL-Z as an end-of-file.

It is probably better to read one line at a time. Define you own word to end the input.

Untested.


Code
my @array 
while ( my $line = <>) {
print "Enter one line of data ('END' to quit)\n";
last if $line eq 'END';
push @array, $line;
}

Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives