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

Re: Re: Conditionally override 'time' builtin with Time::HiRes::time()

by meonkeys (Chaplain)
on Apr 30, 2004 at 00:29 UTC ( #349304=note: print w/replies, xml ) Need Help??


in reply to Re: Conditionally override 'time' builtin with Time::HiRes::time()
in thread Conditionally override 'time' builtin with Time::HiRes::time()

Ah, perfect!

Here's what I really want, though:

#!/usr/bin/perl -w use strict; BEGIN { Time::HiRes->import('time') if eval "require Time::HiRes"; } my $time = time; print "$time\n";
UPDATE (Fri Apr 30 11:15:23 PDT 2004):

Your advice is well-received, chip! Changed the eval EXPR to eval BLOCK. As for letting the user know, that is also a good idea. I left that out for brevity. This is actually for a patch to Net::IRC, so I'll let Jeremy (the maintainer) decide weather he wants to emit a warning.

#!/usr/bin/perl -w use strict; BEGIN { Time::HiRes->import('time') if eval { require Time::HiRes }; } my $time = time; print "$time\n";

---
"A Jedi uses the Force for knowledge and defense, never for attack."

Replies are listed 'Best First'.
Re: Re: Re: Conditionally override 'time' builtin with Time::HiRes::time()
by chip (Curate) on Apr 30, 2004 at 00:33 UTC
    That eval STRING could just as well be eval BLOCK.

    More to the point: Having your program work differently just because a module gets installed is usually evil. People don't expect that installing a module will make apparently unrelated code start doing different things. At least print a diagnostic or something, a la CPAN and Term::ReadLine.

        -- Chip Salzenberg, Free-Floating Agent of Chaos

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://349304]
help
Chatterbox?
[erix]: I recognise the makings of a fine argument
[LanX]: lanx wonders ... how likely is it to talk >95% BS without intention?
[erix]: "gigantic amounts of data" is also not SQLite (imho)
talexb wonders why sqlite2 was deprecated in favour of sqlite3.
[erix]: looks like a fork, rather, no?
LanX /me /me
[erix]: /hehehe
[marto]: LanX yesterday I found out about Gish gallop tactic
[marto]: "Eugenie Scott, executive director of the National Center for Science Education, dubbed this approach the Gish gallop, describing it as "where the creationist is allowed to run on for 45 minutes or an hour, spewing forth torrents of error that the

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (13)
As of 2017-07-28 15:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (431 votes). Check out past polls.