Reading from STDIN, the good way
Good replacement for <STDIN> to avoid perlcritic warn : Use <> or <ARGV> or a prompting module instead of <STDIN>:
sub _stdin {
my $io;
my $string = q{};
$io = IO::Handle->new();
if ( $io->fdopen(fileno(STDIN), 'r') ) {
$string = $io->getline();
$io->close();
}
chomp $string;
return $string;
}
Written by Mickaël S.
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Perl
Authors

janosgyerik
25.21K

Jean-Remy Duboc
12.28K
Related Tags
#perl
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#