Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Most efficient way to remove some text from a string

by tybalt89 (Monsignor)
on Dec 06, 2016 at 22:29 UTC ( [id://1177337]=note: print w/replies, xml ) Need Help??


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

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

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

Replies are listed 'Best First'.
Re^4: Most efficient way to remove some text from a string
by adamZ88 (Beadle) on Dec 07, 2016 at 00:57 UTC

    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).

        It does not show indentation

      "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.

        To get a list with out either bullets or numbers [use <dl>]

        Please don't do this. It would be misusing semantic tags for stylistic reasons which has been frowned upon since the turn of the millennium. Worst of all, it upsets Sir Tim.

        In HTML, an unordered list (which is what you have in your last example) is semantically identified by the <ul> tag. It's what the U and the L stand for: Unordered List. If you want to present this list without any markers then all you need to do is style it as such, either via CSS or a <style> tag or (simplest) with the style attribute. eg: <ul style="list-style: none;">.

        Conversely the <dl> tag is semantically for Definition Lists (or more generally for Description Lists). Since you aren't defining/describing any terms here, please don't use the tag for this.

        I know you mean well and we've all had to shudder at some point as we feed horrendous input to a broken application to please some PHB but it would be bad for someone to stumble upon this thread and think that <dl> is an acceptable way of styling a list generally.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1177337]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-26 00:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found