J
JS Bangs
Hey, all:
I've got a function that would like to be able to delete an array element
from an array in the caller's scope, given only the array element (not the
array itself, or a reference to it). The idea is to have something that
duplicates the functionality of delete(), but which tacks a bit of
other processing onto it. The existing code is quite simple, and looks
like this:
##########
sub delete_seg {
return undef unless is_segment($_[0]);
$_[0]->clear;
delete($_[0]);
}
#########
In the calling script (which has imported the function delete_seg()):
#########
delete_seg($word[3]);
#########
Unfortunately, this does not work. $word[3] remains firmly in place with a
defined value. What can I do to make this work?
Jesse S. Bangs (e-mail address removed)
http://students.washington.edu/jaspax/
http://students.washington.edu/jaspax/blog
I've got a function that would like to be able to delete an array element
from an array in the caller's scope, given only the array element (not the
array itself, or a reference to it). The idea is to have something that
duplicates the functionality of delete(), but which tacks a bit of
other processing onto it. The existing code is quite simple, and looks
like this:
##########
sub delete_seg {
return undef unless is_segment($_[0]);
$_[0]->clear;
delete($_[0]);
}
#########
In the calling script (which has imported the function delete_seg()):
#########
delete_seg($word[3]);
#########
Unfortunately, this does not work. $word[3] remains firmly in place with a
defined value. What can I do to make this work?
Jesse S. Bangs (e-mail address removed)
http://students.washington.edu/jaspax/
http://students.washington.edu/jaspax/blog