remove a value from a callback array

Discussion in 'Perl Misc' started by Mark D Smith, May 13, 2005.

  1. Mark D Smith

    Mark D Smith Guest

    Hi

    i have a call-back which i need to check 1 array value and remove some of
    the words used.

    my $status =$content->{status};

    fine gives 1 or 0 which i use but

    $content->{names} is an array of words some of which i want to delete.

    my $names =$content->{names}[0];

    example $names = test1 test2 test3 wibble test4 in this instance i want to
    remove wibble.

    Mark
     
    Mark D Smith, May 13, 2005
    #1
    1. Advertising

  2. Mark D Smith

    Guest

    "Mark D Smith" <> wrote:
    > Hi
    >
    > i have a call-back which i need to check 1 array value and remove some of
    > the words used.


    I don't see any call-backs in your code.

    > my $status =$content->{status};
    >
    > fine gives 1 or 0 which i use but
    >
    > $content->{names} is an array of words some of which i want to delete.


    I assume you mean that $content->{names} is reference to an array of.....

    Anyway, if want to delete words, it may make more sense for it to be
    reference to a hash, rather than a reference to an array.

    If you truly can't turn it into a hash, I guess I would do:

    @{$content->{names}} = grep $_ ne $word_to_delete, @{$content->{names}};

    or if you need to delete several words (stored in %words_to_delete):

    @{$content->{names}} = grep not exists $words_to_delete{$_},
    @{$content->{names}};


    > my $names =$content->{names}[0];


    This looks like Perl, although I don't understand what you intend by it.

    > example $names = test1 test2 test3 wibble test4 in this instance i want
    > to remove wibble.


    This looks like neither Perl nor English, but some incomprehensible mismash
    of the two. I have no idea what you are trying to say about $names.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , May 13, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?R2xlbm4=?=

    Application Cache Remove Callback Issue

    =?Utf-8?B?R2xlbm4=?=, Feb 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,185
    Alvin Bruney [MVP]
    Feb 4, 2004
  2. Simon-Pierre  Jarry
    Replies:
    2
    Views:
    2,414
    Henrik
    Aug 10, 2005
  3. tshad
    Replies:
    6
    Views:
    21,538
    tshad
    Aug 8, 2006
  4. Sam Collett

    Remove specified value from array

    Sam Collett, Jul 21, 2003, in forum: Javascript
    Replies:
    12
    Views:
    251
    Sam Collett
    Jul 24, 2003
  5. M.L.
    Replies:
    8
    Views:
    146
Loading...

Share This Page