#!/usr/bin/perl use warnings; use strict; my @segtests = (32140578, 32140000, 23400230, 32146578, 32106578, 21301000 ); foreach my $segment_id(@segtests){ my ($shval1,$shval2) = $segment_id =~ /(\d{4})(\d{4})/; print "$shval1 $shval2\n"; #this simulates what happens when the numbers #are passed through the semaphore $shval1 += 0; $shval2 += 0; my $reassemble = connectm($shval1,$shval2); print "$reassemble\n\n"; } sub connectm{ my ($val1,$val2) = @_; # this gives me errors # Left padding a number with 0 (no truncation): # my $padded = sprintf("%0${4}d", $val2); return $val1.$val2; } #### 3214 0578 3214578 3214 0000 32140 2340 0230 2340230 3214 6578 32146578 3210 6578 32106578 2130 1000 21301000