Dear Perlmonks,
I have written a perl code which is giving wrong results. I need your help to sort out this problem.
From an array, I am interested in getting the substrings starting with either A or G, followed by TG, followed by any number of characters, followed by T, followed by A or G, ending with A or G i.e. AGTG.*TAGAG
#!/usr/bin/perl -w # Finding substring starting with [AG]TG followed by any number of cha +racter but ending with T[AG][AG]. # Getting the output of each substring, its length and locating its po +sition from left to right # by number with starting position as zero @d = “CCATGNNNTAACCNNATGNNTAGCC”; use 1.010; my $string ="@d"; # Remove whitespace $string=~ s/\s//g; $x= () =$string=~ /[AG]TG.*T[AG][AG]/ig; say $_ for map{("%d('%S')",length,$_)}split/$x/,$string; my @a=$_ for map{("%d('%S')",length,$_)}split/$x/,$string; print "The sequences and their lengths are:\n @a \n"; exit;
Result: I am getting the following wrong result from cmd:
Microsoft Windows Version 6.1.7600
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\DR-SUPRIYO>cd desktop
C:\Users\DR-SUPRIYO\Desktop>perl2.pl
Can't call method "say" without a package or object reference at C:\Users\DR-SUP RIYO\Desktop\perl2.pl line 11.
Correct Result should be like this:
The sequences , their lengths and positions are:
ATGNNNTAA; 9; 2-10
<ATGNNTAG; 8; 15-22I hope perl monks will help me get the correct result.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |