I can't find anywhere what the :: is for in Perl. Example:
$someVariable::QUERY{'someString'};
Thanks!
The Special Character Classes in Perl are as follows: Digit \d[0-9]: The \d is used to match any digit character and its equivalent to [0-9]. In the regex /\d/ will match a single digit. The \d is standardized to “digit”.
Under /a , \d always means precisely the digits "0" to "9" ; \s means the five characters [ \f\n\r\t] , and starting in Perl v5. 18, the vertical tab; \w means the 63 characters [A-Za-z0-9_] ; and likewise, all the Posix classes such as [[:print:]] match only the appropriate ASCII-range characters.
There are three types of character classes in Perl regular expressions: the dot, backslash sequences, and the form enclosed in square brackets. Keep in mind, though, that often the term "character class" is used to mean just the bracketed form. Certainly, most Perl documentation does that.
=~ is the Perl binding operator. It's generally used to apply a regular expression to a string; for instance, to test if a string matches a pattern: if ($string =~ m/pattern/) {
These are package separators. I suspect the actual code is more like $SomePackage::SomeHash{'SomeKey'}
. This syntax allows accessing a "package variable", in this case a hash, from some other package, or by its fully qualified name. You are probably more accustomed to seeing something like:
package SomePackage;
our %SomeHash;
$SomeHash{'SomeKey'} # do something with $SomePackage::SomeHash{'SomeKey'} here
A use case is setting up some module, like say Data::Dumper, which uses these package variables to control output:
use Data::Dumper;
local $Data::Dumper::Sortkeys = 1;
print Dumper { c => 3, a => 1, b => 2 };
... though this type of usage is typically avoided by using Object Oriented style.
See also: the famous "Coping with Scoping" article by MJD: http://perl.plover.com/FAQs/Namespaces.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With