parseNumericArgList($args{p}, 'pipeline', 1); parseNumericArgList($args{o}, 'overlap', 1); #### sub parseNumericArgList { my ($arg, $tag, $deflt) = @_; my $sing = 0; my @new = (); if (defined($arg)) { # a list was entered if ($arg =~ /,/) { my @singles = split(",", $arg); foreach $sing (@singles) { if ($sing =~ /\D/) { print "\n\nWrong value in $tag\n\n"; die $USAGE } else { if (scalar(@arrAllArgs) == 0) { push (@new, addToRef($allArgs, $tag, $sing)); } else { foreach $allArgs (@arrAllArgs) { push (@new, addToRef($allArgs, $tag, $sing)); } } } } } else { # a single value was entered if ($arg =~ /\D/) { print "\n\nWrong value in $tag\n\n"; die $USAGE } if (scalar(@arrAllArgs) == 0) { push (@new, addToRef($allArgs, $tag, $arg)); } else { foreach $allArgs (@arrAllArgs) { push (@new, addToRef($allArgs, $tag, $arg)); } } } } else { # nothing was entered, use default if (scalar(@arrAllArgs) == 0) { push (@new, addToRef($allArgs, $tag, $deflt)); } else { foreach $allArgs (@arrAllArgs) { push (@new, addToRef($allArgs, $tag, $deflt)); } } } @arrAllArgs = (); @arrAllArgs = @new; } sub addToRef { my ( $refIn, $addNm, $addVal ) = @_; my $ref = {}; my $k = ""; foreach $k (keys %{$refIn}) { $ref->{$k} = $refIn->{$k}; } $ref->{$addNm} = $addVal; return $ref; } #### 0 HASH(0x9e2930) 'overlap' => 100 'pipeline' => 1 1 HASH(0x9e55f0) 'overlap' => 200 'pipeline' => 1 2 HASH(0x9e2910) 'overlap' => 100 'pipeline' => 3 3 HASH(0xd8ead0) 'overlap' => 200 'pipeline' => 3 #### foreach $run (@arrAllArgs) { foreach $ak (keys %{$run}) { $runArgs{$ak} = $run->{$ak}; } processOne(); }