prasadbabu has asked for the wisdom of the Perl Monks concerning the following question:
Monks, i have some question in regex. Today when i was doing simple clean up work in xml file, i got the following error. But i was surprised to see that i don't find any error in the code. When i enclosed that character class in the bracket, i am not getting any error. Below i have placed a part of the code and sample input string. This is the first time i am facing such error. Is it my mistake in the code or some other issue behind it? Could anyone explain where am i going wrong.
The error i am getting: syntax error at D:\testing\pract.pl line 14, near "[^" Execution of D:\testing\pract.pl aborted due to compilation errors.
use strict; use warnings; my %imlre = ('RE1' => ['RE1', 'body', 'measure', 'remove'], 'RE2' => [ +'RE2', 'jcode', '', 'remove']); my $input = '<front>front matter comes here</front><body>bodymatter co +mes here</body><back>back matter</back>'; for (keys %imlre) { if ($imlre{$_}->[3] =~ /^remove$/i) { $input =~ s/<$imlre{$_}->[1][^>]*>//g ; #here getting error #$input =~ s/<$imlre{$_}->[1]([^>]*)>//g ; #here no error } } print $input;
Prasad
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting Error in character class - Regex
by davidrw (Prior) on Apr 03, 2006 at 15:38 UTC | |
by ikegami (Patriarch) on Apr 03, 2006 at 15:40 UTC | |
|
Re: Getting Error in character class - Regex
by holli (Abbot) on Apr 03, 2006 at 15:42 UTC | |
by ikegami (Patriarch) on Apr 03, 2006 at 15:50 UTC | |
|
Re: Getting Error in character class - Regex
by murugu (Curate) on Apr 03, 2006 at 15:52 UTC | |
|
Re: Getting Error in character class - Regex
by codeacrobat (Chaplain) on Apr 03, 2006 at 15:46 UTC |