in reply to Re: How do I delete a specific element from an XML file
in thread How do I delete a specific element from an XML file

A side note: delete an array element does not shift index. Try the following example:

use Data::Dumper; use strict; use warnings; my @a = (1,2,3,4,5); print Dumper(\@a); delete $a[1]; #splice(@a, 1,1); print Dumper(\@a);

It gives you:

$VAR1 = [ 1, 2, 3, 4, 5 ]; $VAR1 = [ 1, undef, 3, 4, 5 ];

The array after deletion does not become something like

$VAR1 = [ 1, 3, 4, 5 ];

as splice does.

Replies are listed 'Best First'.
Re^3: How do I delete a specific element from an XML file
by Maxim (Sexton) on Oct 31, 2004 at 05:18 UTC
    Sorry about the spelling mistake I made for $counterchan. I understand in general what you said with the example but how do I implemented?
Re^3: How do I delete a specific element from an XML file
by Maxim (Sexton) on Nov 02, 2004 at 04:02 UTC
    I found the problem, it come from with the exit command. WIth this it works well
    delete $category->{'subcategory'}[$countersubs]{'product'}[$counterpro +d]{'channel'}[$counterchan]
    only when all loops is finished their process.
Re^3: How do I delete a specific element from an XML file
by Maxim (Sexton) on Nov 02, 2004 at 06:45 UTC
    Probem solve! Just need to put the command "exit 1" outside of the loop with a condition and everything works welll.
    Example:exit 1 if isDel;