It has already been noted in your previous thread that a set of arrays is a poor choice of data structure for your task. Difficulty of deleting a record is one problem of many that you'll encounter - it's much easier using hashes.
#!/usr/bin/env perl use v5.12; use Data::Dumper; my %students = ( x1 => { name => "Alice", telephone => 1001, regno => "x1", }, x2 => { name => "Bob", telephone => 1002, regno => "x2", }, x3 => { name => "Carol", telephone => 1003, regno => "x3", }, ); say "Let's look at the data structure..."; print Dumper \%students; say "What is student x1's telephone number?"; say $students{x1}{telephone}; say "What is Carol's telephone number?"; my ($carol) = grep { $_->{name} eq "Carol" } values %students; say $carol->{telephone}; say "Now let's delete student x2..."; delete $students{x2}; say "And change Carol's phone number"; $carol->{telephone} = "1004"; say "Let's look at the data structure again..."; print Dumper \%students;
In reply to Re: How can one delete an element and it corresponding values from the array of arrays?
by tobyink
in thread How can one delete an element and it corresponding values from the array of arrays?
by supriyoch_2008
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |