develooper Front page | perl.beginners | Postings from May 2007

Regarding pattern matching

Thread Next
From:
Dharshana Eswaran
Date:
May 24, 2007 03:41
Subject:
Regarding pattern matching
Message ID:
9f91e0840705240340n6b9dbf50t894a1982b28d7c15@mail.gmail.com
Hi All,

I am trying to extract strings from few files. The content of the file reads
as shown

typedef struct
{
    REFID_T  pp_ref_id;              /* destination */
    CAUSE_T  pp_cause;            /* Reason registered */
    STATE_T   pp_state;             /* State for indicators */
    COMMON_TYPE_PLMN_T            pp_plmn_list[COMMON_TYPE_MAX];       /*
list for the user */
    TYPE_LAC_T             pp_lac[COMMON_TYPE_MAX];
    TYPE_T            pp_cam;/* Cam for initiating only */
} NREG_IND;

I am extracting only the type and the variable names in different strings,
by using the command shown below:

......
.......
$xyz = <FILE>;
$xyz =~ /\s*(\w+)\s+(\w+);/;
$a = $1; # type is stored here
$b = $2; #variable name is stored here
........
.......

But the variables like pp_lac[COMMON_TYPE_MAX] and
pp_plmn_list[COMMON_TYPE_MAX] are not getting stored because of the special
character used inbetween the names.

Can i know what corrections to my regex would help me in extracting both
kinds of the variable names?

I kindly request to guide me in this.

Thanks and Regards,
Dharshana

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About