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
754 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.
=over
=item B<-c --chomp>
Remove any newlines from standard input.
If an argument is B<->, it will be replaced with standard input.
=back
=head1 EXAMPLES
echo bar | dog -c foo - baz
=head1 AUTHOR
Brennen Bearnes
=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;
}
}