December 3rd, 2012, 02:02 PM
Use the sprintf function to reformat your number strings.
Don't use a syntax like:
$one = $1;
$two = $2;
$three = $3;
but put all your captured values into an array.
As an example:
my $foo = '11-22-33-44';
my @result = $foo =~ /(\d+)-(\d+)-(\d+)-(\d+)/;
print "@result"; # prints "11 22 33 44"
And now that your values are in an array, instead of multiple variables, you will be able to process all of them with just one line of code or two (using sprintf for formatting and foreach or map for processing each value, instead of about 25 lines of code to process each one by one.