The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Reading specific contents from 1 input files and appending it to another input file sksahu Shell Programming and Scripting 5 01-14-2009 06:09 AM
Replace text in input file daphantomica Shell Programming and Scripting 2 04-25-2008 03:39 AM
input text into file cannonfodder Shell Programming and Scripting 1 12-15-2007 10:37 AM
sh shell user input and stote it to a array user_prady Shell Programming and Scripting 7 11-16-2007 03:51 AM
How to input username on text file into finger command on shell script Micz Shell Programming and Scripting 3 11-08-2005 02:38 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #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
  #2 (permalink)  
Old 10-13-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
Code:
my @data = ['Project', 'HW1', 'HW2', 'HW3', 'MidTerm', 'Final'],
            [25, 6, 7, 2, 25, 35];
print $data[0][1] "\n";   # first row second column
creates a matrix - your two D array. IS that what you want?
  #3 (permalink)  
Old 10-14-2008
pietie pietie is offline
Registered User
  
 

Join Date: Oct 2008
Location: C:/dos/run
Posts: 5
Quote:
Originally Posted by jim mcnamara View Post
Code:
my @data = ['Project', 'HW1', 'HW2', 'HW3', 'MidTerm', 'Final'],
            [25, 6, 7, 2, 25, 35];
print $data[0][1] "\n";   # first row second column
creates a matrix - your two D array. IS that what you want?
hi Thank you for your reply. It put me on the right track, and now I have the text file in a matrix(2d array). Regards
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0