<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<div><div dir="ltr">Bom dia, monges!<br><br>Gostaria de saber se alguem pode me ajudar em uma questão peculiar.<br><br>Eu não entendo muito de bitwise, a questão de bit e byte me confundem muito,<br>mas eu queria perguntar como passar uma letra do minusculo para o maiusculo.<br><br>Eu ja tenho um script que fiz que faz essa conversão, mas a questão aqui é fazer isso bit a bit!<br><br><font style="font-size:8pt" face="Arial" size="1">#!/usr/local/bin/perl</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">use common::sense;</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">sub inverter{</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    my @result = undef ;</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    my $nome = shift;</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    my @letr = split (//, $nome);</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    foreach my $let (@letr) { </font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">        if ($let eq uc $let) {</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">            my $chng = lc $let;</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">            push (@result, $chng);</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">        }</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">        elsif ($let eq lc $let){</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">            my $chng = uc $let;</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">            push (@result, $chng);</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">        }    </font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    }</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    </font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    print @result, "\n";</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    </font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">}</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    my $ENT = <STDIN>;</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    my $inv = inverter $ENT;</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    </font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    exit 0 ;</font><br><font style="font-size:10pt" size="2">(sei que ta grande, mas sou iniciante ainda)</font><br><br>A letra 'a' é representada pelo binario '01100001' e a letra 'A' é representada pelo binario '01000001'.<br>O que eu entendo é que tudo esta ligado ao quinto bit, que quando ligado a letra sai minuscula e quando <br>desligado sai maiuscula!<br><br>Eu queria um script que fizesse isso a nivel binario, ou seja se o quinto bit esta ligado desliga ele<br>se esta desligado o liga!<br><br>É mais por questão de estudo mesmo, agradeço a ajuda!<br><br>Ps: eu tentei fazer da seguinte forma, mas não da certo!<br><br><font style="font-size:8pt" face="Arial" size="1">#!/usr/local/bin/perl</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">use common::sense;</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">chomp (my $entrada = <STDIN>);</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">my @name = split (//, $entrada);</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">my $n = @name;</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">for (my $i= 0; $i = $n - 1; $i++){</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    my @change = split (//, binmode $name[$i]);</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    #8 digitos 3 define masc ou min</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    if ($change[2] == 0){</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">        $change[2] += 1;</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    }</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    elsif ($change[2] == 1){</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">        $change[2] -= 1;</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">    }</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">}</font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1"><br></font><font style="font-size:8pt" face="Arial" size="1">print @name, "\n";</font><font style="font-size:8pt" face="Arial" size="1"><br></font><br><br>                                         </div></div>                                        </div></body>
</html>