fiat has asked for the wisdom of the Perl Monks concerning the following question:
Greetings to all
I need to process two (and possibly a third) group of patterns in my input . My current code snippet for this is:
while ($data_in =~ /<container><a>(.+?)<\/a><b>(.+?)<\/b><\/container> +(<\?query\?>)??/ig) { $data_out = "$2, $1$3 "; errors here ; further processing here }
However I am getting this error: 'Use of uninitialized value in concatenation (.) or string' referring I believe to $3 when it does not exist.
I did try the following:
while ($data_in =~ /<container><a>(.+?)<\/a><b>(.+?)<\/b><\/container> +(<\?query\?>)??/ig) { if ($+ =~ /<\?query\?>/i) {; errors here now $data_out = "$2, $1$3 "; } else { $data_out = "$2, $1 "; } ; further processing here }
But then I get this:
Use of uninitialized value in pattern match (m//)
Of course there is probably a much simpler way of achieving this.
Thanks for any advice
fiat
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Special Variables in Regular Expression
by kyle (Abbot) on Jul 25, 2008 at 14:36 UTC | |
|
Re: Special Variables in Regular Expression
by toolic (Bishop) on Jul 25, 2008 at 14:47 UTC | |
by Anonymous Monk on Jul 25, 2008 at 15:58 UTC | |
|
Re: Special Variables in Regular Expression
by Fletch (Bishop) on Jul 25, 2008 at 14:35 UTC | |
|
Re: Special Variables in Regular Expression
by ikegami (Patriarch) on Jul 25, 2008 at 14:39 UTC | |
|
Re: Special Variables in Regular Expression
by InfiniteSilence (Curate) on Jul 25, 2008 at 16:04 UTC | |
by toolic (Bishop) on Jul 25, 2008 at 16:25 UTC | |
by fiat (Initiate) on Jul 28, 2008 at 07:10 UTC | |
|
Re: Special Variables in Regular Expression
by Anonymous Monk on Jul 25, 2008 at 14:37 UTC |