in reply to accessing array items

Is the information in a text file, a database, or hard-coded in your script?

Are you asking how to use arrays in Perl?

If you could show us the code you've written so far, we'd be happy to help you move along the spiritual path that is Perl...

Replies are listed 'Best First'.
Re^2: accessing array items
by Tedffo (Initiate) on Jul 29, 2008 at 10:53 UTC
    Yes, I guess this is a question on how to manipulate arrays in Perl. The data is in a text file. The code looks like this:
    foreach (<>) { $line=$_; if ($line =~ m(^\s{2}[-0])) #gets us to required lines in dataset { chomp $line; @items_in_line = split ' ', $line; } print $items_in_line[o]; }
    Prob is, I cant seem to get at the individual numbers on each line.
    thanks again!
      $items_in_line[3] would give you the fourth value on the line. (Indices start at 0, though you can change that if you need to.)

      Be careful to make certain there really is a fourth value before you try to manipulate it. ($#items_in_line is the number of elements in the array.)