Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference betweeen %INC and @INC?

What is the difference between %INC and @INC in Perl?

like image 796
joe Avatar asked Jun 25 '09 21:06

joe


People also ask

Is Inc the same as C Corp?

The abbreviation “Inc.” is used for incorporated companies, either C corporation (c corp) or S corporation (s corp). “LLC” stands for limited liability company. This abbreviation indicates that the business entity is a limited liability company.

WHAT'S INC short for?

The word "incorporated" indicates that a business entity is a corporation. by Michelle Kaminsky, J.D. updated July 27, 2022 · 2min read. "Inc." is an abbreviation of "incorporated," and both the abbreviation and the full word mean that a company's business structure is a legal corporation.


2 Answers

The @INC array holds all the file system paths where Perl will be looking for modules when you use or require them.

After use or require, the %INC hash will contain the loaded modules and where they were loaded from.

Examples from my laptop:

@INC:

'/etc/perl',
'/usr/local/lib/perl/5.10.0',
'/usr/local/share/perl/5.10.0',
'/usr/lib/perl5',
'/usr/share/perl5',
'/usr/lib/perl/5.10',
'/usr/share/perl/5.10',
'/usr/local/lib/site_perl',
'.'

and %INC:

'warnings/register.pm' => '/usr/share/perl/5.10/warnings/register.pm',
'bytes.pm' => '/usr/share/perl/5.10/bytes.pm',
'XSLoader.pm' => '/usr/lib/perl/5.10/XSLoader.pm',
'Carp.pm' => '/usr/share/perl/5.10/Carp.pm',
'Exporter.pm' => '/usr/share/perl/5.10/Exporter.pm',
'warnings.pm' => '/usr/share/perl/5.10/warnings.pm',
'overload.pm' => '/usr/share/perl/5.10/overload.pm',
'Data/Dumper.pm' => '/usr/lib/perl/5.10/Data/Dumper.pm'

(%INC contains Data::Dumper because I used it to quickly dump those two values).

like image 76
innaM Avatar answered Sep 22 '22 03:09

innaM


See perldoc perlvar for @INC, %INC and all other special variables in Perl.

like image 30
Sinan Ünür Avatar answered Sep 24 '22 03:09

Sinan Ünür