-5

I'm trying to create a database .Each element in list contains details in the form of associative array and the last element of each of these associative array is a 2-d array,i need help initializing it ..

Sayan Paul
  • 91
  • 1
  • 13

1 Answers1

1

You need to say much more about what it is you are trying to do, but this may help: it initialises a Perl data structure in the way you have described. Note that there can be no "last" element of a hash (a better name than "associative array") as hashes are unordered. I have used the customers field of the data to hold the 2D array you talked about.

use strict;
use warnings;

my @list = (
  {
    id => 1,
    name => 'cattle',
    customers => [
      [ 'World Bank', 'Space Marines', 'Undersea Exploration' ],
      [ 1, 2, 3 ],
      [ 0.0500, 0.6322, 0.9930 ],
    ],
  },
  {
    id => 2,
    name => 'arable',
    customers => [
      [ 'Jack Spratt', 'Molly Malone', 'The Whistler' ],
      [ 4, 5, 6 ],
      [ 0.0022, 0.1130, 0.6930 ],
    ],
  },
  {
    id => 3,
    name => 'seafood',
    customers => [
      [ 'Tai Chi School of Fishery', 'Latin Intermediary College', 'Ping Pong Gymnastics' ],
      [ 7, 8, 9 ],
      [ 0.0012, 0.8540, 0.9817 ],
    ],      
  },
);
Borodin
  • 126,100
  • 9
  • 70
  • 144
  • thank you for taking interest and sorry i forgot to mention that i'm trying to take the input from the user itself i'm having trouble understanding how append the grouped data with the list properly and perform delete or insertion operations on it.. – Sayan Paul Nov 16 '12 at 23:10