I've been working on a nifty little program to count up all my CodeRed attacks per day, and I realized I could chop an entire line (!!) off my program if i could change this:
@parsed=split/\s/,$line; $CR{substr($parsed[3],1,11)}[$line=~/(NNNNN)/+2*$line=~/(XXXXX)/]++;
(BTW, that takes the date, uses it as a key, and index 0 is everything else, index 1 is CRI hits on that date, and index 2 is CRII hits on that date.)
To a one liner replacing the $parsed[3], with some kind immediate access to index 3 of what split passes back, like
$CR{substr(split(/\s/,$line)[3],1,11)}[$line=~/(NNNNN)/+2*$line=~/(XXX +XX)/]++;
that example doesnt work, obviously, and i've been mangling split every which way to get that quick reference to any of it's indices. I've treated it as a real array, as an arrayref but no way i do it will get me the desired results. I've tried simple testing by just trying to print out an index like that, without it nested in substr, but regardless it doesn't work. Anyone know how to help me save a precious few bytes from my code?

Thanks

@:::::::((==========Rydor====>

In reply to split as immediate array? by Rydor

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.