How does perl recognise end of variable while printing? -
how perl recognise end of variable?
for example, code:
use warnings; $a = 10; print "value of $a:::"; output:
use of uninitialized value $a:: in concatenation (.) or string @ tryprint.pl line 6. value of : why consider $a:: , not $a: or $a:::
this works:
print "value of $a\:::"; prints:
value of 10:::
:: used print/access variable package/symbol table. eg, access scalar variable x in package abc, perl uses $abc::x abc name of symbol table , x variable. similarly, when used $a:::, perl thought there package name 'a' , variable name :, , hence error.
see example below:
our $a = 10; { $a=20; print "lexical $a \n"; print "value of $main::a"; }
Comments
Post a Comment