I'm developing an app that manages Excel files so each user can open a different, serialized file.
It has to add zeros to a number at some point (so the filename becomes nicely formatted), so I've made this into a sub. This sub is called from another sub that starts the process of creating and opening the Excel documents.
So this is the sub who does the job:
sub geraNova
{
my $ctrl = './control.dat';
open(CTR, "+>>$ctrl");
flock(CTR, 2);
my $id = <CTR>;
flock(CTR, 8);
close(CTR);
$id = $id + 1;
unlink $ctrl;
open(CTR, "+>>$ctrl");
flock(CTR, 2);
print CTR $id;
flock(CTR, 8);
close(CTR);
$id = addZeros($id);
#The above calls the sub passing the id to format
my $file = 'C:\Lobo\Sites\test'.$id.'.xls';
my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Wi
+n32::OLE->new('Excel.Application');
$Excel->{DisplayAlerts} = 0;
$Excel->{Visible} = 1;
my $Book = $Excel->Workbooks->Add();
$Book->SaveAs($file);
my $ActBook = $Excel->Workbooks->Open("$file") || die "Não foi pos
+sível abrir a planilha. Erro: $!";
undef $Excel;
undef $Book;
undef $ActBook;
}
And this is the one who should add zeros to the control number wich was extracted from a text file:
sub addZeros
{
my $num = $_;
# Below is the line that I'm having problems.
#Perl tells me: Use of uninitialized value in length
while(length($num) < 6)
{
$num = "0".$num;
}
return $num;
}
I know I must be missing something very basic, but I still don't get it... Help, please.
my
($author_nickname, $author_email) = ("DaWolf","erabbott\@terra.com.br")
if ($author_name eq "Er
Galvão Abbott");