Petal::Hash::Test(3pm) User Contributed Perl Documentation Petal::Hash::Test(3pm)NAME
Petal::Hash::Test - Test and Tutorial Petal modifier
SUMMARY
Petal modifiers are snippets of code which are used to extend the expression engine capabilities. This test shows how to write your own
modifiers.
API
The modifier API is very, very simple. It consists of two elements:
The package name
Your modifier should be called Petal::Hash::<SomeThing>, where <SomeThing> is the name that you want to give to your modifier.
For example, this modifier is called Petal::Hash::Test. Petal will automatically pick it the module up and assign it the 'test:' prefix.
package Petal::Hash::Test;
use warnings;
use strict;
The method $class->process ($hash, $argument);
This class method will define the modifier in itself.
* $class is the package name of your modifier (which might come in handy if you're subclassing a modifier),
* $hash is the execution context, i.e. the objects and data which will 'fill' your template,
* $argument is whatever was after your modifier's prefix. For example, for the expression 'test:foo bar', $argument would be 'foo bar'.
In this test / tutorial we're going to write a modifier which uppercases a Petal expression.
sub process
{
my $class = shift;
my $hash = shift;
my $argument = shift;
return uc ($hash->get ($argument));
}
1;
__END__
And that's it! Simple!
AUTHOR
Jean-Michel Hiver
This module is redistributed under the same license as Perl itself.
SEE ALSO
The template hash module:
Petal::Hash
perl v5.12.4 2011-08-25 Petal::Hash::Test(3pm)
Check Out this Related Man Page
Hash(3pm) User Contributed Perl Documentation Hash(3pm)NAME
Test::Data::Hash -- test functions for hash variables
SYNOPSIS
use Test::Data qw(Hash);
DESCRIPTION
This modules provides a collection of test utilities for hash variables. Load the module through Test::Data.
Functions
exists_ok( KEY, HASH [, NAME] )
Ok if the value for KEY in HASH exists. The function does not create KEY in HASH.
not_exists_ok( KEY, HASH [, NAME] )
Ok if the value for KEY in HASH does not exist. The function does not create KEY in HASH.
hash_value_defined_ok( KEY, HASH [, NAME] )
Ok if the value for KEY in HASH is defined. The function does not create KEY in HASH.
hash_value_undef_ok( KEY, HASH [, NAME] )
Ok if the value for KEY in HASH is undefined. The function does not create KEY in HASH.
hash_value_true_ok( KEY, HASH [, NAME] )
Ok if the value for KEY in HASH is true. The function does not create KEY in HASH.
hash_value_false_ok( KEY, HASH [, NAME] )
Ok if the value for KEY in HASH is false. The function does not create KEY in HASH.
SEE ALSO
Test::Data, Test::Data::Array, Test::Data::Function, Test::Data::Scalar, Test::Builder
SOURCE AVAILABILITY
This source is in Github:
http://github.com/briandfoy/test-data/tree/master
AUTHOR
brian d foy, "<bdfoy@cpan.org>"
COPYRIGHT AND LICENSE
Copyright (c) 2002-2009 brian d foy. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2009-02-12 Hash(3pm)
Assuming the following code
sub foo {
dosomething {...}
else { foo }
is the number of times foo has been called kept track of internally and how could I access that count? (1 Reply)
Hi All,
I'm trying to test a Hash variable but it's not working. Here is my code - can anyone tell me if the test is valid?
for (keys %enabled_yn) {
if ($enabled_yn{$1} =~ m/\s+Y/) {
$html =~ s/%(\w+)%/\<b\>\<font color\=orange\>$enabled_yn{$1}\<\/font\>\<\/b\>/g;
}... (1 Reply)
Hi All,
i was browsing thru' the opensource glib(deflate/inflate) algorithms..
which i am supposed to implement. I came across Dictionary usage (Hash tables), LZ77 algorithm and Huffman coding in that.. i couldn't follow on the Hash table implementation in that.
Anybody there to give some... (5 Replies)
HI
I have a hash like this
$hashname->{$filesystem}->{'fsname'}=$filesystem;
How to get the values from this multilevel hash.
Thanks in advance... :) (1 Reply)
I am attempting to write a script that reads each line of a file into a separate array and does some work on it then puts it all back together and I think I need to use the 'shift()' command to read each line into its own array, but I need help nesting it into a while loop (while not eof)
So... (10 Replies)
Hi,
I have created a relocatable AIX package named Test.
The USIL is /abc
bash-2.05b# lsusil
INSTALL PATH = /abc
COMMENTS = None
Generally if a package gets installed in "/opt/Test" and i want to relocate it to "/abc" it gets installed under "/abc/Test". This happens the way in Solaris,... (2 Replies)
Hi i am reading one file and creating Hash from the contents of it my issue is there are 3 different files in 3 different locations having same structure so for parsing these files i have one subroutine which returns hash after reading all the 3 files i need to create consolidated hash from three... (2 Replies)
I have created my own hash table class, but am looking to speed it up. My current hash function is:
int HashTable::hashFunc(const string &key) const
{
int tableSize = theLists.size();
int hashVal = 0;
for(int i = 0; i<key.length(); i++)
hashVal =... (7 Replies)
Hi Everyone,
Can anyone help me how do i call hash variable in to sql query in perl. Please see the script below
i have defined two Hash %lc and %tab as below
$lc{'REFF'}='V_RES_CLASS';
$lc{'CALE'}='V_CAP_CLASS';
$lc{'XRPD'}='V_XFMR_CLASS';
$tab{'V_RES_CLASS'}='V_MFR_SERS';... (6 Replies)
Hello everyone!
I'm writing a C++ program and I use a hash table which contains strings.
Its the first time I have to deal with strings since the only thing I have done so far is for integers and is the following:
int hashFunction(int key){
return key%sizeOfHashTable;
}
but how... (2 Replies)
Hi all, i am using the following code to that use curl to that outputs a json, i am stuck it into a hash but i canot figure out how to get just the value i need ( hostname)
here is my code
use warnings;
use strict;
use Data::Dumper qw(Dumper);
##use JSON;
use JSON::XS;
my $curl=... (2 Replies)
Hi folks,
If a declare a direct hash , then the hash element works fine.
my %test = ("test",1);
print %test;
print "\n";
Here in the above, the name of the hash is predeclared...
Suppose now I need to create the hash elements dynamically in the for loop.
$test="hash";
my... (1 Reply)
I was looking at this script and was wondering if anyone can explain what this script does and how does it work. Thank you for any help.
State* lookup(char* prefix, int create)
{
int i, h;
State *sp = NULL ;
h = hash(prefix);
for (sp = statetab; sp != NULL; sp... (14 Replies)