Re: Ragged Hierarchy

2007-12-21 Thread Tom Phoenix
On Dec 21, 2007 11:01 AM, banker123 <[EMAIL PROTECTED]> wrote: > 1. This only processes the first record in the file, the file has many > records and I would like to process each record. It sounds as if you want to wrap what you have in a loop. Perhaps you want to do something like this: while

Re: Ragged Hierarchy

2007-12-21 Thread John W . Krahn
On Friday 21 December 2007 11:01, banker123 wrote: > Some mild progress here is what I have so far. Couple of questions: > > 1. This only processes the first record in the file, the file has > many records and I would like to process each record. > 2. My array has empty elements, how do I remove e

Re: Ragged Hierarchy

2007-12-21 Thread banker123
Some mild progress here is what I have so far. Couple of questions: 1. This only processes the first record in the file, the file has many records and I would like to process each record. 2. My array has empty elements, how do I remove empty or blank elements? 3. When I print the array the first

Re: Ragged Hierarchy

2007-12-21 Thread Gunnar Hjalmarsson
banker123 wrote: Tom Phoenix wrote: In this case, an array could make your life much simpler. After using split() into an array, the problem of identifying the last element's index is easy; it's the last valid index of the array. my @v = split /,/, $_; my $last_elem_index = $#v; Still

Re: Ragged Hierarchy

2007-12-21 Thread banker123
Still stuck, OK I read the data file into an array split the variables using the comma as the delimiter. How do I find the last elemennt in each of the lines as explained in the original post? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http:/

Re: Ragged Hierarchy

2007-12-20 Thread Tom Phoenix
On 12/20/07, banker123 <[EMAIL PROTECTED]> wrote: > I have two started the first is my attempt to read the file into an > array, the second is processing each variable. I am unsure how to > identify the last variable in a variable length line of data. > > open (input, 'c:\organization.txt') or di

Re: Ragged Hierarchy

2007-12-20 Thread banker123
Here is what I have: open ('input', 'C:/Organization.txt') or die "Cannot open file: $!"; open ('output', '>C:/out.txt') or die "Cannot open file: $!"; while () { my ($v1,$v2,$v3,$v4,$v5,$v6,$v7,$v8,$v9,$v10,$v11,$v12,$v13,$v14,$v15,$v16,$v17,$v18,$v19,$v20,$v21,$v22,$v23,$v24) = split (/,/

Re: Ragged Hierarchy

2007-12-20 Thread banker123
I have two started the first is my attempt to read the file into an array, the second is processing each variable. I am unsure how to identify the last variable in a variable length line of data. open (input, 'c:\organization.txt') or die "Cannot open file: $!"; @data=; foreach $line(@data){

Re: Ragged Hierarchy

2007-12-20 Thread michael wang
On 12/20/07, banker123 <[EMAIL PROTECTED]> wrote: > > I have a text file with a ragged hierarchy as shown below, I would > like to structure the data in a different format (also shown below) > please help. Also the data below is just an example the actual data > file is much larger and the hierarc

Re: Ragged Hierarchy

2007-12-20 Thread John W . Krahn
On Thursday 20 December 2007 07:49, banker123 wrote: > > I have a text file with a ragged hierarchy as shown below, I would > like to structure the data in a different format (also shown below) > please help. Also the data below is just an example the actual data > file is much larger and the hier

Re: Ragged Hierarchy

2007-12-20 Thread Tom Phoenix
On 12/20/07, banker123 <[EMAIL PROTECTED]> wrote: > I have a text file with a ragged hierarchy as shown below, I would > like to structure the data in a different format (also shown below) > please help. It sounds as if you want to read a text file, build a Perl data structure in memory, perhaps