http://www.perlmonks.org?node_id=993236

linseyr has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I would like to calculate the average of column 4 from my input files.
#!/usr/local/bin/perl #OPEN UP THE FILE open (MYFILE, '148-N-pvalue0.01_peaks.xls'); #READ THROUGH THE FILE while (my $line = <MYFILE>) { @arr1 = split('\t',$line); @length = @arr1[3]; $numbers = join(", ",@length); print $numbers; #print @length,","; #$avg = avg($length); }
But the problem is the array. How do I get commas between the numbers? And at the end calculate the average from the array? Thanks!