# Split up master list into smaller strings so that command line limit is not reached (limit to around 5000 chars) my @lists = $masterList =~ /(.{5000,}? )/g; # build the string of filename groups for pdf conversion my $htmlFiles = ""; for (my $y = 0; $y < $#lists; $y++) { $htmlFiles.= "\$lists[$y] "; }