I am trying to set up a data structure to hold the information in /usr/share/misc/pci.ids. After going backwards and forwards in Programming Perl Ch 9 I tried reading the file in and creating the structure, didn't work. I tried running the sub's with fixed data from a record in the file: didn't work. Finally I created a structure manually but I can't print it out. I think there must be a hole where knowledge of references should be. The structure is
my %pci_ids = { "9710", devices => { "NetMos Technology", devices => [ { devid => "7780", devname => "USB IRDA-port" }, { devid => "9805", devname => "PCI 1 port parallel adapter" }, { devid => "9815", devname => "PCI 9815 Multi-I/O Controller", subinfo => [ { subv => "1000", subdev => "0020", subsys =>"2P0S (2 port paral +lel adaptor)" } ] }, { devid => "9835", devname => "PCI 9835 Multi-I/O Controller", subinfo => [ { subv => "1000", subdev =>"0002", subsys =>"2S (16C550 UART)" +}, { subv => "1000", subdev => "0012", subsys => "1P2S" } ] }, { devid => "9845", devname => "PCI 9845 Multi-I/O Controller", subinfo => [ { subv => "1000", subdev => "0004", subsys => "0P4S (4 port 165 +50A serial card)" }, { subv => "1000", subdev => "0006", subsys =>"0P6S (6 port 1655 +0a serial card)" } ] }, { devid => "9855", devname => "PCI 9855 Multi-I/O Controller", subinfo => [ { subv => "1000", subdev => "0014", subsys => "1P4S" } ] } ] } };
To print it I have
my $href; for $href (keys %pci_ids) { print "Vendor Id: $href:\n"; print("pci_ids{href}: ", ${$href}{devices}, "\n"); }
I think I'm in out of my depth.

In reply to pci.ids to a complex data structure by wynnmc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.