Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 956 Categories, Downloaded 50.230.690 Times

Sub::PatMat 0.01

  Date Added: January 18, 2010  |  Visits: 824

Sub::PatMat

Report Broken Link
Printer Friendly Version


Product Homepage
Download (92 downloads)



Sub::PatMat can call a version of subroutine depending on its arguments. SYNOPSIS use Sub::PatMat; # basics: sub fact : when($_[0] <= 1) { 1 } sub fact { my ($n) = @_; $n*fact($n-1) } print fact(6); # referring to things other than @_: sub mysort : when($a < $b) { -1 } sub mysort : when($a == $b) { 0 } sub mysort : when($a > $b) { 1 } print join ", ", sort mysort (3,1,2); # intuiting parameter names: sub dispatch : when($ev eq "help") { my ($ev) = @_; print "helpn" } sub dispatch : when($ev eq "blah") { my ($ev) = @_; print "blahn" } dispatch("help"); dispatch("blah"); # no fallback, this will die: dispatch("hest"); # dies with "Bad match" # silly sub do_something : when(full_moon()) { do_one_thing() } sub do_something { do_something_else() } The Sub::PatMat module provides the programmer with the ability to define a subroutine multiple times and to specify what version of the subroutine should be called, depending on the parameters passed to it (or any other condition). This is somewhat similar to argument pattern matching facility provided by many programming languages. To use argument pattern matching on a sub, the programmer has to specify the when attribute. The parameter to the attribute must be a single Perl expression. When the sub is called, those expressions are evaluated consequitively until one of them evaluates to a true value. When this happens, the corresponding version of a sub is called. If none of the expressions evaluates to a true value, a Bad Match exception is thrown. It is possible to specify a fall-back version of the function by doing one of the following: specifying when without an expression specifying when with an empty expression not specifying the when attribute at all Please note that it does not make sense to specify any non-fall-back version of the sub after the fall-back version, since such will never be called. There is an additional limitation for the last form of the fall-back version (the one without the when attribute at all), namely, it must be the last version of the sub defined. It is possible to specify named sub parameters in the when-expression. This facility is highly experimental and is currently limited to scalar parameters only. The named sub parameters are extracted from expressions of the form my (parameter list) = @_; anywhere in the body of the sub. Limitations:.

Requirements: No special requirements
Platforms: Linux
Keyword: Attribute Depending Depending On Dispatch Libraries Patmat Programming Specify Sub Subpatmat Subroutine
Users rating: 0/10

License: Freeware Size: 14.34 KB
USER REVIEWS
More Reviews or Write Review


SUB::PATMAT RELATED
Development Tools  -  Economic dispatch by quadratic programming 1.0
This code solves the economic dispatch by quadratic programming.Monotonic quadratic Fuel cost equations with Bmn coefficients is considered this model.
30.72 KB  
Libraries  -  Hash::Diff::Dispatch 0.01
Hash::Diff::Dispatch allows to execute code depending on difference between hashes. SYNOPSIS my $hash_watcher = Hash::Diff::Dispatch->new( {}, # Sets the starting hash # The events will be called using the order returned # by calling keys...
3.07 KB  
Audio Tools  -  oggment 0.0.2
oggment is a mixing/streaming environment able to mix an unlimited (depending on the CPU) number of vorbis encoded audio files. These files could came from from the hardisk with a line/mic input from the soundcard and stream to an icecast2.0...
153.6 KB  
Audio Tools  -  Tam Jukebox Snapshot-2004-12-07
A jukebox that selects songs with relative frequency depending on how much you think they suck. Tam (Track Attribute Manager) jukebox is a system that randomly picks songs to play, and considers every track you have to be in every...
204.8 KB  
3D Graphic Tools  -  Photozeec 0.1.4
Photozeec is a software which lets you to modify digital photos (add date, add borders) depending on models. Principle : Choose a group of photos, set a title to this group, choose a model (modification template) and run the image conversion...
11.26 KB  
Modules  -  Nav bar with on/off tabs 1.0
It has on/off tabs which change colour depending on whether you are on that page or not.It can be used for the home page, category pages and also info pages or special pages such as special offers or the advanced search page. It can also be used...
 
Networking  -  Daily iframe content II Script 1.1
This script loads a different page into an iframe daily, depending on the day of the month (1-31).You can use it to serve up daily, changing content, such as a "tip of the day." The script offers optional code to auto resize iframe based on height...
102.4 KB  
Development Tools  -  ODE Phase Plane 1.0
The script shows two plots; the time response and the phase plane for different initial conditions depending on the coordinates of the mouse pointer.
102.4 KB  
Development Tools  -  updated 3 years ago Result-Adaptive PID-Control improves Laserscanner Positioning 1.0
The proportional, integral and differential terms of PID control are modified by simple nonlinear terms, depending on the error.That makes the control faster, more precise and more robust.This was tested and proven at the control lab of the Munich...
542.72 KB  
Development Tools  -  reverse.mdl 1.0
Accepts an input and sends it to only one of the two outputs, depending on the value of a second "control" input.
10 KB  
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB  
Libraries  -  wolfSSL 4.0.0
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
3.88 MB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB