chomp; my @line = split /\s+/, $_;

That is usually written as:

my @line = split;

if ($bwa{$ID}[2] =~ /[D]/) { $splitstoreD = 1; } else { $s +plitstoreD = 0 } if ($bwa{$ID}[2] =~ /[I]/) { $splitstoreI = 1; } else { $s +plitstoreI = 0 }

That is usually written as:

$splitstoreD = $bwa{$ID}[2] =~ /D/ ? 1 : 0; $splitstoreI = $bwa{$ID}[2] =~ /I/ ? 1 : 0;

Or simply:

$splitstoreD = $bwa{$ID}[2] =~ /D/; $splitstoreI = $bwa{$ID}[2] =~ /I/;

#Defining Deletions if($splitstoreD == 1) { $bwa{$ID}[11]="Del" } else { $bwa{ +$ID}[11]=0 } #Defining Insertions if($splitstoreI == 1) { $bwa{$ID}[12]="Ins" } else { $bwa{ +$ID}[12]=0 }

That is usually written as:

#Defining Deletions $bwa{$ID}[11] = $splitstoreD == 1 ? 'Del' :0; #Defining Insertions $bwa{$ID}[12] = $splitstoreI == 1 ? 'Ins' : 0;

@s2 = split /(\d+M)/, @s1; @s3 = split /(\d+M)/, @s2; @s4 = split /(\d+I)/, @s3; @s5 = split /[D]/, @s4;

You are using an array in scalar context which means that if @s1 has 53 elements, for example, then @s2 = split /(\d+M)/, @s1 is the same as @s2 = split /(\d+M)/, '53'.    The second argument to split has to be a scalar or it will be evaluated as a scalar.



In reply to Re: string manipulation with Regex by jwkrahn
in thread string manipulation with Regex by FluffyBunny

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.