Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
You expected something to work, and it didn't, because of the circumstance.

The > operator is kind of difficult since it is really meant to be used in a boolean comparison. Perl will usually issue a warning if it is used in a void context (which makes sense). I had actually implemented both the > & >> operators in a file class I wrote once, and I found myself writing code like this to avoid warnings.

($f > "writing this to my file") || die "cannot write to file for some + reason";
Its a little overkill, but the project requirements actually dictated this level of strictness so it worked out.

IO::All actually catches the warnings, and dismisses them:

# line 800 in if ($_[0] !~ /^Useless use of .+ \(.+\) in void context/) { goto &$old_warn_handler if $old_warn_handler; warn(@_); }
Which IMHO is kinda dangerous as it hides real warnings too. But hey, TIMTOWTDI i suppose.

In the end, Perl's overloading is great, but is somewhat limited in the sense that the original "intention" of the operator is somewhat retained. Of course, you could also view this as a good thing, as it prevents people from doing really weird stuff.

I have to say, I like both the '>' and '>>' operators - they work just like in the shell, pretty much. '>>' is also a bit C++-ish. But, maybe it's just my brane.

Nah, its what coding in C++ has done to your brain, its not your fault. ;-)


In reply to Re: Re: Re: Re: Re: Ingy's "Swiss Army Light Sabre" - or, "how do you design your APIs?" by stvn
in thread Ingy's "Swiss Army Light Sabre" - or, "how do you design your APIs?" by kal

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 browsing the Monastery: (4)
    As of 2018-01-21 03:46 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (227 votes). Check out past polls.