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

Regarding pattern matching

Thread Next
Dharshana Eswaran
May 24, 2007 03:41
Regarding pattern matching
Message ID:
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 */

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,

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About