473,396 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

STDIN in list context

i have created an array
print "Enter a string";
@list = <STDIN>;
print @list;
when i excute this it is always in input mode even though i go to new line by pressing enter or if i try bypressing ctrl z
Apr 25 '07 #1
2 1572
Are you using Linux or Windows? In Linux, I believe the EOF character is indicated by Ctrl-D. In Windows, it's Ctrl-Z.

If you want the print to return upon pressing enter. Store the input into a scalar as such:

Expand|Select|Wrap|Line Numbers
  1. my $temp = <STDIN>;
  2. print "$temp";
  3.  
Apr 25 '07 #2
savanm
85
Hi,

The array size is not mentioned so that it doesn't know which element
is last, so that it doesn't print anything. So u must give Ctrl+Z to terminate,
then it wl show the result..
Thanks
Apr 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Mike Maxwell | last post by:
When I invoke readline() in a for loop, why does it return a series of one-char strings, rather than the full line? >>> for sL in sys.stdin.readline(): print sL .... abc a b c
3
by: Josh Wilson | last post by:
OK, somewhat new to C, have searched the group and haven't found an answer that has fixed my problem, so I am just going to try posting it. I am taking really large image files(128x128x35) and...
0
by: ezra epstein | last post by:
I'm struggling using COPY FROM. COPY ... FROM STDIN expects stdin to be whatever file is being processed, so: $ cat data_file.txt | psql -f load_script.sql MyDB Does not do what one...
35
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is...
7
by: Will McDonald | last post by:
Hi all. I'm writing a little script that operates on either stdin or a file specified on the command line when run. I'm trying to handle the situation where the script's run without any input...
5
by: the.theorist | last post by:
I was writing a small script the other day with the following CLI prog * I've used getopt to parse out the possible options, so we'll ignore that part, and assume for the rest of the discussion...
1
by: ywzhan | last post by:
Hi, I am new here. When I use sys.stdin.readline() to get input string from user, how can I set a timeout value for this operation? thank you.
5
by: Cameron Laird | last post by:
Question: import subprocess, StringIO input = StringIO.StringIO("abcdefgh\nabc\n") # I don't know of a compact, evocative, and # cross-platform way to exhibit this behavior. # For now, depend...
5
by: Luis Zarrabeitia | last post by:
I have a problem with this piece of code: ==== import sys for line in sys.stdin: print "You said!", line ==== Namely, it seems that the stdin buffers the input, so there is no reply until ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.