Date: Wed, 04 Jul 2001 12:58:04 -0700 From: "Godzilla!" Subject: Re: clean up array from "holes"... Message-Id: <3B43754C.A0D9E068@stomp.stomp.tokyo> Alexvalara wrote: > Is it possible to get rid off "holes" in an array... Those "holes" are referred to as null elements and a host of other geeky terms of endearment. > for example: i have something that looks like > ($ref1,$ref2,"",$ref3,"",$ref4,"","") > and i want to transform it into > ($ref1,$ref2,$ref3,$ref4). Piece of cake. This method I exemplify works very nice for small to small-medium size arrays. I would suggest a different method for large arrays. You will note, for a brief period of time, an original array will double in size using this simple method below my signature. For large arrays, it would be more logical to simply push non-null elements into a new array. However, would not you then have two large arrays for a period of time? I would say, "Half a dozen of one, a Baker's Dozen of the other." Imaginative use of shift will turn these large fattening half dozens into a small delicious cream puff; push it in, shift it out. * her butt gains ten pounds with just the thought * Annoyingly, women tend not to shift out as much as we push in. Godzilla! -- TEST SCRIPT: ____________ #!perl print "Content-type: text/plain\n\n"; @Array = ("Godzilla", "", "Rocks", "And", "", "Rolls", "", "!", "", "0", "¿", "0"); $element_count = $#Array; for ($iterate = 0; $iterate <= $element_count; $iterate++) { if ($Array[$iterate] ne "") { push (@Array, $Array[$iterate]); } } for ($iterate = 0; $iterate <= $element_count; $iterate++) { shift (@Array); } print "@Array"; exit; PRINTED RESULTS: ________________ Godzilla Rocks And Rolls ! 0 ¿ 0