Well, no one would get "trapped" in you if statements if you indented your code. That would help both you and the raving lunatic who will have to maintain your creation. ;)

Here, the warning is actually helpful. The thing to note here is that substr doesn't work like splice in that the position you higlight by LENGTH and OFFSET (see the docs) isn't removed it is just identified. So with this substr, you tell perl go to the beginning of the string $links and look at one character. But you neither store that character anywhere or change it, which makes it void context. You don't change the string, and you don't store what you've found. So perl thinks somethings fishy.

If you want to remove that first character try:
substr($links, 0, 1) = undef; or even substr($links, 0, 1, undef);


HTH.



Code is (almost) always untested.
http://www.justicepoetic.net/

In reply to Re: Useless use of substr in void context by jweed
in thread Useless use of substr in void context by mkurtis

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.