[Rio-pm] Chaves de hash
Tiago Peczenyj
tiago.peczenyj em gmail.com
Quinta Novembro 29 16:24:51 PST 2012
o or é facil
my $xxx = open (mimimi) or die "ops..";
eu posso usar o and no mesmo contexto.
$self->upload_file_if_necessary($keyname,$file)
and $self->change_acl_to_public_read($keyname)
and $self->delete_file($file)
and $self->on_success($file)
or $self->on_error($file)
ou seja, se o change_acl_to_public_read retornar falso, eu vou executar
on_error
On Thu, Nov 29, 2012 at 10:09 PM, Bruno Buss <bruno.buss em gmail.com> wrote:
>
>
> 2012/11/29 <thiagoglauco em ticursos.net>
>
> Seu primeiro erro é o operador and. No documento perlop: $ perldoc perlop
>> você vai descobrir o seguinte:
>>
>> " Logical And
>> Binary "and" returns the logical conjunction of the two
>> surrounding expressions. It's equivalent to && except for
>> the very low precedence. This means that it short-circuits:
>> i.e., the right expression is evaluated only if the left
>> expression is true.
>> [...]
>> C-style Logical And
>> Binary "&&" performs a short-circuit logical AND operation.
>> That is, if the left operand is false, the right operand is
>> not even evaluated. Scalar or list context propagates down
>> to the right operand if it is evaluated."
>>
>> Logo, seu código
>>
>>
>> if($keys >= $min and $keys <= $max){
>>
>> deveria ser if($keys >= $min && $keys <= $max){
>>
>
> Eu devo ser muito estúpido... mas alguém que está falando isso (ja é o
> 3o), poderia fazer o favor de me explicar porque ele deve usar && no lugar
> do 'and' e qual diferença isso faz no caso deste if específico? E em quais
> situações deve-se usar o 'and' no lugar de &&?
>
> [ ]'s
> --
> Bruno C. Buss
> http://www.brunobuss.net
>
> _______________________________________________
> Rio-pm mailing list
> Rio-pm em pm.org
> http://mail.pm.org/mailman/listinfo/rio-pm
>
--
Tiago B. Peczenyj
Linux User #405772
http://pacman.blog.br
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/rio-pm/attachments/20121129/b0cff00f/attachment.html>
Mais detalhes sobre a lista de discussão Rio-pm