What is the difference between $ dxyabc and $ {dxyabc} in Perl?

What is the difference between string $dxyabcand string definitions ${dxyabc}in Perl?

+4
source share
3 answers

Well, it depends on the context. For instance,

$foo = "$dxyabcdef";
$bar = "${dxyabc}def";

$foowill have a value $dxyabcdefinstead $dxyabc, added with def, this value $bar.

Otherwise, as far as I know, they are the same.

+9
source

perldoc perldata explains why curls are used in the context of scalar variables:

, - ( ). , , :

$who = "Larry";
print PASSWD "${who}::0:0:Superuser:/:/bin/perl\n";
print "We use ${who}speak when ${who} here.\n";

Perl $whospeak, a $who::0 $who's. $0 $s () who.


, , $dxyabc ${dxyabc}. , "$dxyabc_" "${dxyabc}_"

+8

No, curly braces are a separator around a variable name.

+1
source

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


All Articles