Understanding a hashref

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • keithl
    New Member
    • May 2007
    • 8

    Understanding a hashref

    Hi,.

    Newbie dumb question time ! Could somebody either give me an iniots guide to hashrefs or point me in the direction of one ? I can not get my head around the structure.

    I have sucked in an XML file using XML::Simple and can dump the data quite nicely to screen as per the following

    [CODE=perl]
    $VAR1 = {
    'ORDER' => [
    {
    'ORDER_NUMBER' => 'W-21670-3',
    'DETAILS' => {
    'LOCATION' => 'WGBASLBA',
    'DATE' => '07/05/2006 12:30:19',
    'VENDOR_REF' => 'FI15374820 KNCL1023',
    'TYPE' => {},
    'MOD_LEVEL' => 'EQU-INSTL-CPE',
    'PART_NUMBER' => 'CIS-CAB-ETH-S-RJ45',
    'DOMAIN' => 'Equant Non-serialized',
    'SHIPPED_QTY' => '2',
    'SERIAL_NO' => {}
    }
    },
    {
    'ORDER_NUMBER' => 'W-21670-4',
    'DETAILS' => {
    'LOCATION' => 'WGBASLBA',
    'DATE' => '07/05/2006 12:31:25',
    'VENDOR_REF' => 'FI15374820 KNCL1023',
    'TYPE' => {},
    'MOD_LEVEL' => 'EQU-INSTL-ZFS',
    'PART_NUMBER' => 'SVP-CAB-RJ45-X',
    'DOMAIN' => 'Equant Non-serialized',
    'SHIPPED_QTY' => '1',
    'SERIAL_NO' => {}
    }
    },
    {
    'ORDER_NUMBER' => 'W-11206-1',
    'DETAILS' => {
    'LOCATION' => 'WGBASMAN',
    'DATE' => '03/02/2006 10:35:05',
    'VENDOR_REF' => 'PMAN354 FI14162655',
    'TYPE' => {},
    'MOD_LEVEL' => 'EQU-INSTL-CPE',
    'PART_NUMBER' => 'CIS-CISCO2610XM',
    'DOMAIN' => 'Equant Serialized',
    'SHIPPED_QTY' => '1',
    'SERIAL_NO' => ' FCZ095071BE'
    }
    }
    ]
    };
    [/CODE]

    I am having difficulty just starting to extract the data from the hashref now !
    I want to be able to convert this data to a simple CSV output. - that bit I can do no problem if I just had the data available to me in standard scalars.

    I guess my qwuestion is how to start to reference this data from within the script ?

    Many Thanks

    Keith
    Last edited by miller; Jun 18 '07, 03:58 PM. Reason: Code Tag and ReFormatting
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    check out the first two tutorials on this page:

    Comment

    • keithl
      New Member
      • May 2007
      • 8

      #3
      Thanks Kevin,

      That looks like exactly the kind of guide I've been searching for all day !!

      Keith

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        yer welcome Keith ....

        Comment

        Working...