"\&" - is used while bullet proofing a program because it permits runtime error to exit my program so sudden. so the programmer could easily notice the error.

"eval" - is used when you have finished bullet proofing a program. well it just trap runtime errors that was not caught by the programmer.

<update>

No, the difference is that \& { } constructs a reference to a subroutine which is named after whatever it is the evaluation of the contents of { } returns. That is, \& {chr(65)} returns a reference to the subroutine A, be this sub defined or not. In your example, a subroutine is allocated in the symbol table named after the return value of exit or yes\n, depending on the input. Which is a weird form to shoehorn something into the symbol table.

</update>

<No, the difference is that \& { } constructs a code reference from a block (which isn't even a subroutine, just a code reference) which is a reference to a subroutine , while eval { } ... well, evals the { } block. So, \& { } is just bare metal, without the additional features eval { } provides.

One could say \& { } is to eval { } what do is to require, if that helps (it's not quite so).

I don't know the compile time implications of \& { }, but I suspect them to be the same as with eval { } - this all isn't about bullet proofing, but - again - I might be wrong.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

In reply to Re^5: Mr. Ternary is greater than Mrs. If Else by shmem
in thread Mr. Ternary is greater than Mrs. If Else by PerlPhi

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.