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.


In reply to Re: array/hash question with XML simple by VinsWorldcom
in thread array/hash question with XML simple by TienLung

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.