DEV Community

Discussion on: Daily Challenge #9 - What's Your Number?

Collapse
 
yzhernand profile image
Yozen Hernandez • Edited

Nice, basically what I got. sprintf works as well.

#!/usr/bin/env perl

use strict;
use warnings;

sub createPhoneNumber {
    sprintf "(%s%s%s) %s%s%s-%s%s%s%s", @_;
    # local $" = "";
    # "(@_[0..2]) @_[3..5]-@_[6..9]";
}

print createPhoneNumber(1, 2, 3, 4, 5, 6, 7, 8, 9, 0) . "\n";

The regex solution was pretty interesting. Thanks for the explanation!