Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Yes, I know what you said. If this is the logical answer, so simple and straight, I have used it in my previous post already. Does not seem to me that you have read and understood my previous post carefully. What you said is right, but it does not mean anything here.

Also I don't understand why you involve !1, when you can simply state that both 0 and "" are "false". How is this "!" operator get involved, when we are talking about "~" operator. They are relatives, but not the same person.

Although Perl consider multiple values as "false", for a particular function, it usually always returns a single fixed consistent value to represent "false". Ask you an extream question, both 1 and 2 represents "true", when one of your function needs to return "true", will you consistently return 1, or will you sometime return 1 and sometime return 2?

You failed to answer why should "~" receive 0, when "~" can be applied against "empty string" with no problem, and as we see thru lots of my demo, m// actually returns "empty string" from time to time to represent "false".

Your 0+"" example also means nothing here. In your case, "+" operator has to be applied to numbers, but in my case, it is absolutely valid to use "~" operator against a string. try this:

use strict; use warnings; print ~"abcd";

From a logic point of view, what you did is like: I asked how much 1+1 is, and you answered 2+3=5.


Anonymous Monk's dump is useful, and my further explanation is that:

  • as print requires a string value, so "" is used.
  • for "~", although it can be used against both string and number, when both "" and 0 are available to be used, Perl arbitrarily picks 0.

One reminder, the dump you given shows ""\0, please don't make up this !1. State what you observed, and only what you observed.

In reply to Re: Re^4: m//g behaves strange... (!1) by pg
in thread m//g behaves strange... by Anonymous Monk

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (7)
    As of 2018-01-19 06:46 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (216 votes). Check out past polls.