TheBigAmbulance has asked for the wisdom of the Perl Monks concerning the following question:
I have the need to pull out values in a XML file. Below is an example of the script I have:
#!/usr/bin/perl -w use strict; use warnings; my $mystring = "ABC<ID>blahblah</ID>DEF"; if ( $mystring =~ /<ID>($.)<\/ID>/) { my $ID = $1; print "$ID\n"; }
When I run it, I get:
dpich@m6400-vb:~/Documents$ perl ./xml.pl Use of uninitialized value $. in regexp compilation at ./xml.pl line 6 +. dpich@m6400-vb:~/Documents$
I'm confussed. Why am I getting an unititialzed value error? Isn't '$.' representing text between the <ID> and </ID> tags? My desired result is to place 'blahblah' in the variable $ID.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex/perl question about uninitialized value
by JavaFan (Canon) on Nov 03, 2011 at 14:16 UTC | |
by jwkrahn (Abbot) on Nov 03, 2011 at 18:39 UTC | |
|
Re: regex/perl question about uninitialized value
by toolic (Bishop) on Nov 03, 2011 at 14:23 UTC | |
|
Re: regex/perl question about uninitialized value
by pvaldes (Chaplain) on Nov 03, 2011 at 14:46 UTC | |
by TheBigAmbulance (Acolyte) on Nov 03, 2011 at 14:48 UTC | |
by pvaldes (Chaplain) on Nov 03, 2011 at 14:52 UTC | |
by JavaFan (Canon) on Nov 03, 2011 at 21:46 UTC | |
by pvaldes (Chaplain) on Nov 03, 2011 at 22:41 UTC |