Hi All, I have written a program,
use strict; use warnings; my $Enum = "typedef enum _SIGNAL_E { LEVEL_0_EV = 0, LEVEL_1_EV, LEVEL_2_EV, LEVEL_3_EV, LEVEL_4_EV, LEVEL_5_EV } SIGNAL_E;"; my $Enumidentifier = qr{ [A-Z0-9_]\w* }xs; my $Enumstatement = qr{ \s* ($Enumidentifier) \s* =? \s* (\S+)? ,? }xs; my @m = $Enum =~ /$Enumstatement/g; my $len = @m; for(my $i =0; $i<$len; $i++) { print "$m[$i]\n"; } The output for this program is _SIGNAL_E { LEVEL_0_EV 0, LEVEL_1_EV , LEVEL_2_EV , LEVEL_3_EV , LEVEL_4_EV , LEVEL_5_EV } SIGNAL_E ; But i want to read only the elements of the Enum and the values assigned to those elements. I dont want to read the Enum names and the extra characters. I am unable to filter them. The desired output is LEVEL_0_EV 0 LEVEL_1_EV LEVEL_2_EV LEVEL_3_EV LEVEL_4_EV LEVEL_5_EV Can anyone help me in correcting the regex? Thanks and Regards, Dharshana