I'd strongly recommend not to use so complex perl one-liners.
while some might have a habit of using these to show off how smart a hacker they are, they are the opposite of smart.
Using these for more than a few commands is definitely not a good idea, except for making unreadable unmaintainable code.
Find out what the code is exactly supposed to do and check for alternative options (the code is possibly full of errors, so if you can find an easier option, don't use the complex one)
I guess you inherited the code. To debug, format it as a proper perl program and edit in an editor with proper syntax highlighting and
auto-formatting. I have tried to edit it for you and turn it into a proper perl program for you this time.
Say the perl program is named extract_fpkm.pl, debug the syntax with perl -c extract_fpkm.pl until it is showing no more errors. The parser will now tell you the line where the errors occur.
Run the program finally: extract_fpkm.pl PB_stressed_sample.txt, no need to use more, cat, etc.
#!/usr/bin/env perl
use strict;
use warnings;
# you will most likely have to fix more errors now
BEGIN{ # there is no more need for a begin block
my %F = ();
my %G = ();
my $C = 0;
my @S = ("gene","genename");
}
while (<>) { # this line is the only advantage what perl -n provides
my @a=split;
push @S,$a[0];
open(my $fh, "<", " SRX3084$a[0]/genes.fpkm_tracking");
$C++;
<$fh>;
while (my $row = <$fh>) {
my @b=split(/\s/,$row);
push @{$F{$b[0]}}, $b[9];
$G{$b[0]}=$b[4]
}
}
END{ # there is no more need for an END block in a simple parser either
print join("\t",@S),"\n";
foreach my $key (keys %F) {
my $tt=join("\t",@{$F{$key}}[0..$C-1]);
print "$key\t$G{$key}\t$tt\n"
}
}
__END__
What does your file
PB_stressed_sample.txt
look like? It's hard for anyone to tell without looking at the file. You can post few lines of your file.