Created
May 1, 2024 17:57
-
-
Save nunq/fcf0e0c2cdd8de12ae9d4000e679a124 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# wp.pl - write to file and stdout | |
use strict; | |
use warnings; | |
use POSIX "strftime"; | |
my $file = strftime "%Y-%m-%d_%H-%M-%S.log", localtime; | |
open (my $fh, ">", $file) or die "cannot open $file: $!\n"; | |
foreach my $line (<STDIN>) { | |
print STDOUT "$line"; | |
print $fh "$line"; | |
} | |
close $fh; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment