Personal tools
Skip to content. | Skip to navigation
This the only function of this module and it is exported by default. It takes a scalar, array or hash left-value as first argument, and a list of one or more values depending on the type of the first argument as the value for the variable. It will set the variable to that value and subsequently make it read-only. Arrays and hashes will be made deeply read-only.
This pragma allows you to declare constants at compile-time: use constant PI => 4 * atan2(1, 1); When you declare a constant such as "PI" using the method shown above, each machine your script runs upon can have as many digits of accuracy as it can use. Also, your program will be easier to read, more likely to be maintained (and maintained correctly), and far less likely to send a space probe to the wrong planet because nobody noticed the one equation in which you wrote 3.14195. When a constant is used in an expression, Perl replaces it with its value at compile time, and may then optimize the expression further. In particular, any code in an "if (CONSTANT)" block will be optimized away if the constant is false.
Sometimes you need to call a function, get the results, act on the results, then return the result of the function. This is painful because of contexts; the original function can behave different if it's called in void, scalar, or list context. You can ignore the various cases and just pick one, but that's fragile. To do things right, you need to see which case you're being called in, and then call the function in that context. This results in 3 code paths, which is a pain to type in (and maintain). This module automates the process. You provide a coderef that is the "original function", and another coderef to run after the original runs. You can modify the return value (aliased to @_) here, and do whatever else you need to do. 'wantarray' is correct inside both coderefs; in "after", though, the return value is ignored and the value 'wantarray' returns is related to the context that the original function was called in.
This module allows you to define return values of a perl sub that are appropriate given the calling context.
Convert::ASN1 encodes and decodes ASN.1 data structures using BER/DER rules.
Convert::BinHex extracts data from Macintosh BinHex files.
This is Convert::PEM, a module implementing read/write access to ASN.1-encoded PEM files (with optional encryption).