
BillKSmith
Veteran
Apr 2, 2011, 10:23 AM
Post #3 of 4
(7043 views)
|
Re: [kadu] Regex to find a match and extract the first value of a line
[In reply to]
|
Can't Post
|
|
You need grep to run in list context.
use strict; use warnings; my $app = 'stjerm'; my @wl = ( '0x1a0005c : 0 464 18x 436 :: -1 : "Pidgin" "Pidgin" : "Buddy List" : "buddy_list"', '0x2400003 : 1389 302 51x 598 :: -1 : "gkrellm" "Gkrellm" : "gkrellm" : "-NONE-"', '0x1c00004 : 0 0 1440x 400 :: -1 : "stjerm" "Stjerm" : "stjerm" : "-NONE-"', '0x1a00902 : 0 47 18x 415 :: -1 : "Pidgin" "Pidgin" : "Gustavo Erler" : "conversation"', ); my ($id) = split (":", (grep{/$app/} @wl)[0]); print $id, "\n"; Good Luck, Bill
|