in reply to array/hash question with XML simple
Are you sure your $dat variable contains a number that corresponds to a valid array index for PAGE in the XML file?
Your code works for me:
Added:use strict; use XML::Simple; my $docid = "pounces"; my $dat = $ARGV[0];
Used 2 files, both containing the same data so I could diff between runs. Both files had this content:
<opt version="1.0"> <page ui="gtk-gaim"> <account protocol="prpl">VinsWorldcom1</account> <actions> <action type="popup-notify" /> </actions> </page> <page ui="gtk-gaim"> <account protocol="prpl">VinsWorldcom2</account> <actions> <action type="popup-notify" /> </actions> </page> </opt>
Run on Windows ActiveState Perl v5.8.8:
{C} > 750398.pl 2 {C} > diff pounces.xml "Copy of pounces.xml" {C} > 750398.pl 1 {C} > diff pounces.xml "Copy of pounces.xml" 7a8,13 > <page ui="gtk-gaim"> > <account protocol="prpl">VinsWorldcom2</account> > <actions> > <action type="popup-notify" /> > </actions> > </page>
So you can see in the first run when I ask to delete "PAGE - 2" from the "2" as ARGV, nothing changes because there are only 2 PAGE array elements ([0] and 1). When I run it again as ask for 1, the second entry appears in the "COPY OF" file (as nothing happens to that file, it's my baseline), but it's deleted from the 'pounces.xml' file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: array/hash question with XML simple
by TienLung (Acolyte) on Mar 13, 2009 at 13:54 UTC |