What is the use of qw (: ALL) in perl

I know about the function qw(), but in many places I have seen usage qw(:ALL).

What is the advantage of using this and where can I find usage examples qw(:ALL)?

+4
source share
2 answers

qw(:ALL)means the same as (":ALL"). This is just one list of items consisting of one line of four characters - a colon, capital A, capital L, capital L. Nothing interesting.

Many Perl modules offer features that can be imported into your namespace. For example, a module Carpoffers features such as croakand confess. Many of these modules allow you to specify a list of functions that you want to import:

use Carp "confess", "croak", "cluck";
use Carp qw( confess croak cluck );      # this means the same, but looks cleaner

Some modules let you specify something like ":ALL"either ":ALL"or in this list "-all"to indicate that you want to import all the functions that they can offer. File :: Spec :: Functions is an example of a module that does this:

use File::Spec::Functions ":ALL";
use File::Spec::Functions qw( :ALL );    # means the same again

, , ALL ( - , List:: MoreUtils ALL). ; . , :

use Foo::Bar "ALL";

... Foo:: Bar. , .

+13

:ALL import . . File:: Spec:: Functions .

use File::Spec::Functions qw(:ALL);
print tmpdir();
+2

Source: https://habr.com/ru/post/1538052/


All Articles