in reply to Format of number by template
Here's one way to do it, step-by-step
#!/usr/bin/perl use warnings; use strict; my $num = 34; #example number my $padded_num = sprintf("%015d",$num); #Step 1: Pad the number my $first = substr($padded_num, 0, 3); #Step 2: Break the padded numb +er up my $second = substr($padded_num, 3, 5); my $third = substr($padded_num, 8, 7); my $string = sprintf("NO-%s-%s-%s", $first, $second, $third); #Step 3: + Reformat the sections print $string . "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Format of number by template
by nite_man (Deacon) on Feb 12, 2003 at 13:50 UTC |