gskoli:

Just a minor suggestion on your array initialization: It looks like your data may come from a table that you manually split into three vectors. In the future, you may want to try putting the table into your code like so:

my (@new_lot, @cat_one, @A_services); my @table = qw ( 1 R 182 2 R 111 3 RC 160 4 RC 105 5 R 113 6 RC 121 );

Then you can split it out into separate tables (if you like) like this:

while (@table) { push @new_lot, shift @table; push @cat_one, shift @table; push @A_services, shift @table; }

It adds a little processing time, but makes maintenance quite a bit easier. Alternatively, you can avoid the extra processing and just go ahead and make it an AoA, like this:

my @table = ( [ qw( 1 R 182 ) ], [ qw( 2 R 111 ) ], [ qw( 3 RC 160 ) ], [ qw( 4 RC 105 ) ], [ qw( 5 R 113 ) ], [ qw( 6 RC 121 ) ], );

But you'll have to change your coding a little, though, as $cat_one[2] would become $$table[2][1].

...roboticus

UPDATE: Per chromatic's fine suggestion, I changed the lines like $new_lot[@new_lot] = shift @table; to push @new_lot, it makes the code look much nicer.


In reply to Re: Help Me in following code :: by roboticus
in thread Help Me in following code :: by gskoli

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.