<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Em 21-07-2010 23:27, Bruno Buss escreveu:
<blockquote
 cite="mid:AANLkTimcWcrItDM_NlBJ1GVjFSZPspbYdxaIR4zCn0kN@mail.gmail.com"
 type="cite">push @juncao_elementos, @array1, @array2;</blockquote>
<br>
&nbsp;&nbsp;&nbsp; Nossa!...que "dif&iacute;cil" heim! :p<br>
&nbsp;&nbsp;&nbsp; Obrigado Bruno<br>
<br>
<blockquote
 cite="mid:AANLkTimcWcrItDM_NlBJ1GVjFSZPspbYdxaIR4zCn0kN@mail.gmail.com"
 type="cite">
  <div><br>
  <div class="gmail_quote">2010/7/21 "Fl&aacute;vio R. Lopes" <span dir="ltr">&lt;<a
 moz-do-not-send="true" href="mailto:flavio.lopes@links.inf.br">flavio.lopes@links.inf.br</a>&gt;</span><br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Aproveitando
a oportunidade, teria jeito mais f&aacute;cil do que este que eu fiz para
juntar dois Arrays em um terceiro array, por exemplo:<br>
    <br>
my @array1 = qw ( 4 5 6 7 );<br>
my @array2 = qw ( 8 9 );<br>
    <br>
&nbsp; &nbsp;foreach my $elementos ( @array1, @array2 ) {<br>
    <br>
&nbsp; &nbsp; &nbsp; &nbsp;push @juncao_elementos, $elementos;<br>
    <br>
&nbsp; &nbsp;}<br>
    <br>
    <br>
    <br>
    <br>
Em 21-07-2010 22:45, Daniel de Oliveira Mantovani escreveu:
    <div>
    <div class="h5"><br>
    <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Voc&ecirc; pode contar o tanto de vezes que aparece em seguida,<br>
      <br>
use strict;<br>
use warnings;<br>
use Data::Dumper;<br>
      <br>
my @numeros = ( 1, 2, 3, 4, 5, 6, 6, 6, 5 );<br>
my %hash = map { $_ =&gt; &nbsp;{ $_ =&gt; &nbsp;++$_{$_} } } @numeros;<br>
      <br>
print Dumper %hash;<br>
      <br>
&lt;resultado&gt;mantovani@mantovani-desktop:~$ perl <a
 moz-do-not-send="true" href="http://foo.pl" target="_blank">foo.pl</a><br>
$VAR1 = '6';<br>
$VAR2 = {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '6' =&gt; &nbsp;3<br>
&nbsp; &nbsp; &nbsp; &nbsp; };<br>
$VAR3 = '4';<br>
$VAR4 = {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '4' =&gt; &nbsp;1<br>
&nbsp; &nbsp; &nbsp; &nbsp; };<br>
$VAR5 = '1';<br>
$VAR6 = {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '1' =&gt; &nbsp;1<br>
&nbsp; &nbsp; &nbsp; &nbsp; };<br>
$VAR7 = '3';<br>
$VAR8 = {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '3' =&gt; &nbsp;1<br>
&nbsp; &nbsp; &nbsp; &nbsp; };<br>
$VAR9 = '2';<br>
$VAR10 = {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'2' =&gt; &nbsp;1<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;};<br>
$VAR11 = '5';<br>
$VAR12 = {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'5' =&gt; &nbsp;2<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;};<br>
&lt;/resultado&gt;<br>
      <br>
      <br>
2010/7/21 "Fl&aacute;vio R. Lopes"&lt;<a moz-do-not-send="true"
 href="mailto:flavio.lopes@links.inf.br" target="_blank">flavio.lopes@links.inf.br</a>&gt;:<br>
&nbsp; <br>
      <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Humm....<br>
        <br>
Obrigado pessoal!<br>
        <br>
Em 21-07-2010 21:41, Giuliani Sanches escreveu:<br>
&nbsp; &nbsp; <br>
        <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Fl&aacute;vio,<br>
          <br>
Hash n&atilde;o permite a duplica&ccedil;&atilde;o de chaves. Ao adicionar o primeiro 6,<br>
ele simplesmente vai sobrescrevendo o conte&uacute;do e como todos s&atilde;o 6,<br>
voc&ecirc; tem o resultado obtido.<br>
          <br>
[]'s<br>
          <br>
Em 21 de julho de 2010 21:31, "Fl&aacute;vio R. Lopes"<br>
&lt;<a moz-do-not-send="true" href="mailto:flavio.lopes@links.inf.br"
 target="_blank">flavio.lopes@links.inf.br</a>&gt; &nbsp; &nbsp;escreveu:<br>
          <br>
&nbsp; &nbsp; &nbsp; <br>
          <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ol&aacute; pessoal.<br>
            <br>
Num dos exerc&iacute;cios que estou fazendo, uma das solu&ccedil;&otilde;es (pelo menos que<br>
estou<br>
imaginando) seria colocar o conte&uacute;do de um array dentro de um hash, mas<br>
quando os elementos s&atilde;o repetidos, s&oacute; insere a primeira inst&acirc;ncia do<br>
elemento.<br>
            <br>
Supondo um array com os elements:<br>
            <br>
my &nbsp;@numeros = (1, 2, 3, 4, 5, 6, 6, 6, 5);<br>
            <br>
my &nbsp;%hash = map { $_ =&gt; &nbsp; &nbsp;$_ } @numeros;<br>
            <br>
&nbsp;while ( my ($chave, $valor) = each %hash ) {<br>
            <br>
&nbsp; &nbsp; &nbsp; &nbsp;say "$chave =&gt; &nbsp; &nbsp;$valor";<br>
            <br>
&nbsp;}<br>
            <br>
            <br>
Tenho como sa&iacute;da:<br>
6 =&gt; &nbsp; &nbsp;6<br>
4 =&gt; &nbsp; &nbsp;4<br>
1 =&gt; &nbsp; &nbsp;1<br>
3 =&gt; &nbsp; &nbsp;3<br>
2 =&gt; &nbsp; &nbsp;2<br>
5 =&gt; &nbsp; &nbsp;5<br>
            <br>
            <br>
Porque os outros dois elementos "6" e o &uacute;ltimo elemento "5" n&atilde;o s&atilde;o<br>
armazenados dentro do hash?<br>
Gostaria que produzisse a seguinte sa&iacute;da (como todos os 9 elementos do<br>
array):<br>
            <br>
6 =&gt; &nbsp; &nbsp;6<br>
6 =&gt; &nbsp; &nbsp;6<br>
6 =&gt; &nbsp; &nbsp;6<br>
4 =&gt; &nbsp; &nbsp;4<br>
1 =&gt; &nbsp; &nbsp;1<br>
3 =&gt; &nbsp; &nbsp;3<br>
2 =&gt; &nbsp; &nbsp;2<br>
5 =&gt; &nbsp; &nbsp;5<br>
5 =&gt; &nbsp; &nbsp;5<br>
            <br>
Onde estou errando?<br>
            <br>
Abra&ccedil;o,<br>
Fl&aacute;vio<br>
            <br>
            <br>
            <br>
_______________________________________________<br>
SaoPaulo-pm mailing list<br>
            <a moz-do-not-send="true" href="mailto:SaoPaulo-pm@pm.org"
 target="_blank">SaoPaulo-pm@pm.org</a><br>
            <a moz-do-not-send="true"
 href="http://mail.pm.org/mailman/listinfo/saopaulo-pm" target="_blank">http://mail.pm.org/mailman/listinfo/saopaulo-pm</a><br>
            <br>
            <br>
&nbsp; &nbsp; &nbsp; &nbsp; <br>
          </blockquote>
          <br>
          <br>
&nbsp; &nbsp; &nbsp; <br>
        </blockquote>
_______________________________________________<br>
SaoPaulo-pm mailing list<br>
        <a moz-do-not-send="true" href="mailto:SaoPaulo-pm@pm.org"
 target="_blank">SaoPaulo-pm@pm.org</a><br>
        <a moz-do-not-send="true"
 href="http://mail.pm.org/mailman/listinfo/saopaulo-pm" target="_blank">http://mail.pm.org/mailman/listinfo/saopaulo-pm</a><br>
&nbsp; &nbsp; <br>
      </blockquote>
      <br>
      <br>
&nbsp; <br>
    </blockquote>
    <br>
_______________________________________________<br>
SaoPaulo-pm mailing list<br>
    <a moz-do-not-send="true" href="mailto:SaoPaulo-pm@pm.org"
 target="_blank">SaoPaulo-pm@pm.org</a><br>
    <a moz-do-not-send="true"
 href="http://mail.pm.org/mailman/listinfo/saopaulo-pm" target="_blank">http://mail.pm.org/mailman/listinfo/saopaulo-pm</a><br>
    </div>
    </div>
  </blockquote>
  </div>
  <br>
  <br clear="all">
  <br>
-- <br>
Bruno C. Buss<br>
  <a moz-do-not-send="true" href="http://brunobuss.wordpress.com/">http://brunobuss.wordpress.com/</a><br>
  <a moz-do-not-send="true" href="http://www.dcc.ufrj.br/%7Ebrunobuss/">http://www.dcc.ufrj.br/~brunobuss/</a><br>
  </div>
  <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
SaoPaulo-pm mailing list
<a class="moz-txt-link-abbreviated" href="mailto:SaoPaulo-pm@pm.org">SaoPaulo-pm@pm.org</a>
<a class="moz-txt-link-freetext" href="http://mail.pm.org/mailman/listinfo/saopaulo-pm">http://mail.pm.org/mailman/listinfo/saopaulo-pm</a></pre>
</blockquote>
<br>
</body>
</html>