sigils

What is the difference between `$this`, `@that`, and `%those` in Perl?

≯℡__Kan透↙ 提交于 2019-12-28 02:49:07
问题 What is the difference between $this , @that , and %those in Perl? 回答1: A useful mnemonic for Perl sigils are: $calar @rray %ash Matt Trout wrote a great comment on blog.fogus.me about Perl sigils which I think is useful so have pasted below: Actually, perl sigils don’t denote variable type – they denote conjugation – $ is ‘the’, @ is ‘these’, % is ‘map of’ or so – variable type is denoted via [] or {}. You can see this with: my $foo = 'foo'; my @foo = ('zero', 'one', 'two'); my $second_foo =

Significance of an ampersand in VB6 function name?

十年热恋 提交于 2019-11-30 11:26:02
I just got a bunch of legacy VB6 (!) code dumped on me and I keep seeing functions declared with an ampersand at the end of the name, for example, Private Declare Function ShellExecute& . . . . I've been unable to find an answer to the significance of this, nor have I been able to detect any pattern in use or signature of the functions that have been named thusly. Anyone know if those trailing ampersands mean anything to the compiler, or at least if there's some convention that I'm missing? So far, I'm writing it off as a strange programmer, but I'd like to know for sure if there's any meaning

Significance of an ampersand in VB6 function name?

时间秒杀一切 提交于 2019-11-29 17:08:10
问题 I just got a bunch of legacy VB6 (!) code dumped on me and I keep seeing functions declared with an ampersand at the end of the name, for example, Private Declare Function ShellExecute& . . . . I've been unable to find an answer to the significance of this, nor have I been able to detect any pattern in use or signature of the functions that have been named thusly. Anyone know if those trailing ampersands mean anything to the compiler, or at least if there's some convention that I'm missing?

Why do you need $ when accessing array and hash elements in Perl?

烂漫一生 提交于 2019-11-28 13:23:27
Since arrays and hashes can only contain scalars in Perl, why do you have to use the $ to tell the interpreter that the value is a scalar when accessing array or hash elements? In other words, assuming you have an array @myarray and a hash %myhash , why do you need to do: $x = $myarray[1]; $y = $myhash{'foo'}; instead of just doing : $x = myarray[1]; $y = myhash{'foo'}; Why are the above ambiguous? Wouldn't it be illegal Perl code if it was anything but a $ in that place? For example, aren't all of the following illegal in Perl? @var[0]; @var{'key'}; %var[0]; %var{'key'}; Slices aren't illegal

Why do you need $ when accessing array and hash elements in Perl?

喜欢而已 提交于 2019-11-27 07:38:28
问题 Since arrays and hashes can only contain scalars in Perl, why do you have to use the $ to tell the interpreter that the value is a scalar when accessing array or hash elements? In other words, assuming you have an array @myarray and a hash %myhash , why do you need to do: $x = $myarray[1]; $y = $myhash{'foo'}; instead of just doing : $x = myarray[1]; $y = myhash{'foo'}; Why are the above ambiguous? Wouldn't it be illegal Perl code if it was anything but a $ in that place? For example, aren't