0

Hi,

I am trying to match phone numbers, and want only having format xxx-xxxx.

Here is what i have written so far :

sub OfficePhoneNumber
{
my @numbers = @_;
my $number;
my @results;
foreach $number (@numbers)
{
if ($number =~ m/(^\d{3}-\d{4}$)/)
{
push @results, $number;
}
}

return @results;
} 

&OfficePhoneNumber "554-321,+1 302-342-2323";

Please suggest on this.

Thanks, John

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by john_prince
0

The problem is syntax of the passing values through the subroutine. you will be modify this line.

&OfficePhoneNumber ("554-3211","+1 302-342-2323");
0

Thanks for the response.

I might have input like this :

&OfficePhoneNumber ("554-3211","444-4565");

However, i want only one value either first one or the second but not both. As the value can be found at either places.

At time we might get this also,

&OfficePhoneNumber ("","444-4565");

John

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.