G'day GrizzlyRizly,

Welcome to the Monastery.

That sounds like you're using one of the many GUIs available in Perl: you need to state which. These GUIs can have multiple combobox widgets: again, you need to state which.

When a combobox item is selected, GUIs can provide various types of information about the selection, such as an index or a string.

If you have an index, and don't care about preserving the original array, perhaps use splice.

$ perl -E 'my @x = qw{a b c}; say "@x"; splice @x, 1, 1; say "@x"' a b c a c

If you have an index, but do care about preserving the original array, perhaps use a slice.

$ perl -E 'my @x = qw{a b c}; say "@x"; my @y = @x[0,2]; say "@y"' a b c a c

If you have the selection as a string, and do care about preserving the original array, perhaps create a new array using grep.

$ perl -E 'my @x = qw{a b c}; say "@x"; my $sel = "b"; my @y = grep { +$_ ne $sel } @x; say "@y"' a b c a c

There's other ways to do this depending on your requirements. You should really show us some sample code (see SSCCE): we might be able to suggest a completely different approach when we have a better idea what you're currently doing. Also see the guidelines in "How do I post a question effectively?" for tips on the type of information to provide us with.

— Ken


In reply to Re: Need help with removing values from arrays by kcott
in thread Need help with removing values from arrays by GrizzlyRizly

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.