Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ffcccc
langperl

sub output_log {
  my $action = shift;
  open( my $log, ">>", "log.txt");
  select( $log);
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  $year += 1900;
  $mon += 1;
  print "$year-$mon-$mday $hour:$min:$sec: $action\n";
}

# ...

print "Hello!\n";
output_log("Greeted user");
print "How are you?\n";

...

Code Block
bgColor#ccccff
langperl

sub output_log {
  my $action = shift;
  open( my $log, ">>", "log.txt");
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  $year += 1900;
  $mon += 1;
  print $log "$year-$mon-$mday $hour:$min:$sec: $action\n";
}

...

Code Block
bgColor#ffcccc
langperl

select(( select($log), $| = 1)[0]);

...

Code Block
bgColor#ccccff
langperl

use IO::Handle;
# ...
$log->autoflush();

...

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

EXP37-PL

medium Medium

unlikely Unlikely

medium Medium

P14 P4

L3

Automated Detection

Tool

Diagnostic

Perl::Critic

InputOutput::ProhibitOneArgSelect

Bibliography

...

...

[

...

...

...

Perl-Critic-1.116 ProhibitOneArgSelect
[Conway 2005]"Automatic Progress Indicators," p. 224
[Wall 2011]perlfunc

 

...

Image Added Image Added Image Added|http://search.cpan.org/~elliotjs/Perl-Critic-1.116/]. [ProhibitOneArgSelect|http://search.cpan.org/dist/Perl-Critic/lib/Perl/Critic/Policy/InputOutput/ProhibitOneArgSelect.pm]. \[[Conway 2005|AA. Bibliography#Conway 2005]\], pg 224 \[[Wall 2011|AA. Bibliography#Manpages]\] [perlfunc|http://perldoc.perl.org/perlfunc.html]EXP11-C. Do not apply operators expecting one type to data of an incompatible type      03. Expressions (EXP)      EXP13-C. Treat relational and equality operators as if they were nonassociative