compare array element

R

Rose

I find the following codes will give match for 'C' to '-', what's the
problem?

$preseq = "C-";
@preseq = splilt '', $preseq;

$curseq = "--";
@curseq = splilt '', $curseq;

$len = @curseq;
$len--;

if ($preseq[$len-1] == $curseq[$len-1]) {
print "P:$preseq[$len-1]\n";
print "C:$curseq[$len-1]\n";
}
 
G

Gunnar Hjalmarsson

Rose said:
I find the following codes will give match for 'C' to '-', what's the
problem?

$preseq = "C-";
@preseq = splilt '', $preseq;

$curseq = "--";
@curseq = splilt '', $curseq;

$len = @curseq;
$len--;

if ($preseq[$len-1] == $curseq[$len-1]) {
print "P:$preseq[$len-1]\n";
print "C:$curseq[$len-1]\n";
}

The problem is that you ask for help with debugging, while you haven't
first asked Perl for help by using strictures and warnings.

Add

use strict;
use warnings;

to the beginning of the script, and make the adjustments needed to get
rid of possible error and warning messages.
 
R

Rose

Thanks to both Bob Walton's explanation and Gunnar Hjalmarsson's critics. I
feel very sorry for raising such stupid questions although I am very
hopeless to be ordered to learn several languages at the same time. I will
pay more attention to use strict and use warnings next time
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top