#!/usr/bin/perl use strict; use warnings; use File::Spec; my @name; my @length; open(GENDATA, "<$ARGV[1]"); while () { chomp($_); my @field=split(/\t/, $_); push(@length, $field[1]); push(@name, $field[0]); } close(GENDATA); open(RANGE, "<$ARGV[0]"); while () { chomp($_); my $simlen = $_; my $randname = 0; my $randpos = 0; do { $randname = int(rand(scalar(@name))); $randpos = int(rand($length[$randname] - $simlen - 1)); print $name[$randname] ."\t". $randpos ."\t". ($randpos + $simlen) ."\n"; }} close(RANGE);