4 print STDERR "pad, for padding a file out to an even block size\n";
5 print STDERR "usage: pad BLOCKSIZE < INPUT > OUTPUT\n\n";
6 print STDERR "pad copies its input to its output, then writes\n";
7 print STDERR "zeroes to its output as necessary to make the\n";
8 print STDERR "output size an even multiple of BLOCKSIZE bytes\n";
12 $blocksize = $ARGV[0];
14 while (read (STDIN, $input, 4096)) {
15 $input_size += length ($input);
19 $odd_bytes = $input_size % $blocksize;
20 print "\0" x ($blocksize - $odd_bytes) if $odd_bytes != 0;