Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- sub hora {
- my ($diaActual,$mesActual,$anioActual) = ($_[3],$_[4]+1,$_[5]+1900);
- my @inicio = $ARGV[0] =~ /\S/g;
- my $datos;
- my @edad;
- foreach my $n (@inicio) {
- if ($n =~ /\d/ ) {
- $datos = $datos .+ $n;
- } elsif ($n =~ /\D/) {
- push (@edad,$datos);
- $datos = undef;
- }
- }
- push (@edad,$datos);
- my ($dia,$mes,$anio) = @edad;
- if ($mes == $mesActual and $dia > $diaActual) {
- $anioActual = $anioActual - 1;
- }
- if ($mes > $mesActual) {
- $anioActual = $anioActual - 1;
- }
- my $edadActual = $anioActual - $anio;
- print "$edadActual\n";
- }
- if ($ARGV[0]) {
- &hora(localtime(time));
- } else { print "Uso : perl $0 dia/mes/aƱo\n"}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement