Recently a question was asked in SOPW that could be answered straight out of the Perl Cookbook. Not wanting to get myself in trouble by copying what was listed in the book, I answered the question with the general slant of the cookbook entry, as well as what entry number it was exactly.
I asked a couple of people (very casually) what their initial thoughts about posting code straight out of a book were, and they agreed with me that it might be pushing the bounds of fair use.
In this case, what is the best solution? Many times the solutions provided in text are very good, and trying to explain how they work or even rewriting (paraphrasing) the code yourself is not as good an answer.
I must admit to quite a bit of ignorance of copyright law, but I am pretty sure that unless the text explicitly says we are free to copy the examples we should be leaving them in the book.

Guildenstern
Negaterd character class uber alles!

In reply to Fair Use When Referring to Book Answers? by Guildenstern

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.