in reply to Re: manipulating alignment data
in thread manipulating alignment data

thank you.Yes, by conserved I mean columns where there is more than one letter. Could you please explain the following lines more verbosely. Also, I need the position, so I guess in your case instead of printing I could feed it into and array or hash and then print out the positions with an X

$template |= $first ^ $_;
print ord == 0 ? '.' : 'X';

Replies are listed 'Best First'.
Re^3: manipulating alignment data
by moritz (Cardinal) on Mar 28, 2012 at 12:23 UTC

    infix ^ is the bitwise XOR operator, so the resulting string from $first ^ $_ has a zero-byte at every position where $first and $_ are equal.

    Likewise | is the bitwise OR operator, so $template accumulates non-zero bytes at any character position where any row differed from $first.

    print ord == 0 ? '.' : 'X';

    ord == 0 simply checks if $_ is the zero-byte. If yes, a dot is returned, otherwise an X.

    For more information look into perlop, search for "bitwise" and "ternary".