Skip to content

Instantly share code, notes, and snippets.

@nunq
Created May 1, 2024 17:57
Show Gist options
  • Save nunq/fcf0e0c2cdd8de12ae9d4000e679a124 to your computer and use it in GitHub Desktop.
Save nunq/fcf0e0c2cdd8de12ae9d4000e679a124 to your computer and use it in GitHub Desktop.
#!/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