CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
deleting hash ref key & value



Dec 17, 2015, 1:04 AM

Post #1 of 2 (1707 views)
deleting hash ref key & value Can't Post

Hi folks,

Is this the right way to delete a hash? I have this portion of a script and wanted to delete the hash ref/key/value but it errored out "delete argument is not a HASH or ARRAY element or slice". TIA!

my $unwanted;
foreach my $wafer (@{$model->wafers}){
foreach my $die ( @{$wafer->dies}){
if ($die->{soft_bin} eq "") {
$unwanted = $die;
delete $wafer->dies($unwanted);


Dec 17, 2015, 10:36 AM

Post #2 of 2 (1683 views)
Re: [alferic] deleting hash ref key & value [In reply to] Can't Post

You have not given us enough information to help you. We need to see your data structures. Your for loops are valid perl only if $model and $wafer are objects. If they are, we will also need to see their code (or their documentation). If not, you must fix your code. (We probably can help with this after we see the data structure.)

The function 'delete' removes a key from a hash. Your error message is telling you that that is not what you are doing. My best guess is that you are trying to remove an element from an array. That would be very hard to do. You do not want a design that requires it. Please explain the 'big picture' of what you are trying to do.
Good Luck,


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives