Ad
Difference Between Use Modulename; And Use Modulename();
Is there any difference between use Modulename;
and use Modulename();
?
Sometimes I see, for example, use Carp;
and sometimes use Carp ();
Ad
Answer
As documented,
use Modulename;
is the basically the same as
BEGIN {
require Modulename;
import Modulename;
}
while
use Modulename ();
is the basically the same as
BEGIN { require Modulename; }
That means the parens specify that you don't want to import anything. (It would also prevent a pragma from doing its work.)
Carp exports confess
, croak
and carp
by default, so
use Carp;
is short for
use Carp qw( confess croak carp );
By using
use Carp (); # or: use Carp qw( );
confess
, croak
and carp
won't be added to the caller's namespace. They will still be available through their fully qualified name.
use Carp ();
Carp::croak(...);
Ad
source: stackoverflow.com
Related Questions
- → Chaining "Count of Columns" of a Method to Single Query Builder
- → Format date time properly with laravel and carbon
- → angularjs data binding issue
- → htaccess not working properly for sub url having more slashes
- → Is Laravels' DD helper function working properly?
- → JS Get multiple links in a string
- → add event not working properly with closure in a loop
- → Liquid Slider not working properly in chrome extension
- → SEO effects of wrapping block-level elements in links
- → Alexa/similarWeb traffic tracking on single-page application?
- → How can I change what to be indexed on google by using WooCommerce?
- → jQuery's `getScript` fails. The path is correct, and the script was downloaded properly.
- → How to execute Stored Procedure from Laravel
Ad