#!/usr/bin/env perl
|
|
|
|
=pod
|
|
|
|
=head1 NAME
|
|
|
|
dog - lump STDIN and arguments together.
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
dog [ B<--chomp> ] [ I<argument> ] [ I<argument> ] [ I<...> ]
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
Concatenate arguments, and/or standard input, to standard output.
|
|
|
|
B<-c --chomp>
|
|
|
|
=over
|
|
|
|
Remove any newlines from standard input.
|
|
|
|
=back
|
|
|
|
If an argument is B<->, it will be replaced with standard input.
|
|
|
|
=head1 EXAMPLES
|
|
|
|
echo bar | dog -c foo - baz
|
|
|
|
=head1 AUTHOR
|
|
|
|
Brennen Bearnes <bbearnes@gmail.com>
|
|
|
|
=cut
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Getopt::Long;
|
|
|
|
# chomp any trailing newline from STDIN?
|
|
my $chomp = 0;
|
|
GetOptions(chomp => \$chomp);
|
|
|
|
for (@ARGV) {
|
|
if ($_ eq '-') {
|
|
while (<STDIN>) {
|
|
chomp if (eof(STDIN) && $chomp);
|
|
print;
|
|
}
|
|
} else {
|
|
print;
|
|
}
|
|
}
|