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

Why did u put this array? my @record = ( "662-5555", "+1 102 892-1314" ); What if they are just individual values? Thanks, Pamela

Replies are listed 'Best First'.
Re^3: pull single value
by ikegami (Patriarch) on Nov 10, 2009 at 00:02 UTC
    Did you want to run the "print if" against both values?
      Actually this code will fetch attribute having multiple values, i want only a single value that matches my pattern. The code above is not working. I even tried this one.
      #!/usr/bin/perl use strict; use warnings; my @array; my $record = "+1 102 892-1314"; $record = "662-5555"; if ($record =~ m/(^\d{3}-\d{4}$)/) { push @array, $record; } print "@array";
        It's rather useless to put a value in a variable when you immediately replace it with another.
      yes.
      How to do that?
        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.