...
Code Block |
---|
|
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 |
---|
|
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 |
---|
|
select(( select($log), $| = 1)[0]);
|
...
Code Block |
---|
|
use IO::Handle;
# ...
$log->autoflush();
|
...
[CPAN] Elliot Shank, Perl-Critic-1.116 ProhibitOneArgSelect
[Conway 2005] pg. 224
[Wall 2011] perlfunc
...
Image Modified Image Removed 03. Integers