in reply to Re: Most efficient way to remove some text from a string
in thread Most efficient way to remove some text from a string

Very Very Close. The first part to trim the unwanted path is working correctly. However, everything printed without any indents(tabs) and with an asterisk.

  • Comment on Re^2: Most efficient way to remove some text from a string

Replies are listed 'Best First'.
Re^3: Most efficient way to remove some text from a string
by tybalt89 (Monsignor) on Dec 06, 2016 at 22:29 UTC

    Are you printing to a terminal or to a web page?

      Probably very convoluted as I am still new to perl, but I output to terminal and "tee" the output to a file with docx extension. I want to open the file with word.

        You can do that. However the file with the .docx extension will not work as a MS Word file because that file will be a simple text file, not a Microsoft document file.

        You can tee to say, "Blah.txt". Open "Blah.txt" in MS word, then execute a macro by perhaps typing Ctl-M for "Music". That macro reformats the input into Word format which can be saved in a next step or it can be automatically be saved as Blah.docx in Word format.

        It is possible in Word to have "auto-run" macros which do things when a particular type of file is opened. But that can be a security risk.

        I suspect that what you need is a "glue piece of Perl" that makes a text file. Then manually open that text file in Word, "hit CTL-M" to re-format and then save the file in Word format or do what your want to do with it.

        You should say for performance, things like: "I want to do this one time only", "I need to do this once per week", "I need to update a webpage every second", etc.

        Does the output on the terminal show indentation? (I don't trust Word to display properly).

        "tee" the output to a file with docx extension. I want to open the file with word.</c>

        A trick for producing documents that look nice in Word: output simple HTML and name the file with a docx extension. Word will format that reasonably and your employer gets a "docx" file.

        You can indent - and get bullet points (or item numbers) - with HTML lists:

        <ul> <li>artist <ul> <li>album <ol> <li>song</li> <li>song</li> </ol> </li> <li>album</li> </ul> </li> <li>artist</li> </ul>

        Note: <ul> produces a bulleted list and <ol> produces a numbered list.

        To get a list with out either bullets or numbers, use:

        Update: As hippo rightly pointed out (below), you should use:

        <ul style="list-style: none;">

        rather than (ab)using <dl> as I have done in the past. However, I have not actually tested that, so I will leave my (heretical) example, below, as-is.

        <dl> <dd>artist</dd> <dd>artist</dd> </dl>

        You can nest <dl> with <ul> and <ol> lists.