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-22
I hope perl monks will help me get the correct result.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.