This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Who Knows The Problem In This Perl Script
$  perl duplex.pl 2.gff out.fasta [table_file] file.out fasta_file
   Use of uninitialized value $m in string ne at duplex.pl line 109, <GEN0> line 1.

How to change it? duplex.pl

perl

2 answers

If I see that correctly, you define the variable "m" in line 18, but never initialize it as anything. I think you want it to start as zero since you increment it on line 104?

Your script breaks because it tries to compare "m", which has no value, to something. I'm unsure why you compare it to an empty string.

change

#!/usr/bin/perl -w

to

#!/usr/bin/perl
use strict;
use warnings;

The -w flag you have in you #! does the same as use warnings but is discouraged as it is less common, see the man page for perl or perldoc http://perldoc.perl.org/perl.html

use strict http://perldoc.perl.org/strict.html Using both strict and warnings will improve code quality. This will point out situations like @Philipp noted, $m in duplex.pl is incremented before being initialized. It is common practice to include these lines in every script.

By placing the use strict pragma at the beginning of your code (as the first line after the "shebang" which points to the perl executable). perl can perform some useful optimizations which can prove beneficial with regard to execution speed, memory management, etc.

~Caitlin

Log in to answer this question.