> ###########################
> # Delete a hash from the #
> # array #
> ###########################
> sub DeleteHash {
> my ($szpackage, @array) = @_;
> my $szTemp;
> my $test;
>
> $test = @array;
> print "deleted $szTemp $szpackage\n";
>
> print "test=$test\n";
> for $szTemp ( 0 .. $#array ) {
> if ( lc($array[$szTemp]{'package'}) eq lc($szpackage)) {
> print "$szpackage <--- $array[$szTemp]{'package'}\n";
> splice(@array, $szTemp, 1);
Instead of splice, you may want to use
delete $array[$szTemp];
> }
> }
> $test = @array;
> print "test=$test\n";
> return (@array);
> }
>
If you're stuck on an older version that doesn't support delete, something
like (untested):
sub DeleteHash {
my ($szpackage, @array) = @_;
grep { $_->{'package'} =~/$szpackage/ && undef $_} @array;
@array = grep defined, @array;
return @array;
}
if your intent is to modify the original @array, rather than get a modified
copy, I would also pass a ref to @array, instead of the whole thing.
Steve
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs