DaWolf has asked for the wisdom of the Perl Monks concerning the following question:
And this is the one who should add zeros to the control number wich was extracted from a text file: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; }
I know I must be missing something very basic, but I still don't get it... Help, please.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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Sub can't get $_ value?
by merlyn (Sage) on Jan 11, 2004 at 23:05 UTC | |
by DaWolf (Curate) on Jan 11, 2004 at 23:26 UTC | |
|
Re: Sub can't get $_ value?
by kutsu (Priest) on Jan 11, 2004 at 23:05 UTC | |
by DaWolf (Curate) on Jan 11, 2004 at 23:24 UTC | |
|
Re: Sub can't get $_ value?
by Roger (Parson) on Jan 11, 2004 at 23:26 UTC |