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

  • Home
  • SEARCH
  • 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 1103681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:22:31+00:00 2026-05-17T01:22:31+00:00

Quoting from Perl::Critic::Policy::InputOutput::ProhibitExplicitStdin Perl has a useful magic filehandle called *ARGV that checks the

  • 0

Quoting from Perl::Critic::Policy::InputOutput::ProhibitExplicitStdin

Perl has a useful magic filehandle called *ARGV that checks the command line and if there are any arguments, opens and reads those as files. If there are no arguments, *ARGV behaves like *STDIN instead. This behavior is almost always what you want if you want to create a program that reads from STDIN. This is often written in one of the following two equivalent forms:

while (<ARGV>) {
  # ... do something with each input line ...
}
# or, equivalently:
while (<>) {
  # ... do something with each input line ...
}
  • Is it “just a convention” or are there some solid reasons not to use <STDIN> ?

I feel <STDIN> makes my code’s intentions more clear than using <> or <ARGV>.

The flow of my code is like this

my @inp = <STDIN>;
my $len = $inp[0];

...

for(my $i = 0; $i < ($len + 0); $i++) {
    my @temp = split (' ', $inp[$i]);
    ...
}
  • 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-17T01:22:31+00:00Added an answer on May 17, 2026 at 1:22 am

    It’s because using <ARGV> will enable users to either specify files to read from as arguments, or pipe stuff into stdin while specifying no arguments. If you use <STDIN>, only piping will work.

    Of course it’s up to you to decide if you think people would like to be able to specify files as command line arguments, but it’s something a lot of programs support so it might be worth thinking about.

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

Sidebar

Related Questions

Quoting from the cakephp Book (ver 1.3): Note that only fields of the model
Quoting from the MSDN Link for ValueType Class In cases where it is necessary
Quoting from the C-std section 6.7.2.1, struct s { int n; double d[]; };
quoting from The C++ Standard Library by N M Jousttis, Section 5.9 #include <
I'm quoting part of an answer which I received for another question of mine
I'm quoting myself on a previous question I asked to further explain: I'm trying
Which style of Ruby string quoting do you favour? Up until now I've always
For some reasons, I would like to do an explicit quoting of a string
Objective-C doesn't have namespaces, and many (such as CocoaDevCentral's Cocoa Style Guide ) recommend
I'm just starting with Ruby and I personally find the following to be a

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.