Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: pull single value

by bichonfrise74 (Vicar)
on Nov 09, 2009 at 21:48 UTC ( [id://806038]=note: print w/replies, xml ) Need Help??


in reply to pull single value

Looking at this code, you want to change it to something like this.
#!/usr/bin/perl use strict; my @record = ( "662-5555", "+1 102 892-1314" ); for (@record) { print if /(^\d{3}-\d{4}$)/; }

Replies are listed 'Best First'.
Re^2: pull single value
by Anonymous Monk on Nov 09, 2009 at 23:59 UTC
    Why did u put this array? my @record = ( "662-5555", "+1 102 892-1314" ); What if they are just individual values? Thanks, Pamela
      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";
        yes.
        How to do that?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://806038]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-19 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found