Regex Issue
- From: dharshana.ve@xxxxxxxxx (Dharshana Eswaran)
- Date: Wed, 29 Aug 2007 10:14:33 +0530
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
- Follow-Ups:
- Re: Regex Issue
- From: Chas Owens
- Re: Regex Issue
- Prev by Date: Problem in comparing two files using compare.pm
- Next by Date: Re: conflicting errors
- Previous by thread: Problem in comparing two files using compare.pm
- Next by thread: Re: Regex Issue
- Index(es):
Relevant Pages
|
|