What does the "$ :: n" mean for perl?

Did you know that "$ :: n;" mean? The code section is as follows.

use JSON::XS; # ... open (YI, "| $cmd"); my $msg = { test => test }; my $emsg = encode_json($msg); print YI "$msg_inject\n" unless $::n; close YI;` 

I remember that before I met $ :: v. What is $ :: v? Does it have additional use?

I only know $: a reserved word for writing perl with a lot of lines filling the field.

Yours faithfully,

TWLMD.

+7
perl
source share
1 answer

$::n matches $main::n or just $n , where $ n is in the package main:: .

Such a notation ignores the possible lexical (defined with the help of my ) definition of $n , i.e.

 perl -Mstrict -we 'our $n=3; my $n=1; print $::n' 

pin 3

+18
source share

All Articles