#!/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 number 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";