Ok I see what you did there
Now say I want the ability to grab any character out of the hole string given the position of it.

Such as mystring123456 so when I find the length of it with length(), so 14 characters. Is there a way I can tell it I want the 6th and 7th characters. Or then just grab the 9th character.


#not actual code more just a logical walk through
if(the string has 20 characters){
     Get the 9th character;
     Get the characters 6-8;
}elsif(the string has 14 characters){
     Get the 6th character from the end;
     Get the last 4 characters from the end;
}

Sorry if this looks ugly but sometimes it helps me think through things like this.

In reply to Re^3: How do I cut single characters out of a string by akechnie
in thread How do I cut single characters out of a string by akechnie

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.