Skip to content

Instantly share code, notes, and snippets.

@raimon49
Created May 10, 2012 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raimon49/2650901 to your computer and use it in GitHub Desktop.
Save raimon49/2650901 to your computer and use it in GitHub Desktop.
Perlでパイプから受け取った内容を一時ファイルに書き出してほげほげする
#!/usr/bin/perl -w
use strict;
use warnings;
use File::Temp qw(tempfile);
my $fh;
my $f;
unless ( -t STDIN) {
($fh, $f) = tempfile(
CLEANUP => 1
);
while (<STDIN>) {
print $fh $_;
}
}
# $fにほげほげ
if ($f) {
print $f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment