John11 has asked for the wisdom of the Perl Monks concerning the following question:

It's my third day with Perl ... I am working in the Komodo development environment on Windows 2000. I am trying to get a user input for the radius and then, calculate the circumpherence of the circle ( exercise 2-2 from the Lama book). Here is the code:

$radius = <STDIN>;
$circum = $radius * 2 * 3.14;
print "The circumference of the circle with the radius of $radius equals $circum\n";

It doesn't ask me for input and just kind of hangs.
Can I use <STDIN> in Komodo?
Thanks.

Replies are listed 'Best First'.
Re: A Newcomer can't get the user input!
by Zaxo (Archbishop) on Jul 06, 2002 at 21:20 UTC

    It's just that you are expecting a prompt, but haven't provided one. If you do this:

    print 'Radius? '; $radius = <STDIN>;
    all will be well.

    I'm unfamiliar with Komodo, but this is a method that works cross-platform. A GUI popup is a little more complicated. I'd suggest learning those bits later.

    After Compline,
    Zaxo

      I added
      print 'Radius? ';
      as the first line of the code.
      It didn't help but thanks anyway. -John11
Re: A Newcomer can't get the user input!
by Mr. Muskrat (Canon) on Jul 07, 2002 at 00:16 UTC
    #!/usr/bin/perl use strict; use warnings; print "What is the radius? "; my $radius = <STDIN>; chomp $radius; my $circum = $radius * 2 * 3.14; print "The circumference of the circle with the radius of $radius is $ +circum\n";
    Funny, it works for me.
Re: A Newcomer can't get the user input!
by perlkid (Novice) on Jul 07, 2002 at 00:59 UTC
    Perhaps what you thought wasn't quite what you thought, 
    was it acually just waiting for an input for the $radius.
    Have you entered a numeric value and then press Enter 
    to see the print result?
    
    #will wait for an input from the STDIN 
    #which by default is the keyboard.
    radius = <STDIN> 
    
    -perlkid
    
A reply falls below the community's threshold of quality. You may see it by logging in.