Hi adamZ88,

You wrote: "I did mean what I said about the most efficient way, but I do see your point." I am not sure that you do indeed "get it yet". There will be no user perceptible speed difference between any code in this thread. Forget it! No difference! All of these program snippets are I/O bound under Windows.

There are 2 basic approaches to your first problem of how to remove the ...Music stuff from the beginning of the string. (1)involves counting a number of characters in a "prototype" and then removing that exact number of characters from the input string. (2) Use a regular expression like I did to remove the first part of the file path. This is a much more flexible approach and can be used where the complete path to the Music differs.

Your spec and the introduction of "Eminem" confused me and others. Hence the strange mapping between number of slashes and indentation level in my code.

My advice is to run all of the proposed solutions on your machine and see if you can figure out how all of them work.


In reply to Re^3: Most efficient way to remove some text from a string by Marshall
in thread Most efficient way to remove some text from a string by adamZ88

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.