Of Course Rob, i always use strict and warnings... Since i had to write a pseudocode, i did not write them. But i wil lsurely keep this in mind. :-) Thank you... :-)
On 5/17/07, Rob Coops <[EMAIL PROTECTED]> wrote:
Sure, though I do not see why you would not want to use strict and warnings (you should should should or the people on this list will hunt you down and ....) anyway Data::Dumper was just there for convenience: #!/usr/local/bin/perl #use strict; #use warnings; my $string = '#define MNSS_FACILITY_IND_ID (TF_MNSS_MESSAGE_CATEGORY + 0x01) /* @LOG MNSS_MESSAGE_T */'; my @parts = $string =~ m/\s+?(\w+)\s+?\((\w+.*?)\)[EMAIL PROTECTED](\w+).*/; #use Data::Dumper; #print Dumper @parts; print $1 . "\n" . $2 . "\n" . $3 . "\n"; print "#----- or -----#\n"; foreach ( @parts ) { print $_ . "\n"; } On 5/17/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote: > > Thank you.... But i want to try without using any perl modules. Can you > suggest some way with no modules used in that? > > Thanks and Regards, > Dharshana > > On 5/17/07, Rob Coops <[EMAIL PROTECTED]> wrote: > > > > > > > > On 5/17/07, Rob Coops <[EMAIL PROTECTED] > wrote: > > > > > > How about this? > > > > > > > > > #!/usr/local/bin/perl > > > > > > use strict; > > > use warnings; > > > > > > my $string = '#define MNSS_FACILITY_IND_ID > > > (TF_MNSS_MESSAGE_CATEGORY + 0x01) /* @LOG MNSS_MESSAGE_T */'; > > > > > > my @parts = $string =~ m/\s > > > +?(\w+)\s+?\((\w+.*?)\)[EMAIL PROTECTED](\w+).*/; > > > > > > use Data::Dumper; > > > > > > print Dumper @parts; > > > > > > ----- Had to change that one \S to \s (oops) ----- > > > > > > OUTPUT > > > ------------------------------------------------- > > > $VAR1 = 'NSS_FACILITY_IND_ID'; > > > $VAR2 = 'TF_MNSS_MESSAGE_CATEGORY + 0x01'; > > > $VAR3 = 'MNSS_MESSAGE_T'; > > > ------------------------------------------------- > > > > > > > > > > > > On 5/17/07, Dharshana Eswaran <[EMAIL PROTECTED] > wrote: > > > > > > > > Hi All, > > > > > > > > I am trying to extract few strings from a text file. The pattern > > > > of the text > > > > stored in the file is as follows: > > > > > > > > #define MNSS_FACILITY_IND_ID (TF_MNSS_MESSAGE_CATEGORY + > > > > 0x01) /* @LOG > > > > MNSS_MESSAGE_T */ > > > > > > > > > > > > I need to extract MNSS_FACILITY_IND_ID, TF_MNSS_MESSAGE_CATEGORY + > > > > 0x01 and > > > > MNSS_MESSAGE_T. > > > > > > > > I tried > > > > > > > > next unless > > > > /#define\s+(\w+)\s+\(([^)]+)\s+\/[EMAIL PROTECTED](\w+)\*\//; > > > > > > > > my $name = $1; > > > > my ($base, $offset) = $2 =~ /\w+/g; > > > > my $Struct = $3; > > > > > > > > I am unable to find out the error. > > > > > > > > Can anyone help m in this? > > > > > > > > Thanks and Regards, > > > > Dharshana > > > > > > > > > > > > >