I'm sure that there is still stuff wrong with this code. Can you show one input file (a few lines) and the expected output of your program?#!usr/bin/perl -w use strict; my @input_files=<*.seq>; my $sequence='ABCD'; my @headings=('Tags', 'Frequency'); my $headings=join("\t",@headings); #"Tags\nFrequency" foreach my $input_file(@input_files) { open(INPUT, '<', $input_file) or die "Cannot open file: $!\n"; my $outfile=$input_file; $outfile =~ s/.seq/.tag.txt/i; #/g makes no sense open (OUTPUT, '>', $outfile") or die "Cannot open file $!\n"; print OUTPUT "\n$headings\n"; while (my $line=<INPUT>) { if ($line=~m/$sequence(.{11})(.{11})$sequence/o) { print OUTPUT "$1\n$2\n"; } } }
In reply to Re: Creating a column of frequency for the unique entries of another column
by Marshall
in thread Creating a column of frequency for the unique entries of another column
by bluray
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |