Matija Papec <[EMAIL PROTECTED]> wrote:
<cut>
>Array is a text file with lines as its elements. It looks like:
>
>--txt file--
># ARIN: Aworldwidemall.com, VA - US
>ALL: 63.64.190.230
># ARIN: Aworldwidemall.com, VA - US
>ALL: 67.64.190.230
>.
>.
>.
>.
># ARIN: Aworldwidemall.com, VA - US
>ALL: 163.64.190.230
>--txt file--
>
>Array is already sorted by IP, so I have to insert a new record
>somewhere(i.e. 65.64.190.230 between 1st and 2nd record) and write a whole
>array back to the file.
How about this, it isn't fastest option but it seems very elegant:
@array = (0..7, 9..15);
@cutoff = splice (@array, 8); # @array is now (0..7)
push (@array, 8); # adding new element
@array = (@array, @cutoff); # @array is now (0..15)
--
Matija