Jeffrey Ryan Thalhammer > Perl-Critic-1.120_01 > Perl::Critic::Policy::InputOutput::ProhibitExplicitStdin



Annotate this POD


View/Report Bugs
Module Version: 1.120_01   Source   Latest Release: Perl-Critic-1.123


Perl::Critic::Policy::InputOutput::ProhibitExplicitStdin - Use "<>" or "<ARGV>" or a prompting module instead of "<STDIN>".




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 (<>) {

If you want to prompt for user input, try special purpose modules like IO::Prompt.


This Policy is not configurable except for the standard options.



  my $content = join '', <STDIN>;

because it interprets that line as the nonsensical statement:

  my $content = join '', < STDIN >;

When that PPI bug is fixed, this policy should start catching those violations automatically.




Chris Dolan <>




syntax highlighting: