Reputation: 1328
I saw a piece of code in Perl as below:
my $SUCCESS = \0;
my $FAILURE = \1;
It is an assignment and I cannot understand the significance of \1 and \0.
Upvotes: 2
Views: 436
Reputation: 1384
\1
creates a reference to a scalar. Print $SUCCESS
and you'll see SCALAR(0xb83938)
or something similar. In order to get the value try printing $$SUCCESS
and you should get the value of the variable.
Upvotes: 3
Reputation: 39158
These two specific values are special cases in the JSON family of modules, and serialise to false
and true
.
Upvotes: 5