GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TIE::FUNCTION (3)

.ds Aq ’

NAME

Tie::Function - wrap functions in tied hash sugar

CONTENTS

SYNOPSIS AND EXAMPLE



  use Tie::Function 0.01;
  tie my %a, Tie::Function => sub{join _x$_[0],qw/( | )/};
  print "small: $a{1}\nmedium: $a{2}\nwide: $a{3}\n";
  # we split on $; to recover multiple arguments
  tie my %times, Tie::Function => sub{
        $_[0] * $_[1]
  };
  print "3 times 5 is $times{3,5}\n"



DESCRIPTION

Tie::Function simplifies wrapping functions in tied hash syntax so they can be interpolated in double-quoted literals without messy intermediate variables.

Here’s how I use it the most:



   use HTML::Entities;
   use Tie::Function;
   tie my %Entitize => Tie::Function => \&encode_entities;
   ...
   print <<EOF;
   <em>$Entitize{$somethingaboutsomething}</em><br>
   <textarea name="something"
   cols="60" rows="10">$Entitize{$something}</textarea>
   EOF
   ...



EXPORT

nothing

HISTORY

    0.01

initial version

    0.02

relaxed stricture, turned off warnings to silence split on unitialized value warning

AUTHOR

Copyright (C) 2004,2005 david nicol davidnico@cpan.org released under your choice of the GNU Public or Artistic licenses

SEE ALSO

perltie

Tie::OneOff

Interpolation

Tie::Filter

overload

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 FUNCTION (3) 2005-05-13

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.