in reply to Re^3: pull single value
in thread pull single value

How to do that?

Replies are listed 'Best First'.
Re^5: pull single value
by ikegami (Patriarch) on Nov 10, 2009 at 04:05 UTC
    Then you're not dealing with a single value as you claimed. You want to iterate over a list of values. Why do you think it's a problem storing that list in an array?

    As for how, you've already been shown how. You were even given a fully functional program.

      Thanks for all your efforts. Let's simplify this. I am trying to put this in a subroutine. But it is not working. can you suggest on this?
      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-3214,+1 302-342-2345";
        It works for OfficePhoneNumber("554-3214", "+1 302-342-2345"); Isn't that what you want anyway?