Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Gurus,

When outputting data to a text file, can you specify if you are wanting the letters to be in bold?

For example

open (fileOUT, ">>$filename") || die ("Couldn't open $filename for writing"); print fileOUT "Location: $element "; close (fileOUT);

I am wanting the Location text when ouputted to the text file to be in bold

Is this possible?

2004-11-04 Edited by Arunbear: Changed title from 'Text Files', as per Monastery guidelines; added code tags

Replies are listed 'Best First'.
Re: Formatting text output
by tachyon (Chancellor) on Nov 03, 2004 at 06:16 UTC

    I am wanting the Location text when ouputted to the text file to be in bold

    Should I fax you though an answer on green paper?

    A text file contains text. Text is just characters. Bold is formatting. Text files can contain formatting instructions but these are just stored as text characters as well. In what viewing device do you wish the text to appear bold? Your text file might contain stuff like:

    #In HTML you would do: <b>Location</b> #In Latex you would do: \textbf{Location} #In an ANSI terminal you need: \e[1mLocation\e[0m #In M$ RTF it is: \b Location\b0 # getting bored now.

      Or, in another well known format, just

      B<Location>

      :-))

      Regards,

      PN5

Re: Formatting text output
by TedPride (Priest) on Nov 04, 2004 at 08:54 UTC
    It's not really a stupid question. The only mistake here is that he didn't tell us what program is going to be loading the text.

    The correct answer is: Yes.

A retraction
by DrHyde (Prior) on Nov 03, 2004 at 10:39 UTC
    I take it all back. I used to say that there were no stupid questions, only stupid answers, but this anonymonk has proven me wrong.
      I take it all back. I used to say that there were no stupid questions, only stupid answers, but this anonymonk has proven me wrong.
      Not really. I could see myself 10 years ago thinking that there were different kinds of letters...bold letters, letters in Helvetica, letters in 20 pt font. In some sense, this is true: your computer has to display different characters depending on what formatting information is attached to them, even if the underlying character is still just a 'b'. I realize that you were just kidding, but I think that we have a duty to inform our undercover brother on how things work in a way that makes him want to ask more questions.

      thor

      Feel the white light, the light within
      Be your own disciple, fan the sparks of will
      For all of us waiting, your kingdom will come