#!/usr/bin/perl -w
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
#NAME
#  nbytes - produce an N-byte output file
#
#SYNOPSIS
#  nbytes [N]..
#REQUIRES
#
#DESCRIPTION
#
#OPTIONS
# Write N bytes to stdout.
#
# This is used mostly to produce dumb test files.
#
#EXAMPLES
#
#FILES
#
#BUGS
#
#SEE ALSO
#
#AUTHOR
#  John Chambers <jc@trillian.mit.edu>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #

$| = 1;
$exitstat = 0;
($P = $0) =~ s".*/"";
$V = $ENV{"V_$P"} || $ENV{"D_$P"} || 1;	# Verbose level.

$bc = 1000;
for $arg (@ARGV) {
	if ($arg =~ /^\d+$/) {
		$bc = int($arg);
		print STDERR "$P: Writing $bc bc.\n" if $V>1;
	} else {
		print STDERR "$P: Can't parse \"$arg\" arg.\n" if $V>0;
	}
}
$line = "....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....\n";
$ll = length($line);
print STDERR "$P: ll=$ll\n" if $V>1;
print STDERR "$P: bc=$bc\n" if $V>1;
while ($bc > $ll) {
	print $line;
	$bc -= $ll;
	print STDERR "$P: bc=$bc\n" if $V>1;
}
if ($bc > 1) {
	$last = substr($line,0,$bc-1);
	print STDERR "$P: last='$last'\n" if $V>1;
	print $last;
	$bc = 1;
}
print "\n" if $bc > 0;

exit $exitstat;
