You have massive problems with variable scope. A "my" variable only "lives" withing the braces that surround it. Change the top of your file from
to this#!user/local/perl use Cwd;
And then try to understand what it is telling you. If you still are confused read this Variable Scoping in Perl: the basics. If after that you don not understand how to fix it come back and show us your progress.#!user/local/perl use strict; use warnings; use Cwd;
hint: the key will be to combine your c/d loops into a single loop. something like this
for my $c (0..$#AbsFiles){ my $key1=undef; my $key2=undef; if ($AbsFiles[$c] =~ /R2_001\.fastq$/){ open INPUT1 ... ; ...stuff to set key1; close INPUT1; } if ($AbsFiles[$c] =~ /R1_001\.fastq$/$/){ open INPUT2 ... ; ...stuff to set key2; close INPUT2; } if (defined($key1) && defined($key2} && key1 eq $key2 ) { ... stuff to do when both are set and equal ... } else { ...stuff to do otherwise .. } } # c
Note that i "escaped" the dot in the regexp. an escaped dot will match any character, while "\." matches a dot itself.
Note that the close does not include the lessthan/greaterthan signs, those are used to read a file, not to reference it. Also note i closed them inside the same scope i opened them, this tends to be good practice.
edit:See below Re: Running a script across multiple directories with multiple output files (problems comparing hash key values)
In reply to Re: Running a script across multiple directories with multiple output files (problems comparing hash key values)
by huck
in thread Running a script across multiple directories with multiple output files (problems comparing hash key values)
by msnyder424
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |