Hello guys, im a newbie at Perl, my apologies if I ask something that is weird. Im having a trouble here for an exam, it requires me to use this input:
Slot Description HW Version Software Version Uptime 0 CAM (0D, 12U) CAM-01122W/K04 CMTS_V07.03.01.39 112 days 2:26: +09 1 CAM (0D, 12U) CAM-01122W/K04 CMTS_V07.03.01.39 112 days 2:26: +09 2 CAM (0D, 12U) CAM-01122W/K04 CMTS_V07.03.01.39 112 days 2:26: +09 3 CAM (0D, 12U) CAM-01122W/K04 CMTS_V07.03.01.39 112 days 2:26: +10 4 CAM (0D, 12U) CAM-01122W/K05 CMTS_V07.03.01.39 112 days 2:26: +10 5 CAM (0D, 12U) CAM-01122W/K04 CMTS_V07.03.01.39 112 days 2:26: +09 6 CAM (0D, 12U) CAM-01122W/K04 CMTS_V07.03.01.39 112 days 2:26: +10 Press <space> to continue, <cr> to single step, ? for help 7 CAM (0D, 12U) CAM-01122W/K05 CMTS_V07.03.01.39 112 days 2:26: +09 8 CAM (0D, 12U) CAM-01122W/K05 CMTS_V07.03.01.39 112 days 2:26: +10 9 CAM (0D, 12U) CAM-01122W/K05 CMTS_V07.03.01.39 112 days 2:26: +10 10 CAM (16D, 0U) CAM-20016W/G04 CMTS_V07.03.01.39 112 days 2:29: +46 11 CAM (16D, 0U) CAM-20016W/G04 CMTS_V07.03.01.39 112 days 2:30: +15 12 CAM (16D, 0U) CAM-20016W/G04 CMTS_V07.03.01.39 112 days 2:29: +51 13 CAM (16D, 0U) CAM-20016W/G04 CMTS_V07.03.01.39 112 days 2:29: +33 14 CAM (16D, 0U) CAM-20016W/G04 CMTS_V07.03.01.39 112 days 2:29: +47 15 CAM (16D, 0U) CAM-20016W/G04 CMTS_V07.03.01.39 112 days 2:29: +52 Press <space> to continue, <cr> to single step, ? for help 17 RCM A RCM-01000W/E04 CMTS_V07.03.01.39 112 days 2:29: +24 18 RCM B RCM-01000W/E04 CMTS_V07.03.01.39 112 days 2:28: +22 19 SCM A SCM-02440W/B10 CMTS_V07.03.01.39 112 days 2:32: +51 20 SCM B SCM-02440W/B10 CMTS_V07.03.01.39 112 days 2:32: +51
and output the following structure:
my %slotHash = ( "9" = ( type => "CAM", #The first three characters of the descr +iption slotID => 9, description => "CAM (0D, 12U)", hwVersion => "CAM-01122W/K05", swVersion => "CMTS_V07.03.01.39", uptime => 9685570 ), "17" = ( type => "RCM", #The first three characters of the descr +iption slotID => 17, description => "RCM A", hwVersion => "RCM-01000W/E04", swVersion => "CMTS_V07.03.01.39", uptime => 9685764 ), );

Can you guys point me in the right direction?

Im having problems how to declare a hash like this, this input is weird, maybe I can change the input to a delimiter or something, if I do this, how can I do the hash with this specific structure? THANKS!

In reply to Defining hash structure by mtx

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.