arunhorne has asked for the wisdom of the Perl Monks concerning the following question:
Monks!
I have a string I need to parse for parameters. So I have written the following code:
#!/usr/contrib/bin/perl # Parses a string in the format: # REFDATA_ERROR[type=<1>,system=<2>,category=<3>,code=<4>] # Prints out the four parameters, <1>, <2>, <3>, <4> sub parse_error($) { $params =~ m/REFDATA_ERROR\[type=(.*),system=(.*),category=(.*),code +=(.*)\]/; print "$params\n"; print "$1\n"; print "$2\n"; print "$3\n"; print "$4\n"; } # Main parse_error("REFDATA_ERROR[type=val1,system=val2,category=val3,code=va +l4]");
... only problem is my print statements are just returning blanks. Can anyone point me in the right direction please?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing with Regular Expressions
by Corion (Patriarch) on Nov 17, 2004 at 14:57 UTC | |
by ysth (Canon) on Nov 17, 2004 at 16:51 UTC | |
|
Re: Parsing with Regular Expressions
by tilly (Archbishop) on Nov 17, 2004 at 16:22 UTC | |
|
Re: Parsing with Regular Expressions
by dragonchild (Archbishop) on Nov 17, 2004 at 15:31 UTC | |
by idsfa (Vicar) on Nov 17, 2004 at 16:45 UTC |