Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3271104
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:41:53+00:00 2026-05-17T18:41:53+00:00

I am learning Perl and wrote this script to practice using STDIN. When I

  • 0

I am learning Perl and wrote this script to practice using STDIN. When I run the script, it only shows the first print statement on the console. No matter what I type in, including new lines, the console doesn’t show the next print statement. (I’m using ActivePerl on a Windows machine.) It looks like this:

$perl script.pl
What is the exchange rate? 90.45
[Cursor stays here]

This is my script:

#!/user/bin/perl
use warnings; use strict;

print "What is the exchange rate? ";
my @exchangeRate = <STDIN>;
chomp(@exchangeRate);

print "What is the value you would like to convert? ";
chomp(my @otherCurrency = <STDIN>);

my @result = @otherCurrency / @exchangeRate;
print "The result is @{result}.\n";

One potential solution I noticed while researching my problem is that I could include

use IO::Handle;

and

flush STDIN; flush STDOUT;

in my script. These lines did not solve my problem, though.

What should I do to have STDIN behave normally? If this is normal behavior, what am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:41:53+00:00Added an answer on May 17, 2026 at 6:41 pm

    When you do

    my @answer = <STDIN>;
    

    …Perl waits for the EOF character (on Unix and Unix-like it’s Ctrl-D). Then, each line you input (separated by linefeeds) go into the list.

    If you instead do:

    my $answer = <STDIN>;
    

    …Perl waits for a linefeed, then puts the string you entered into $answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Perl script, that's supposed to match this string: Sometimes, he says
I've been learning Perl and whenever I write a non-trivial script I always get
I'm just learning Perl. When is it advisable to use OO Perl instead of
I have recently started learning Perl and one of my latest assignments involves searching
I'm learning Python now because of the Django framework. I have been a Perl
Im learning lisp and im pretty new at this so i was wondering... if
I'm reading the Llama ( Learning Perl ) book, and working on the exercises.
While learning Perl I am also learning Linux (Ubuntu), so it is kinda fire-hose
I started learning how to make a module in perl with perltoot : package
I'm learning Python (and it's my first programming language so don't be too intense

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.