Hi PerlMonks,

I have 3 arrays i.e. @sample1, @sample2 and @sample3 each with 4 elements. One element in one array is linked to the corresponding position element in the other two arrays. I mean to say that a, 1 & x1 are linked and so are the others. Now I want to put all the arrays in a bigger array @big. At some point of time, I might be interested to delete one element x3 from @sample3 and its corresponding values from @sample1 and @sample2 i.e. c & 3 and likewise from array @big. The big array is an array of arrays. I am at my wit's end to find out the resultant big array and other three arrays after removing x3 & its corresponding values from @sample1 & @sample2. I am looking forward to suggestions and guidance from PerlMonks in this matter.

#!/usr/bin/perl use warnings; use strict; my @sample1=qw/a b c d/; my @sample2=qw/1 2 3 4 /; my @sample3=qw/x1 x2 x3 x4/; # Joined array: my @big=(@sample1, @sample2, @sample3); print"\n Original Big Array:\n @big\n"; # To store the array values in a hash: my %h; # Code for removing x3 & its corresponding values from big array??? # and code for modified @sample1, @sample2 & @sample3 ??? $deleted_ele="x3"; ???? print"\n Original big array: @big\n Resultant big array: @mod_big\n Deleted Element: $deleted_ele\n Modified sample1: @mod_sam1\n sample2: @mod_sam2\n sample3: @mod_sam3\n\n"; exit;

Result should look something like:

Original big array: a b c d 1 2 3 4 x1 x2 x3 x4 Resultant big array: a b d 1 2 4 x1 x2 x4 Deleted Element: x3 Modified @sample1: a b d @sample2: 1 2 4 @sample3: x1 x2 x4

In reply to How can one delete an element and it corresponding values from the array of arrays? by supriyoch_2008

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.