winterli
winterli

Reputation: 84

How to understand such this kind of variable to combine _ and other charcters in Perl?

How to understand such this kind of value in Perl?

my %opt = ( _argv => join(" ",@ARGV),_cwd = cwd()).

Are _argv and _cwd both strings?

Upvotes: 1

Views: 69

Answers (2)

winterli
winterli

Reputation: 84

thanks for everyone, Now I think _argv and _cwd both are just a variable name, equals to "_argv" and "_cwd".

Upvotes: 0

Joni
Joni

Reputation: 111219

From the reference:

The => operator (sometimes pronounced "fat comma") is a synonym for the comma except that it causes a word on its left to be interpreted as a string if it begins with a letter or underscore and is composed only of letters, digits and underscores. This includes operands that might otherwise be interpreted as operators, constants, single number v-strings or function calls. If in doubt about this behavior, the left operand can be quoted explicitly.

my %hash = ('a' => 'b', 'c' => 'd');

can be written as

my %hash = (a => 'b', c => 'd');

Upvotes: 7

Related Questions