in reply to
serial number generator
Hello royserna03, and welcome to the Monastery!
The following script should do what you want:
my $workbook = Excel::Writer::XLSX->new( 'simple.xlsx' );
my $worksheet = $workbook->add_worksheet();
print "How many Serial Numbers do you need?\n";
my $mal = <STDIN>;
my $comp = 'ITS';
for (my $number = 1; $number <= $mal; $number++)
my $exp = $comp . sprintf("%04d", $number);
push @array, $exp;
$worksheet->write_col(0, 0, \@array);
Always use strict; and declare lexical variables with my.
Barewords must be quoted: my $comp = 'ITS';
If you want (say) 5 serial numbers, and they start at 1, then the last number must be 5, so the loop condition needs to be $number <= $mal.
You can use sprintf to prepend 0s to the serial number.
The key point: Each time a new value of $exp is calculated, it must be added to the array. See push.
Hope that helps,
Athanasius <°(((>< contra mundum