Output version.PL to stdout if outfile is not passed as arg1
authorHeiko Schlittermann <hs@schlittermann.de>
Mon, 04 Jan 2016 11:27:08 +0100
changeset 78 06e0bf90ffec
parent 77 3ee9d9b5724c
child 79 171328219fef
Output version.PL to stdout if outfile is not passed as arg1
lib/version.PL
--- a/lib/version.PL	Mon Jan 04 11:18:27 2016 +0100
+++ b/lib/version.PL	Mon Jan 04 11:27:08 2016 +0100
@@ -1,14 +1,16 @@
 #! /usr/bin/perl
 my $outfile = shift;
 
+my $now = localtime;
 chomp(my $version = `hg log -r . --template '{latesttag}-{latesttagdistance}-{node|short}\n'`);
-my $now = localtime;
 
-open(my $output, '>',  $_ = $outfile) or die "Can't open $_: $!\n";
+if (defined $outfile) {
+	open(STDOUT, '>',  $_ = $outfile) or die "Can't open $_: $!\n";
+}
 
-print {$output} <<_;
+print <<_;
 [%# autogenerated at $now by $0 %]
 [% vcs.version = "$version"; %]
 _
 
-utime 0, 0 => $outfile;
+utime 0, 0 => $outfile