#!/usr/bin/env perl # Copyright 2005 Daniel Cer (daniel.cer@cs.colorado.edu) # # This work is licensed under the Creative Commons Attribution-NonCommercial- # ShareAlike License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a letter to # Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, # 94105, USA. use POSIX qw(INT_MAX); if (@ARGV != 2) { print stderr "Usage:\n\t$0 [int/real] (count)\n"; exit -1; } $type = $ARGV[0]; $count = $ARGV[1]; if ($count<=0){ print stderr "Error: count should be an integer > 0\n"; exit -2; } if ($type eq "int") { for ($i=0; $i<$count; $i++) { print int rand INT_MAX,"\n"; } } elsif ($type eq "real") { # note that, as of perl 5.8, rather than rand(1), just rand() could be used # to generate a value in the range [0,1). However, the docs say this could # change in future versions. for ($i=0; $i<$count; $i++) { print rand 1,"\n"; } } else { print stderr "Invalid type: \"$type\"\n"; exit -3; }