Re: code line of the day
[email protected] ("A. Pagaltzis") Sat, 9 Sep 2006 01:50:02 +0200
| Newsgroups | perl.fwp |
|---|---|
| Message-ID | <20060908235002.GF17294@klangraum> |
* John Douglas Porter <[email protected]> [2006-09-08 17:20]: > I believe it's better to do > > ref $_ ? "$$_" : "$_" > > than > > ref $_ eq 'SCALAR' ? "$$_" : "$_" > > because, in the first case, you get an actual error in the > exceptional case (a ref of the wrong type), whereas in the > latter case you get a useless and wrong string in the value, > which you might not catch until later, if ever. > > If you really want to test the ref type, do so robustly using > the methods in Scalar::Util. Excellent points, both of them; I’ll make a mental note. Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>