#!/usr/local/bin/perl -w use strict; opendir DIR, "." or die "No pude abrir este directorio"; my @rems= grep {/^rem/ && -d $_} readdir DIR; closedir DIR; my %seen; foreach my $dir(@rems){ opendir DIR, $dir; my @files=grep { /^det.*htm$/ } readdir DIR; closedir DIR; foreach my $file(@files){ open FILE,"lynx -force_html -dump $dir/$file |" or die "Couldn't pipe from $dir/$file"; # print "$dir/$file", '-'x20, "\n"; my ($fecha, $hora, $distrito)=('','',''); while(){ $fecha=$1 if /Fecha:\s+(.*)/; $hora=$1 if /Hora:\s+(.*)/; $distrito=ucfirst lc $1 if /Distrito\s+de\s+(.*)/; if(/\%/){ s/\%.*//; my @datos=split; next if $seen{"$datos[0].$datos[1]"}; $seen{"$datos[0].$datos[1]"}++; print join("|", ($distrito, $fecha, $hora, @datos)), "\n"; } } print STDERR "$dir/$file $distrito $fecha $hora\n"; } }