Re: input <>; not working?

From: A. Sinan Unur (1usa_at_llenroc.ude.invalid)
Date: 12/22/04


Date: 22 Dec 2004 04:33:24 GMT


"Billy" <bustanut2020@yahoo.com> wrote in
news:Wz6yd.270491$HA.29043@attbi_s01:

> I ran into a problem that I went round-and-round on until I broke an
> input to the simplest test code I could think of and it still doesn't
> work...

...

> $number = <STDIN>;
> print STDOUT "The number is $number.\n";
>
> What happens with both attempts is it prints:
>
> Enter a number: The number is.
>
> without pausing for an input.....
>
> All other parts of my code works except when I want to get an input
> from the keyboard....
> What am I missing?

I am not sure:

use strict;
use warnings;

$| = 1;

print 'Enter a number: ';
my $number = <STDIN>;
chomp $number;
print "The number is $number.\n";

__END__

C:\Dload> t.pl
Enter a number: 5
The number is 5.

C:\Dload> perl -v

This is perl, v5.8.6 built for MSWin32-x86-multi-thread
(with 3 registered patches, see perl -V for more detail)

Copyright 1987-2004, Larry Wall

Binary build 811 provided by ActiveState Corp. http://www.ActiveState.com

C:\Dload> ver

Microsoft Windows XP [Version 5.1.2600]

-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)


Relevant Pages