Template::Manual::VMethods

Template::Manual::VMethods is a Perl module with virtual methods.
Download

Template::Manual::VMethods Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Andy Wardley
  • Publisher web site:
  • http://search.cpan.org/~abw/

Template::Manual::VMethods Tags


Template::Manual::VMethods Description

Template::Manual::VMethods is a Perl module with virtual methods. Template::Manual::VMethods is a Perl module with virtual methods.Scalar Virtual MethodsdefinedReturns true if the value is defined. lengthReturns the length of the string representation of the item: Password too short, dumbass! repeat(n)Repeat the string a specified number of times. # foofoofooreplace(search, replace)Outputs the string with all instances of the first argument (specified as a Perl regular expression) with the second. # foo_bar_bazremove(pattern)Outputs the string with all instances of the pattern (specified as a Perl regular expression) removed. # foobarbazmatch(pattern, global)Performs a regular expression match on the string using the pattern passed as an argument. If the pattern matches the string then the method returns a reference to a list of any strings captured within parenthesis in the pattern. , # Wall, LarryIf the pattern does not match then the method returns false, rather than returning an empty list which Perl and the Template Toolkit both consider to be a true value. This allows you to write expression like this. pattern matches: pattern does not match Any regex modifiers, like /s, should be added in the regex using the (?s) syntax. For example, to modify the regex to disregard whitespace (the /x switch), use: (w+) '; matches = name.match(re); %]To perform a global search to match the pattern as many times as it appears in the source string, provide a true value for the 'global' argument following the pattern. search(pattern)Performs a similar function to 'match' but simply returns true if the string matches the regular expression pattern passed as an argument. # barThis virtual method is now deprecated in favour of 'match'. Move along now, there's nothing more to see here.split(pattern)Calls Perl's split() function to split a string into a list of strings. chunk(size)Splits the value into a list of chunks of a certain size. Output: 1234 5678 2468 3579If the size is specified as a negative number then the text will be chunked from right-to-left. This gives the correct grouping for numbers, for example. Output: 1,234,567substr(offset, length, replacement)Returns a substring starting at 'offset', for 'length' characters. # barIf 'length' is not specified then it returns everything from the 'offset' to the end of the string. # wiz waz wozIf both 'length' and 'replacement' are specified, then the method replaces everything from 'offset' for 'length' characters with $replacement. The substring removed from the string is then returned. # foo bar baz # FOO wiz waz wozlistReturn the value as a single element list. This can be useful if you have a variable which may contain a single item or a list and you want to treat them equally. The 'list' method can be called against a list reference and will simply return the original reference, effectively a no-op. # thing can be a scalar or a listhashReturn the value as a hash reference containing a single entry with the key 'value' indicating the original scalar value. As with the 'list' virtual method, this is generally used to help massage data into different formats.sizeAlways returns 1 for scalar values. This method is provided for consistency with the hash and list size methods.Requirements:· Perl


Template::Manual::VMethods Related Software