NAME

Locale::Maketext::TieHash::nbsp - Tying subroutine to a hash

SYNOPSIS

use strict;
use Locale::Maketext::TieHash::nbsp;
tie my %nbsp, 'Locale::Maketext::TieHash::nbsp';
# print: "15 pieces";
print $nbsp{15 pieces};
# If you want to test your Script, store you yours own test subroutine.
# Substitute whitespace to a string which you see in the Browser.
$nbsp{sub} = sub {
  (local $_ = $_[1]) =~ s/ /<span style="color:red">§</span>/g;
};

DESCRIPTION

Subroutines don't have interpreted into strings. The module ties a subroutine to a hash. The Subroutine is executed at fetch hash. At long last this is the same, only the notation is shorter.

Sometimes the subroutine "sub" expects more than 1 parameter. Then submit a reference on an array as hash key.

METHODS

TIEHASH

use Locale::Maketext::TieHash::nbsp;
tie my %nbsp, 'Locale::Maketext::TieHash::nbsp';

"TIEHASH" ties your hash and set options defaults.

STORE

"STORE" stores your own subroutine.

$nbsp{sub} = sub {   # this sub is the default
  (local $_ = $_[0]) =~ s/ /&nbsp;/g;
  $_;
};

The method calls croak, if the key of your hash is undef or your key isn't correct and if the value, you set to key "sub", is not a reference of "CODE".

FETCH

Give your string as key of your hash. "FETCH" will substitute the whitespace in "&nbsp;" and give it back as value.

# Substitute
print $nbsp{$string};

SEE ALSO

Tie::Hash

Locale::Maketext

Locale::Maketext::TieHash::L10N

Locale::Maketext::TieHash::quant

AUTHOR

Steffen Winkler, <cpan@steffen-winkler.de>

COPYRIGHT AND LICENSE

Copyright (C) 2004, 2005 by Steffen Winkler

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.1 or, at your option, any later version of Perl 5 you may have available.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 57:

Non-ASCII character seen before =encoding in 'style="color:red">§</span>/g;'. Assuming CP1252