Ano Bissexto

Olá,

Hoje estava organizando meus arquivos e encontrei um script que havia feito em perl bem simples para saber se o ano que informo é ou não bissexto. Abaixo está o código. :)

#!/usr/bin/perl -w
 
print -n "Informe o ano: ";
$ano = <STDIN>;
chomp $ano;
 
cal 2 $ano | grep -i 29 >> /dev/null
teste=`echo $?`
 
if ("$teste" == "0") {
print "O ano "$ano" é bissexto!"
}
else {
echo "O ano "$ano" não é bissexto!"
}

:wq!


Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">