use strict; use warnings; binmode STDOUT; for ( 1 .. $ARGV[1] ) { print pack( "S", int rand( $ARGV[0] ) ); }