Re: Most useless function.
by eyepopslikeamosquito (Archbishop) on Feb 16, 2006 at 20:19 UTC
|
use less 'fat';
| [reply] [d/l] |
|
no less 'important';
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
Re: Most useless function.
by brian_d_foy (Abbot) on Feb 16, 2006 at 18:17 UTC
|
Mark Jason Dominus has some interesting candidates under the "Perl Stupidity" section of his website. The Addition module might be a winner.
| [reply] |
Re: Most useless function.
by swampyankee (Parson) on Feb 16, 2006 at 17:52 UTC
|
is_perl_installed;
would seem to be as about as useless as it could get, as well as quite difficult to implement in Perl for the case returning 'false'.
emc
" When in doubt, use brute force." — Ken Thompson
| [reply] |
|
You can create freestanding applications with PerlApp, so you could write a PerlApp to check to see if perl was installed on the host system. That would be 1 (unlikely) use of "is_perl_installed"
:)
| [reply] |
|
sub is_perl_installed {
if(rand() < 0.5) {
recursively_unlink(find_perl_on_disk());
return 0;
}
return 1;
}
| [reply] [d/l] |
|
Ah someone in the true spirit of the thing.
| [reply] |
Re: Most useless function.
by samtregar (Abbot) on Feb 16, 2006 at 18:03 UTC
|
My vote goes to dump. It may have had a use at some point in the past but it's pretty damn useless today!
-sam
| [reply] |
|
If it works worse than perlcc, that's pretty darned bad!
I try perlcc every few years; last I checked, it would finally compile "hello, world" (it didn't the first time I tried!!!), but it still failed on the second script I tested it on.
Maybe by the time Perl6 replaces perl5, perlcc will work reliably...
| [reply] |
|
| [reply] |
|
Re: Most useless function.
by chromatic (Archbishop) on Feb 16, 2006 at 18:54 UTC
|
| [reply] |
Re: Most useless function.
by McDarren (Abbot) on Feb 17, 2006 at 02:11 UTC
|
This one tickled my fancy :)
#!/usr/bin/perl -wl
use strict;
use Acme::Don::t;
print "this" and don't {print "that"};
| [reply] [d/l] |
|
do {
# some debugging stuff
}
#becomes
don't {
# some debugging stuff
}
It's essentially a block comment for code removal, and while I wouldn't put it in production, it's a very useful programming tool. IMO, anyhow.
| [reply] [d/l] |
|
That is not only a clever trick, but it provokes thoughts I should have been having for years.
-----------------------
You are what you think.
| [reply] |
Re: Most useless function.
by Steve_p (Priest) on Feb 17, 2006 at 14:09 UTC
|
I wouldn't have thought it, but some fairly basic usage of not (as apposed to ! which worked just fine) caused core dumps from 5.6.0 through at least 5.8.5. Although technically an operator, the core dump went over five years without a single bug filed on not. Its ranking fairly high on the uselessness scale for me right now.
| [reply] [d/l] [select] |
|
What was the actual Perl code triggering the core dump?
| [reply] |
|
Actually, I was a bit wrong. It was actually a fairly useless use of not.
perl -e 'not() || 1'
perl -e 'die unless not()'
| [reply] [d/l] [select] |
Re: Most useless function.
by Moriarty (Abbot) on Feb 17, 2006 at 01:53 UTC
|
I have heard that ispoweron() isn't all that useless. It's used by some systems to unmount filesystems, park drive heads and other useful stuff before the capacitors are drained after the power has been turned off.
| [reply] |
|
| [reply] |
|
AFAIK, there's also a signal that gets sent in event of a power fluctuation. From there, you can use "ispoweron()" to tell the difference between a momentary power blip, and a real outage condition.
You'll only bother to poll when you've got a signal that said there was a potential outage issue, and then only to check to see if the situation has resolved itself (power back on or not). Depending on that knowledge, you can implement a variety of recovery policies (shutdown immediately; wait 10 minutes, then shutdown if the power is still out; etc).
From what I remember, it's not a useless function; albeit rarely very useful, either. AFAIK, it's been implemented on one of the BSD varients (BSDI Unix, perhaps?)
--
Ytrew
| [reply] |
|
Re: Most useless function.
by Anonymous Monk on Feb 16, 2006 at 17:16 UTC
|
Perl doesn't have any "useless" builtin functions, as far as I can tell; they all have (or had) a purpose.
Perl has a lot of redundant functionality; there's many ways to get the same job done.
If you're talking about user defined functions, look up the term "JAPH" sometime. ;-)
| [reply] |
|
| [reply] |
|
The point of a ispoweron() function is to detect whether the main power source is on, or whether you're running under backup power (UPS, generator, etc).
Once you detect that you're running under UPS power, you can then do a controlled shutdown of the system before power runs out.
It's much less useless than a JAPH, which is a complicated way of writing something that could be written in a straightforward way.
| [reply] |
Re: Most useless function.
by Aristotle (Chancellor) on Feb 21, 2006 at 03:29 UTC
|
The BeOS kernel actually has such functions:
- int32 is_computer_on(void)
Returns 1 if the computer is on. If the computer isn’t on, the value returned by this function is undefined.
- double is_computer_on_fire(void)
Returns the temperature of the motherboard if the computer is currently on fire. If the computer isn’t on fire, the function returns some other value.
Makeshifts last the longest.
| [reply] |