For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2005 > How to divide one array into two arrays?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to divide one array into two arrays?
blackmagic

2005-04-29, 12:48 pm

The context in which i am asking this, is i am reading lines out of a text file, and am going to divide them into three seperate arrays in order to replcae one, and then 'put the text file back together'.

I would like to know how to divide an array into two seperate bits.
For example i expect it may be a fuction like so:

code:
my (@array1,@array2) = divide(@originalarray,5);


This obviously isn't correct, but hypothetically if it was, it would divide '@originalarray' at the '5 value' mark - and place the first part in @array1 and the seocnd half in @array2. If you follow me and understand what i am trying to do, any help is greatly appreciated. Thankyou.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com