The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 10-13-2008
pietie pietie is offline
Registered User
  
 

Join Date: Oct 2008
Location: C:/dos/run
Posts: 5
input text from file into 2d array

Hi all

I have a little brainscratcher here.

I want to draw a pie chart from data in a text file.

The drawing of the graph works fine, if I insert the data manually into a 2d array.

Now I want to pull the data from a text file (which was created using a uniq -c command) see sample below.

Code:
      1 012lg.pwv.gov.za
      1 0zero1.co.za
      1 123websites.co.za
      1 3gi.co.za
      1 3rivers.net
     12 3smedia.co.za
      1 4data.co.za
      3 4seasons4u.co.za
      1 aability.co.za
      2 aapg.org
      1 aapt.net.au

Now the thing that I would like to know. is it possible to change that data into something like a 2d array as seen below


Code:
my @data = (['Project', 'HW1', 'HW2', 'HW3', 'MidTerm', 'Final'],
            [25, 6, 7, 2, 25, 35]);

I would prefer if it was in perl, as the graphing is done in perl.

Thank you in advance