Closed Thread
Results 1 to 9 of 9

Thread: Two Questions.....

  1. #1
    Cosmet is offline Learning Programmer
    Join Date
    Oct 2006
    Posts
    58
    Rep Power
    0

    Two Questions.....

    Ok, the first question is how do I remove an element of an array? It can be any element.....

    Second: how do I use while on an array?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Oct 2006
    Location
    Hendersonville, NC
    Posts
    1,700
    Blog Entries
    3
    Rep Power
    0

  4. #3
    KevinADC is offline Programmer
    Join Date
    Jan 2007
    Posts
    125
    Rep Power
    0
    xXHalfSliceXx,

    That will work great for..... javascript arrays.

    I would post a suggestion or two but Cosmet is in the habit of not replying to threads he starts.

  5. #4
    Cosmet is offline Learning Programmer
    Join Date
    Oct 2006
    Posts
    58
    Rep Power
    0
    Sorry, once I get the answer I forget to reply thanks..... Please help! I'll reply this time.

  6. #5
    KevinADC is offline Programmer
    Join Date
    Jan 2007
    Posts
    125
    Rep Power
    0
    Code:
    my $element = 'cat';
    my @array = qw(dog pig cat bird);
    @array = grep {$_ ne $element} @array;
    print "@array";
    Second, don't use "while" on an array, that is almost never appropriate. Use "for" or "foreach" or "map" or "grep" for processing arrays.
    Last edited by xXHalfSliceXx; 03-14-2007 at 05:35 PM.

  7. #6
    Cosmet is offline Learning Programmer
    Join Date
    Oct 2006
    Posts
    58
    Rep Power
    0
    Thank you for replying - I've been assigning the array values to "", is that good enough for erasing them?

  8. #7
    KevinADC is offline Programmer
    Join Date
    Jan 2007
    Posts
    125
    Rep Power
    0
    Depends on what you are doing, that just makes the array element an empty string, but the array will still be the same length as before because you did not delete the array element, just defined it as empty. Most likely that is not what you really want to do.

  9. #8
    KevinADC is offline Programmer
    Join Date
    Jan 2007
    Posts
    125
    Rep Power
    0
    hmmm...another thread abandoned by cosmet, I should have learned my lesson. I have now.

  10. #9
    Cosmet is offline Learning Programmer
    Join Date
    Oct 2006
    Posts
    58
    Rep Power
    0
    Sorry, I sometimes go for days without getting on the net/computer. I've just now started working on this project again. Thank you for your suggestions, I managed to get them working well in my script.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Several C Questions
    By SegmentationFault in forum C and C++
    Replies: 1
    Last Post: 09-18-2011, 05:38 AM
  2. HELP with QUESTIONS!!!!!!!!
    By lionaneesh in forum C and C++
    Replies: 3
    Last Post: 03-23-2010, 09:04 PM
  3. Some questions
    By ahmed in forum Linux/Unix General
    Replies: 2
    Last Post: 11-07-2009, 11:50 AM
  4. Need some help regarding questions
    By ahmed in forum Java Help
    Replies: 2
    Last Post: 11-01-2009, 08:13 AM
  5. Looking for questions
    By TkTech in forum General Programming
    Replies: 7
    Last Post: 10-31-2009, 05:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts