in reply to 2d Array - making an array for the column then adding the values

I would like to make suggestions for this code. I just started with the UI. A small problem is that $0 is not a portable name for the current program name. I show below how to make $0 portable.

I think a bigger problem is this use of opts. The normal command line usage for an option like "-l" means that I want the "l" option. If I don't mention -l, that means "no". This idea of -l Y or -l N doesn't make sense, just -l means "yes, I want -l" and no mention of -l means "no -l".

Below is a standard design pattern for a command line I/F.

#!/usr/bin/perl -w use strict; use Getopt::Std; use Data::Dumper; use File::Basename; my $prog_name = basename($0); my $usage = <<"USAGE"; Usage: $prog_name [-flags] <fasta file> <output file> Files must be all one type. ie (all fasta NT, all fastq, all fasta fn +a). The script is able to detect if fasta or fastq files have been suplie +d. Depending on the flags, it produces different output. $prog_name will produce a histogram, a vector distribution, and a NT/AA distribution. For fastq files, you must use a flag to specify which version. of fastq the file is formatted with. -l to specify Solexa/Illumina < 1.3 Fastq -s to specify Sanger Fastq -u to specify Illumina >= 1.3 Fastq only one option is allowed! USAGE ###### "code" starts here ########### my %opts; die "$usage" if !getopts ("lsu", \%opts); # above removes any -lu or -lus options from command line # all that is left in @ARGV are the two file paths... # above will cause $usage to be printed if unknown option, say # "-x" is encountered. die "must have 2 files: fasta infile and an output file!\n$usage" if (my ($inflile, $outfile) = @ARGV) !=2; foreach my $opt (keys %opts) #just for debugging.... { print "$opt= $opts{$opt}\n"; } # here is where you put stuff that rules out combos of options. # I am guessing that more than one option is not right die "only one option allowed!\n$usage" if (keys %opts >1); #ie only 0 or 1 options are allowed #now open the input file and the output files # #error should say "can't open $infile for read", etc.... #we are past the usage stuff...
Definitely DO NOT DO THIS!
open STDERR, ">/dev/null";
That sends error output from like "die" to the "bit bucket"!