Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
769 B

#!/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;
}
}