Hello royserna03, and welcome to the Monastery!
The following script should do what you want:
#!/usr/bin/perl use strict; use warnings; use Excel::Writer::XLSX; 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'; my @array; for (my $number = 1; $number <= $mal; $number++) { my $exp = $comp . sprintf("%04d", $number); push @array, $exp; } $worksheet->write_col(0, 0, \@array);
Some notes:
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
In reply to Re: serial number generator
by Athanasius
in thread serial number generator
by royserna03
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |