obdulio santana wrote:
I must mix 3 files, and produce a little report but in line 23 and 31 is a
warning of uninitalized value I  really don't see  the mistake.


use warnings;

use strict;

@lfile0 = <DATA>;
chomp @lfile0;
@meses = qw(ene feb mar abr may jun jul ago sep oct nov dic);
@files= glob "78*";
my %textos;
for (@files){
    open FILE,"<$_";

You should *always* verify that the file opened correctly:

      open FILE, '<', $_ or die "Cannot open '$_' $!";


    $textos{$_}=[<FILE>];
    chomp @{$textos{$_}};
    s/.{5}// for @{$textos{$_}};
}
($day,$month,$year) = (localtime)[3..5];
$dec = $day /10;
$month++;
$dec = 3 if $dec < 1;
$year+=1900;
$file = sprintf "vcl%02d%02d%4d.txt",$day,$month,$year;
open FILEOUT, ">$file";

You should *always* verify that the file opened correctly:

open FILEOUT, '>', $file or die "Cannot open '$file' $!";


print FILEOUT "Resumen decadal \n" ;
printf FILEOUT "$meses[$month-1]/$year;#%d \n",$dec  ;
$form = "%13s" x @files ;
printf FILEOUT "%23s" . "$form\n",sort keys %textos ;

You have one more printf format then you have keys in %textos:

printf FILEOUT '%23s' . ( '%13s' x ( @files - 1 ) ) . "\n", sort keys %textos ;


for $line (5..50){
    @str=();
    for (sort keys %textos){
        push @str,${$textos{$_}}[$line];
    }
    $form = "%13s" x @files ;
    $form = "%-10s".$form."\n";
    printf FILEOUT $form,$lfile0[$line-6],@str;

$line starts out with a value of 5. 5 - 6 == -1. $lfile0[ -1 ] is the *last* element of @lfile0. Did you really want to start with the last element?

When $line contains 48, 49 or 50 the value of $lfile0[$line-6] is undef.


}
close FILEOUT;
__END__



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to