scalar variables
Sponsored Links
Sponsored Links
Secleted [ 0 ] software to compare
Results 1 - 15 of about 1622
MySQL Global User Variables UDF 1.0
MySQL Global User Variables UDF is a MySQL extension to store persistent variables. more>>
MySQL Global User Variables UDF is a MySQL extension to store persistent variables.
This shared library adds simple user functions to MySQL in order to keep persistent shared variables in memory. These variables and their values are available to all clients. Any data can be stored into these persistent variables, including BLOBs. Since updates are atomic and way faster than MEMORY tables, this is an easy and efficient way to handle counters and sequences.
Usage:
Storing a value
An unlimited number of user variables can be created, as long as memory is available.
The GLOBAL_STORE(, ) stores a new shared global variable.
Examples:
mysql> DO GLOBAL_STORE("online_users", 42);
mysql> DO GLOBAL_STORE("secret_key", "pajfUyfnd");
The GLOBAL_STORE() function always returns 1 unless an error occurred.
Fetching a value
Reading the value of a variable is the job of the GLOBAL_GET() function.
The value is returned, or NULL is the variable is undefined.
Example:
mysql> SELECT GLOBAL_GET("online_users;);
42
mysql> SELECT id FROM pxs WHERE secret_key = GLOBAL_GET("secret_key");
1
Atomic increments
A single function call can read the previous value, add an integer (that can be negative), and store the new value into the variable.
The function is GLOBAL_ADD(, ) and the return value is the new value of the variable.
Updates are always atomic, if the old value is 18 and you add 1, you will always get back 19.
Example:
mysql> DO GLOBAL_ADD("online_users", 1);
mysql> SELECT GLOBAL_ADD("online_users", -4);
39
If the value of a variable was a string, the new value is the increment:
mysql> SELECT GLOBAL_ADD("secret_key", 12);
12
Adding a value to an undefined variable returns NULL.
A handy variant is GLOBAL_ADDP(, ). GLOBAL_ADDP() is similar to GLOBAL_ADD() but returns the PREVIOUS value of the variable instead of the new one.
Example:
mysql> DO GLOBAL_SET("xxx", 10);
mysql> SELECT GLOBAL_ADDP("xxx", 1);
10
mysql> SELECT GLOBAL_ADDP("xxx", 1);
11
Installation:
On most systems, compiling and installing the library should be as simple as typing (as root):
make install
The shared library is installed as /usr/local/lib/udf_global_user_variables.so
If the base directory of your MySQL installation is not in /usr/local, just type:
make
and then copy udf_global_user_variables.so to the right location for UDFs on your system (maybe /usr/lib/).
The name of a variable is limited to 256 bytes. If that limit is too low for your specific application, just edit the MAX_NAME_LENGTH variable on top of the .c file and reinstall. Variable names can contain binary characters.
Values are limited to 65536 bytes. If that limit is too low for you, edit the MAX_VALUE_LENGTH variable and reinstall.
<<lessThis shared library adds simple user functions to MySQL in order to keep persistent shared variables in memory. These variables and their values are available to all clients. Any data can be stored into these persistent variables, including BLOBs. Since updates are atomic and way faster than MEMORY tables, this is an easy and efficient way to handle counters and sequences.
Usage:
Storing a value
An unlimited number of user variables can be created, as long as memory is available.
The GLOBAL_STORE(, ) stores a new shared global variable.
Examples:
mysql> DO GLOBAL_STORE("online_users", 42);
mysql> DO GLOBAL_STORE("secret_key", "pajfUyfnd");
The GLOBAL_STORE() function always returns 1 unless an error occurred.
Fetching a value
Reading the value of a variable is the job of the GLOBAL_GET() function.
The value is returned, or NULL is the variable is undefined.
Example:
mysql> SELECT GLOBAL_GET("online_users;);
42
mysql> SELECT id FROM pxs WHERE secret_key = GLOBAL_GET("secret_key");
1
Atomic increments
A single function call can read the previous value, add an integer (that can be negative), and store the new value into the variable.
The function is GLOBAL_ADD(, ) and the return value is the new value of the variable.
Updates are always atomic, if the old value is 18 and you add 1, you will always get back 19.
Example:
mysql> DO GLOBAL_ADD("online_users", 1);
mysql> SELECT GLOBAL_ADD("online_users", -4);
39
If the value of a variable was a string, the new value is the increment:
mysql> SELECT GLOBAL_ADD("secret_key", 12);
12
Adding a value to an undefined variable returns NULL.
A handy variant is GLOBAL_ADDP(, ). GLOBAL_ADDP() is similar to GLOBAL_ADD() but returns the PREVIOUS value of the variable instead of the new one.
Example:
mysql> DO GLOBAL_SET("xxx", 10);
mysql> SELECT GLOBAL_ADDP("xxx", 1);
10
mysql> SELECT GLOBAL_ADDP("xxx", 1);
11
Installation:
On most systems, compiling and installing the library should be as simple as typing (as root):
make install
The shared library is installed as /usr/local/lib/udf_global_user_variables.so
If the base directory of your MySQL installation is not in /usr/local, just type:
make
and then copy udf_global_user_variables.so to the right location for UDFs on your system (maybe /usr/lib/).
The name of a variable is limited to 256 bytes. If that limit is too low for your specific application, just edit the MAX_NAME_LENGTH variable on top of the .c file and reinstall. Variable names can contain binary characters.
Values are limited to 65536 bytes. If that limit is too low for you, edit the MAX_VALUE_LENGTH variable and reinstall.
Download (0.004MB)
Added: 2007-03-19 License: GPL (GNU General Public License) Price:
951 downloads
Scalar::Properties 0.12
Scalar::Properties is a Perl module package that contains run-time properties on scalar variables. more>>
Scalar::Properties is a Perl module package that contains run-time properties on scalar variables.
SYNOPSIS
use Scalar::Properties;
my $val = 0->true;
if ($val && $val == 0) {
print "yup, its true alright...n";
}
my @text = (
hello world->greeting(1),
forget it,
hi there->greeting(1),
);
print grep { $_->is_greeting } @text;
my $l = hello world->length;
Scalar::Properties attempts to make Perl more object-oriented by taking an idea from Ruby: Everything you manipulate is an object, and the results of those manipulations are objects themselves.
hello world->length
(-1234)->abs
"oh my god, its full of properties"->index(g)
The first example asks a string to calculate its length. The second example asks a number to calculate its absolute value. And the third example asks a string to find the index of the letter g.
Using this module you can have run-time properties on initialized scalar variables and literal values. The word properties is used in the Perl 6 sense: out-of-band data, little sticky notes that are attached to the value. While attributes (as in Perl 5s attribute pragma, and see the Attribute::* family of modules) are handled at compile-time, properties are handled at run-time.
Internally properties are implemented by making their values into objects with overloaded operators. The actual properties are then simply hash entries.
Most properties are simply notes you attach to the value, but some may have deeper meaning. For example, the true and false properties plays a role in boolean context, as the first example of the Synopsis shows.
Properties can also be propagated between values. For details, see the EXPORTS section below. Here is an example why this might be desirable:
pass_on(approximate);
my $pi = 3->approximate(1);
my $circ = 2 * $rad * $pi;
# now $circ->approximate indicates that this value was derived
# from approximate values
Please dont use properties whose name start with an underscore; these are reserved for internal use.
You can set and query properties like this:
$var->myprop(1)
sets the property to a true value.
$var->myprop(0)
sets the property to a false value. Note that this doesnt delete the property (to do so, use the del_props method described below).
$var->is_myprop, $var->has_myprop
returns a true value if the property is set (i.e., defined and has a true value). The two alternate interfaces are provided to make querying attributes sound more natural. For example:
$foo->is_approximate;
$bar->has_history;
<<lessSYNOPSIS
use Scalar::Properties;
my $val = 0->true;
if ($val && $val == 0) {
print "yup, its true alright...n";
}
my @text = (
hello world->greeting(1),
forget it,
hi there->greeting(1),
);
print grep { $_->is_greeting } @text;
my $l = hello world->length;
Scalar::Properties attempts to make Perl more object-oriented by taking an idea from Ruby: Everything you manipulate is an object, and the results of those manipulations are objects themselves.
hello world->length
(-1234)->abs
"oh my god, its full of properties"->index(g)
The first example asks a string to calculate its length. The second example asks a number to calculate its absolute value. And the third example asks a string to find the index of the letter g.
Using this module you can have run-time properties on initialized scalar variables and literal values. The word properties is used in the Perl 6 sense: out-of-band data, little sticky notes that are attached to the value. While attributes (as in Perl 5s attribute pragma, and see the Attribute::* family of modules) are handled at compile-time, properties are handled at run-time.
Internally properties are implemented by making their values into objects with overloaded operators. The actual properties are then simply hash entries.
Most properties are simply notes you attach to the value, but some may have deeper meaning. For example, the true and false properties plays a role in boolean context, as the first example of the Synopsis shows.
Properties can also be propagated between values. For details, see the EXPORTS section below. Here is an example why this might be desirable:
pass_on(approximate);
my $pi = 3->approximate(1);
my $circ = 2 * $rad * $pi;
# now $circ->approximate indicates that this value was derived
# from approximate values
Please dont use properties whose name start with an underscore; these are reserved for internal use.
You can set and query properties like this:
$var->myprop(1)
sets the property to a true value.
$var->myprop(0)
sets the property to a false value. Note that this doesnt delete the property (to do so, use the del_props method described below).
$var->is_myprop, $var->has_myprop
returns a true value if the property is set (i.e., defined and has a true value). The two alternate interfaces are provided to make querying attributes sound more natural. For example:
$foo->is_approximate;
$bar->has_history;
Download (0.010MB)
Added: 2007-05-21 License: Perl Artistic License Price:
886 downloads
Scalar 1.02
Scalar is an addictive cross-platform puzzle game written in C++ using SDL library. more>>
Scalar is an addictive cross-platform puzzle game written in C++ using SDL library.
The goal of the game is to assemble the picture from pieces. Each picture is divided into pieces which are shuffled. You need to get each piece back to its original position. You accomplish that by swapping pieces (exchanging their positions).
You have a limited number of swappings for each picture. The game is over when you complete 3 images, and for each one you get the points. If you have a hard time playing this, you can look at the images directory and see what the final picture looks like.
Feel free to add more pictures to images directory and play with them (images can be in .jpg, .gif, .png, .bmp, any many other formats).
<<lessThe goal of the game is to assemble the picture from pieces. Each picture is divided into pieces which are shuffled. You need to get each piece back to its original position. You accomplish that by swapping pieces (exchanging their positions).
You have a limited number of swappings for each picture. The game is over when you complete 3 images, and for each one you get the points. If you have a hard time playing this, you can look at the images directory and see what the final picture looks like.
Feel free to add more pictures to images directory and play with them (images can be in .jpg, .gif, .png, .bmp, any many other formats).
Download (2.6MB)
Added: 2005-08-11 License: GPL (GNU General Public License) Price:
1534 downloads
Scalar::MultiValue 0.03
Scalar::MultiValue is a Perl module to create a SCALAR with multiple values. more>>
Scalar::MultiValue is a Perl module to create a SCALAR with multiple values.
This module create a SCALAR with multiple values, where this values can be randomic or can change by a defined period.
USAGE:
With a period of 2:
my $s = new Scalar::MultiValue( [qw(a b c d)] , 2 ) ;
for(0..8) {
print "$sn" ;
}
Output:
a
a
b
b
c
c
d
d
With randomic values:
my $s = new Scalar::MultiValue( [qw(a b c d)] , * ) ;
for(0..8) {
print "$sn" ;
}
Output:
c
d
c
b
a
d
c
c
<<lessThis module create a SCALAR with multiple values, where this values can be randomic or can change by a defined period.
USAGE:
With a period of 2:
my $s = new Scalar::MultiValue( [qw(a b c d)] , 2 ) ;
for(0..8) {
print "$sn" ;
}
Output:
a
a
b
b
c
c
d
d
With randomic values:
my $s = new Scalar::MultiValue( [qw(a b c d)] , * ) ;
for(0..8) {
print "$sn" ;
}
Output:
c
d
c
b
a
d
c
c
Download (0.003MB)
Added: 2007-07-06 License: Perl Artistic License Price:
841 downloads
Variable::Alias 0.01
Variable::Alias is a Perl module created to alias any variable to any other variable. more>>
Variable::Alias is a Perl module created to alias any variable to any other variable.
SYNOPSIS
use Variable::Alias alias;
my $src;
my $a;
our $b;
my @c;
our @d;
alias $src => $a;
alias $a => $b;
alias $b => $c[0];
alias @c => @d;
$src=src;
# All the other variables now have the string
# src in the appropriate places.
There are various ways to alias one variable to another in Perl. The most popular is by assigning to typeglobs. This is quite efective, but only works with globals. Another method is to use a module like Lexical::Alias or Devel::LexAlias, but as their names suggest, these only work with lexicals. Theres no way to alias an element of an array or hash.
Variable::Alias changes all that. It uses a tie to provide One True Way to alias a variable.
Interface
Variable::Alias may export any or all of five functions. If youve used Lexical::Alias, the interface is virtually identical.
alias(VAR, VAR)
alias takes two variables of any type (scalar, array or hash) and aliases them. Make sure they have the sigil you want on the front.
This function is only available in Perl 5.8.0 and later, because the prototype tricks it uses were first implemented in that version.
alias_s(SCALAR, SCALAR)
alias_s takes two scalars and aliases them.
alias_a(ARRAY, ARRAY)
alias_a takes two arrays and aliases them. Note that this is actual arrays, not array elements, although you can alias references in elements, like so:
alias_a(@short, @{$some->sequence->{of}->calls->{thats}[2]{long}});
alias_h(HASH, HASH)
alias_h takes two hashes and aliases them.
alias_r(REF, REF)
alias_r takes two references and aliases them. The referents must be of the same type.
<<lessSYNOPSIS
use Variable::Alias alias;
my $src;
my $a;
our $b;
my @c;
our @d;
alias $src => $a;
alias $a => $b;
alias $b => $c[0];
alias @c => @d;
$src=src;
# All the other variables now have the string
# src in the appropriate places.
There are various ways to alias one variable to another in Perl. The most popular is by assigning to typeglobs. This is quite efective, but only works with globals. Another method is to use a module like Lexical::Alias or Devel::LexAlias, but as their names suggest, these only work with lexicals. Theres no way to alias an element of an array or hash.
Variable::Alias changes all that. It uses a tie to provide One True Way to alias a variable.
Interface
Variable::Alias may export any or all of five functions. If youve used Lexical::Alias, the interface is virtually identical.
alias(VAR, VAR)
alias takes two variables of any type (scalar, array or hash) and aliases them. Make sure they have the sigil you want on the front.
This function is only available in Perl 5.8.0 and later, because the prototype tricks it uses were first implemented in that version.
alias_s(SCALAR, SCALAR)
alias_s takes two scalars and aliases them.
alias_a(ARRAY, ARRAY)
alias_a takes two arrays and aliases them. Note that this is actual arrays, not array elements, although you can alias references in elements, like so:
alias_a(@short, @{$some->sequence->{of}->calls->{thats}[2]{long}});
alias_h(HASH, HASH)
alias_h takes two hashes and aliases them.
alias_r(REF, REF)
alias_r takes two references and aliases them. The referents must be of the same type.
Download (0.003MB)
Added: 2007-05-04 License: Perl Artistic License Price:
903 downloads
Scalar::Util 1.19
Scalar::Util is a selection of general-utility scalar subroutines. more>>
Scalar::Util is a selection of general-utility scalar subroutines.
SYNOPSIS
use Scalar::Util qw(blessed dualvar isweak readonly refaddr reftype tainted
weaken isvstring looks_like_number set_prototype);
Scalar::Util contains a selection of subroutines that people have expressed would be nice to have in the perl core, but the usage would not really be high enough to warrant the use of a keyword, and the size so small such that being individual extensions would be wasteful.
By default Scalar::Util does not export any subroutines. The subroutines defined are
blessed EXPR
If EXPR evaluates to a blessed reference the name of the package that it is blessed into is returned. Otherwise undef is returned.
$scalar = "foo";
$class = blessed $scalar; # undef
$ref = [];
$class = blessed $ref; # undef
$obj = bless [], "Foo";
$class = blessed $obj; # "Foo"
dualvar NUM, STRING
Returns a scalar that has the value NUM in a numeric context and the value STRING in a string context.
$foo = dualvar 10, "Hello";
$num = $foo + 2; # 12
$str = $foo . " world"; # Hello world
isvstring EXPR
If EXPR is a scalar which was coded as a vstring the result is true.
$vs = v49.46.48;
$fmt = isvstring($vs) ? "%vd" : "%s"; #true
printf($fmt,$vs);
isweak EXPR
If EXPR is a scalar which is a weak reference the result is true.
$ref = $foo;
$weak = isweak($ref); # false
weaken($ref);
$weak = isweak($ref); # true
NOTE: Copying a weak reference creates a normal, strong, reference.
$copy = $ref;
$weak = isweak($ref); # false
looks_like_number EXPR
Returns true if perl thinks EXPR is a number. See "looks_like_number" in perlapi.
openhandle FH
Returns FH if FH may be used as a filehandle and is open, or FH is a tied handle. Otherwise undef is returned.
$fh = openhandle(*STDIN); # *STDIN
$fh = openhandle(*STDIN); # *STDIN
$fh = openhandle(*NOTOPEN); # undef
$fh = openhandle("scalar"); # undef
readonly SCALAR
Returns true if SCALAR is readonly.
sub foo { readonly($_[0]) }
$readonly = foo($bar); # false
$readonly = foo(0); # true
refaddr EXPR
If EXPR evaluates to a reference the internal memory address of the referenced value is returned. Otherwise undef is returned.
$addr = refaddr "string"; # undef
$addr = refaddr $var; # eg 12345678
$addr = refaddr []; # eg 23456784
$obj = bless {}, "Foo";
$addr = refaddr $obj; # eg 88123488
reftype EXPR
If EXPR evaluates to a reference the type of the variable referenced is returned. Otherwise undef is returned.
$type = reftype "string"; # undef
$type = reftype $var; # SCALAR
$type = reftype []; # ARRAY
$obj = bless {}, "Foo";
$type = reftype $obj; # HASH
set_prototype CODEREF, PROTOTYPE
Sets the prototype of the given function, or deletes it if PROTOTYPE is undef. Returns the CODEREF.
set_prototype &foo, $$;
tainted EXPR
Return true if the result of EXPR is tainted
$taint = tainted("constant"); # false
$taint = tainted($ENV{PWD}); # true if running under -T
weaken REF
REF will be turned into a weak reference. This means that it will not hold a reference count on the object it references. Also when the reference count on that object reaches zero, REF will be set to undef.
This is useful for keeping copies of references , but you dont want to prevent the object being DESTROY-ed at its usual time.
{
my $var;
$ref = $var;
weaken($ref); # Make $ref a weak reference
}
# $ref is now undef
Note that if you take a copy of a scalar with a weakened reference, the copy will be a strong reference.
my $var;
my $foo = $var;
weaken($foo); # Make $foo a weak reference
my $bar = $foo; # $bar is now a strong reference
This may be less obvious in other situations, such as grep(), for instance when grepping through a list of weakened references to objects that may have been destroyed already:
@object = grep { defined } @object;
This will indeed remove all references to destroyed objects, but the remaining references to objects will be strong, causing the remaining objects to never be destroyed because there is now always a strong reference to them in the @object array.
<<lessSYNOPSIS
use Scalar::Util qw(blessed dualvar isweak readonly refaddr reftype tainted
weaken isvstring looks_like_number set_prototype);
Scalar::Util contains a selection of subroutines that people have expressed would be nice to have in the perl core, but the usage would not really be high enough to warrant the use of a keyword, and the size so small such that being individual extensions would be wasteful.
By default Scalar::Util does not export any subroutines. The subroutines defined are
blessed EXPR
If EXPR evaluates to a blessed reference the name of the package that it is blessed into is returned. Otherwise undef is returned.
$scalar = "foo";
$class = blessed $scalar; # undef
$ref = [];
$class = blessed $ref; # undef
$obj = bless [], "Foo";
$class = blessed $obj; # "Foo"
dualvar NUM, STRING
Returns a scalar that has the value NUM in a numeric context and the value STRING in a string context.
$foo = dualvar 10, "Hello";
$num = $foo + 2; # 12
$str = $foo . " world"; # Hello world
isvstring EXPR
If EXPR is a scalar which was coded as a vstring the result is true.
$vs = v49.46.48;
$fmt = isvstring($vs) ? "%vd" : "%s"; #true
printf($fmt,$vs);
isweak EXPR
If EXPR is a scalar which is a weak reference the result is true.
$ref = $foo;
$weak = isweak($ref); # false
weaken($ref);
$weak = isweak($ref); # true
NOTE: Copying a weak reference creates a normal, strong, reference.
$copy = $ref;
$weak = isweak($ref); # false
looks_like_number EXPR
Returns true if perl thinks EXPR is a number. See "looks_like_number" in perlapi.
openhandle FH
Returns FH if FH may be used as a filehandle and is open, or FH is a tied handle. Otherwise undef is returned.
$fh = openhandle(*STDIN); # *STDIN
$fh = openhandle(*STDIN); # *STDIN
$fh = openhandle(*NOTOPEN); # undef
$fh = openhandle("scalar"); # undef
readonly SCALAR
Returns true if SCALAR is readonly.
sub foo { readonly($_[0]) }
$readonly = foo($bar); # false
$readonly = foo(0); # true
refaddr EXPR
If EXPR evaluates to a reference the internal memory address of the referenced value is returned. Otherwise undef is returned.
$addr = refaddr "string"; # undef
$addr = refaddr $var; # eg 12345678
$addr = refaddr []; # eg 23456784
$obj = bless {}, "Foo";
$addr = refaddr $obj; # eg 88123488
reftype EXPR
If EXPR evaluates to a reference the type of the variable referenced is returned. Otherwise undef is returned.
$type = reftype "string"; # undef
$type = reftype $var; # SCALAR
$type = reftype []; # ARRAY
$obj = bless {}, "Foo";
$type = reftype $obj; # HASH
set_prototype CODEREF, PROTOTYPE
Sets the prototype of the given function, or deletes it if PROTOTYPE is undef. Returns the CODEREF.
set_prototype &foo, $$;
tainted EXPR
Return true if the result of EXPR is tainted
$taint = tainted("constant"); # false
$taint = tainted($ENV{PWD}); # true if running under -T
weaken REF
REF will be turned into a weak reference. This means that it will not hold a reference count on the object it references. Also when the reference count on that object reaches zero, REF will be set to undef.
This is useful for keeping copies of references , but you dont want to prevent the object being DESTROY-ed at its usual time.
{
my $var;
$ref = $var;
weaken($ref); # Make $ref a weak reference
}
# $ref is now undef
Note that if you take a copy of a scalar with a weakened reference, the copy will be a strong reference.
my $var;
my $foo = $var;
weaken($foo); # Make $foo a weak reference
my $bar = $foo; # $bar is now a strong reference
This may be less obvious in other situations, such as grep(), for instance when grepping through a list of weakened references to objects that may have been destroyed already:
@object = grep { defined } @object;
This will indeed remove all references to destroyed objects, but the remaining references to objects will be strong, causing the remaining objects to never be destroyed because there is now always a strong reference to them in the @object array.
Download (0.042MB)
Added: 2007-05-21 License: Perl Artistic License Price:
888 downloads
Scalar::Number 0.001
Scalar::Number is a Perl module with numeric aspects of scalars. more>>
Scalar::Number is a Perl module with numeric aspects of scalars.
SYNOPSIS
use Scalar::Number qw(scalar_num_part);
$num = scalar_num_part($scalar);
use Scalar::Number qw(sclnum_is_natint sclnum_is_float);
if(sclnum_is_natint($value)) { ...
if(sclnum_is_float($value)) { ...
use Scalar::Number qw(sclnum_val_cmp sclnum_id_cmp);
@sorted_nums = sort { sclnum_val_cmp($a, $b) } @floats;
@sorted_nums = sort { sclnum_id_cmp($a, $b) } @floats;
This module is about the numeric part of plain (string) Perl scalars. A scalar has a numeric value, which may be expressed in either the native integer type or the native floating point type. Many values are expressible both ways, in which case the exact representation is insignificant. To fully understand Perl arithmetic it is necessary to know about both of these representations, and the differing behaviours of numbers according to which way they are expressible.
This module provides functions to extract the numeric part of a scalar, classify a number by expressibility, and compare numbers across representations.
<<lessSYNOPSIS
use Scalar::Number qw(scalar_num_part);
$num = scalar_num_part($scalar);
use Scalar::Number qw(sclnum_is_natint sclnum_is_float);
if(sclnum_is_natint($value)) { ...
if(sclnum_is_float($value)) { ...
use Scalar::Number qw(sclnum_val_cmp sclnum_id_cmp);
@sorted_nums = sort { sclnum_val_cmp($a, $b) } @floats;
@sorted_nums = sort { sclnum_id_cmp($a, $b) } @floats;
This module is about the numeric part of plain (string) Perl scalars. A scalar has a numeric value, which may be expressed in either the native integer type or the native floating point type. Many values are expressible both ways, in which case the exact representation is insignificant. To fully understand Perl arithmetic it is necessary to know about both of these representations, and the differing behaviours of numbers according to which way they are expressible.
This module provides functions to extract the numeric part of a scalar, classify a number by expressibility, and compare numbers across representations.
Download (0.009MB)
Added: 2007-05-21 License: Perl Artistic License Price:
886 downloads
Language::Basic::Variable 1.44
Language::Basic::Variable is a Perl module to handle parsing and implementing BASIC variables. more>>
Language::Basic::Variable is a Perl module to handle parsing and implementing BASIC variables.
SYNOPSIS
See Language::Basic for the overview of how the Language::Basic module works. This pod page is more technical.
There are two sorts of variables: Arrays and Scalars. Each of those classes has a subclass for Numeric or String variables.
An Array needs to have full LBV::Scalar objects in it, rather than just having an array of values. The reason is that, for example, you might use ARR(3) as the variable in a FOR loop. Also, the "set" and "value" methods apply to a LBV::Scalar (since you cant set an array to a value (in BASIC) so in order to be handle A(3)=3, A(3) needs to be an LBV::Scalar.
The lookup method looks up a variable in the Array or Scalar lookup table (depending on whether there were parentheses after the variable name). BASIC allows undeclared variables, so if the variable name hasnt been seen before, a new variable is created.
Language::Basic::Variable::Scalar class
This class handles a variable or one cell in an array.
Methods include "value", which gets the variables value, and "set", which sets it.
Language::Basic::Variable::Array class
This class handles a BASIC array. Each cell in the array is a LBV::Scalar object.
Methods include "dimension", which dimensions the array to a given size (or a default size) and get_cell, which returns the LBV::Scalar object in a given array location.
Note that BASIC arrays start from 0!
<<lessSYNOPSIS
See Language::Basic for the overview of how the Language::Basic module works. This pod page is more technical.
There are two sorts of variables: Arrays and Scalars. Each of those classes has a subclass for Numeric or String variables.
An Array needs to have full LBV::Scalar objects in it, rather than just having an array of values. The reason is that, for example, you might use ARR(3) as the variable in a FOR loop. Also, the "set" and "value" methods apply to a LBV::Scalar (since you cant set an array to a value (in BASIC) so in order to be handle A(3)=3, A(3) needs to be an LBV::Scalar.
The lookup method looks up a variable in the Array or Scalar lookup table (depending on whether there were parentheses after the variable name). BASIC allows undeclared variables, so if the variable name hasnt been seen before, a new variable is created.
Language::Basic::Variable::Scalar class
This class handles a variable or one cell in an array.
Methods include "value", which gets the variables value, and "set", which sets it.
Language::Basic::Variable::Array class
This class handles a BASIC array. Each cell in the array is a LBV::Scalar object.
Methods include "dimension", which dimensions the array to a given size (or a default size) and get_cell, which returns the LBV::Scalar object in a given array location.
Note that BASIC arrays start from 0!
Download (0.051MB)
Added: 2006-09-29 License: Perl Artistic License Price:
1121 downloads
Set::Scalar 1.20
Set::Scalar Perl module contains a basic set of operations. more>>
Set::Scalar Perl module contains a basic set of operations.
SYNOPSIS
use Set::Scalar;
$s = Set::Scalar->new;
$s->insert(a, b);
$s->delete(b);
$t = Set::Scalar->new(x, y, $z);
Creating
$s = Set::Scalar->new;
$s = Set::Scalar->new(@members);
$t = $s->clone;
$t = $s->copy; # clone of clone
Modifying
$s->insert(@members);
$s->delete(@members);
$s->invert(@members); # insert if hasnt, delete if has
$s->clear; # removes all the elements
Note that clear() only releases the memory used by the set to be reused by Perl; it will not reduce the overall memory use.
<<lessSYNOPSIS
use Set::Scalar;
$s = Set::Scalar->new;
$s->insert(a, b);
$s->delete(b);
$t = Set::Scalar->new(x, y, $z);
Creating
$s = Set::Scalar->new;
$s = Set::Scalar->new(@members);
$t = $s->clone;
$t = $s->copy; # clone of clone
Modifying
$s->insert(@members);
$s->delete(@members);
$s->invert(@members); # insert if hasnt, delete if has
$s->clear; # removes all the elements
Note that clear() only releases the memory used by the set to be reused by Perl; it will not reduce the overall memory use.
Download (0.016MB)
Added: 2007-07-03 License: Perl Artistic License Price:
844 downloads
Scalar::Defer 0.07
Scalar::Defer is a Perl module to calculate values on demand. more>>
Scalar::Defer is a Perl module to calculate values on demand.
SYNOPSIS
use Scalar::Defer; # exports defer and lazy
my ($x, $y);
my $dv = defer { ++$x }; # a deferred value (not memoized)
my $lv = lazy { ++$y }; # a lazy value (memoized)
print "$dv $dv $dv"; # 1 2 3
print "$lv $lv $lv"; # 1 1 1
my $forced = force $dv; # force a normal value out of $dv
print "$forced $forced $forced"; # 4 4 4
This module exports two functions, defer and lazy, for building values that are evaluated on demand. It also exports a force function to force evaluation of a deferred value.
defer {...}
Takes a block or a code reference, and returns a deferred value. Each time that value is demanded, the block is evaluated again to yield a fresh result.
lazy {...}
Like defer, except the value is computed at most once. Subsequent evaluation will simply use the cached result.
force $value
Force evaluation of a deferred value to return a normal value. If $value was already normal value, then force simply returns it.
NOTES
Deferred values are not considered objects (ref on them returns 0), although you can still call methods on them, in which case the invocant is always the forced value.
Unlike the tie-based Data::Lazy, this module operates on values, not variables. Therefore, assigning into $dv and $lv above will simply replace the value, instead of triggering a STORE method call.
Also, thanks to the overload-based implementation, this module is about 2x faster than Data::Lazy.
<<lessSYNOPSIS
use Scalar::Defer; # exports defer and lazy
my ($x, $y);
my $dv = defer { ++$x }; # a deferred value (not memoized)
my $lv = lazy { ++$y }; # a lazy value (memoized)
print "$dv $dv $dv"; # 1 2 3
print "$lv $lv $lv"; # 1 1 1
my $forced = force $dv; # force a normal value out of $dv
print "$forced $forced $forced"; # 4 4 4
This module exports two functions, defer and lazy, for building values that are evaluated on demand. It also exports a force function to force evaluation of a deferred value.
defer {...}
Takes a block or a code reference, and returns a deferred value. Each time that value is demanded, the block is evaluated again to yield a fresh result.
lazy {...}
Like defer, except the value is computed at most once. Subsequent evaluation will simply use the cached result.
force $value
Force evaluation of a deferred value to return a normal value. If $value was already normal value, then force simply returns it.
NOTES
Deferred values are not considered objects (ref on them returns 0), although you can still call methods on them, in which case the invocant is always the forced value.
Unlike the tie-based Data::Lazy, this module operates on values, not variables. Therefore, assigning into $dv and $lv above will simply replace the value, instead of triggering a STORE method call.
Also, thanks to the overload-based implementation, this module is about 2x faster than Data::Lazy.
Download (0.025MB)
Added: 2006-10-18 License: MIT/X Consortium License Price:
1101 downloads
Slay::Makefile 0.01
Slay::Makefile is a wrapper to Slay::Maker that reads the rules from a file. more>>
Slay::Makefile is a wrapper to Slay::Maker that reads the rules from a file.
SYNOPSIS
Slay::Maker is a make engine that uses perl declaration syntax for rules, including regular expressions for targets and anonymous subs for targets, dependencies, and actions. This Slay::Makefile wrapper allows for the rules to be contained within a SlayMakefile file whose syntax is similar to that of a normal Makefile.
FILE SYNTAX
The file syntax is a series of statements where each statement is one of:
< perl-block >
< target(s) > : < dependencies >
< actions >
[-] include < filename >
# Comment
< perl-block > has the syntax:
{
< perl-statement(s) >
}
where < perl-statement(s) > is any series of perl statements.
< target(s >) is either a space-delimited set of targets, each of which is either a literal string or a < perl-block > which returns an array, each of which is either a literal string or a regular expression (Regexp) reference (qr/.../). A literal string can contain a % character to act as a wild-card, just as with GNU make.
However, the Regexp feature is more general, since it can capture more than one substring and use the values $!, $2, ... inside the dependencies. Note that only one target can realistically contain wildcards, whether in a Regexp or using %, since there is only one set of $1, $2, ... variables.
The colon separating a < perl-block > for < target(s) > must be on the same line as the closing brace of the < perl-block >.
< dependencies > is either a space-delimited set of dependency strings or a < perl-block > which returns an array of dependencies (or a combination). The dependency string can contain $1, $2, ..., or %, which is synonymous with $1 and ${TARGET}, which gets the target name. They can also use any scalar global variables previously defined in a < perl-block >. A dependency < perl-block > receives an array @_ with the values ($make, $target, $matches), where $make is a Slay::Maker object, $target is the target name, and $matches is a reference to an array containing the captured values from that targets Regexp (if any).
The colon separating a < perl-block > for must be on the same line as the opening brace of the < perl-block >.
< actions > is a series of zero or more action "lines", where each action is either a string, which will be executed inside a shell, a perl anonymous array, which is executed without a shell (see IPC::Run), or a < perl-block >. For purposes of this discussion, a "line" continues as long as the lines of string action end with "" or as long as a perl anonymous array or < perl-block > do not have their closing punctuation. A string action can use the strings $1, $2, ..., for the matches, $DEP0, $DEP1, ..., for the dependencies, and $TARGET, which represents the target being built. For make enthusiasts, $* can be used for $1. A string action can also use any scalar global variables previously defined in a < perl-block >.
An include line includes the content of a file with < filename > as a SlayMakefile file. If there is no such file, Slay::Makefile will try to build it using rules that have already been presented. If there is no such rule, Slay::Makefile exits with an error unless there was a - before the "include".
The equivalent of makes defines are handled by setting perl global variables. Each main < perl-block > is executed in the order it appears in the file, but any that is part of a dependency or action is evaluated lazily, so that all the global variables will have been set.
Comments begin with a # and extend to the end of line.
Continuation lines can be specified by putting a backslash at the end of the previous line, provided however, that continuation lines are unnecessary (automatic) within a perl block or perl anonymous array.
METHODS
new
Class method. Creates a new Slay::Makefile object.
maker
Method. Returns the Slay::Maker object used by this Slay::Makefile object.
make (@targets)
Method. Calls the Slay::Maker objects make method to build the list of targets. If no targets are given, makes the targets of the first rule with constant targets.
parse ($filename)
Method. Parses file $filename as a SlayMakefile and populates the Slay::Maker object with its rules. Returns a reference to an array of parse errors.
parse_string ($string, [$filename, [$lineno]])
Method. Parses $string as a SlayMakefile. If $filename and/or $lineno arguments are provided, they are used for more detailed error reporting. Returns a reference to an array of parse errors.
<<lessSYNOPSIS
Slay::Maker is a make engine that uses perl declaration syntax for rules, including regular expressions for targets and anonymous subs for targets, dependencies, and actions. This Slay::Makefile wrapper allows for the rules to be contained within a SlayMakefile file whose syntax is similar to that of a normal Makefile.
FILE SYNTAX
The file syntax is a series of statements where each statement is one of:
< perl-block >
< target(s) > : < dependencies >
< actions >
[-] include < filename >
# Comment
< perl-block > has the syntax:
{
< perl-statement(s) >
}
where < perl-statement(s) > is any series of perl statements.
< target(s >) is either a space-delimited set of targets, each of which is either a literal string or a < perl-block > which returns an array, each of which is either a literal string or a regular expression (Regexp) reference (qr/.../). A literal string can contain a % character to act as a wild-card, just as with GNU make.
However, the Regexp feature is more general, since it can capture more than one substring and use the values $!, $2, ... inside the dependencies. Note that only one target can realistically contain wildcards, whether in a Regexp or using %, since there is only one set of $1, $2, ... variables.
The colon separating a < perl-block > for < target(s) > must be on the same line as the closing brace of the < perl-block >.
< dependencies > is either a space-delimited set of dependency strings or a < perl-block > which returns an array of dependencies (or a combination). The dependency string can contain $1, $2, ..., or %, which is synonymous with $1 and ${TARGET}, which gets the target name. They can also use any scalar global variables previously defined in a < perl-block >. A dependency < perl-block > receives an array @_ with the values ($make, $target, $matches), where $make is a Slay::Maker object, $target is the target name, and $matches is a reference to an array containing the captured values from that targets Regexp (if any).
The colon separating a < perl-block > for must be on the same line as the opening brace of the < perl-block >.
< actions > is a series of zero or more action "lines", where each action is either a string, which will be executed inside a shell, a perl anonymous array, which is executed without a shell (see IPC::Run), or a < perl-block >. For purposes of this discussion, a "line" continues as long as the lines of string action end with "" or as long as a perl anonymous array or < perl-block > do not have their closing punctuation. A string action can use the strings $1, $2, ..., for the matches, $DEP0, $DEP1, ..., for the dependencies, and $TARGET, which represents the target being built. For make enthusiasts, $* can be used for $1. A string action can also use any scalar global variables previously defined in a < perl-block >.
An include line includes the content of a file with < filename > as a SlayMakefile file. If there is no such file, Slay::Makefile will try to build it using rules that have already been presented. If there is no such rule, Slay::Makefile exits with an error unless there was a - before the "include".
The equivalent of makes defines are handled by setting perl global variables. Each main < perl-block > is executed in the order it appears in the file, but any that is part of a dependency or action is evaluated lazily, so that all the global variables will have been set.
Comments begin with a # and extend to the end of line.
Continuation lines can be specified by putting a backslash at the end of the previous line, provided however, that continuation lines are unnecessary (automatic) within a perl block or perl anonymous array.
METHODS
new
Class method. Creates a new Slay::Makefile object.
maker
Method. Returns the Slay::Maker object used by this Slay::Makefile object.
make (@targets)
Method. Calls the Slay::Maker objects make method to build the list of targets. If no targets are given, makes the targets of the first rule with constant targets.
parse ($filename)
Method. Parses file $filename as a SlayMakefile and populates the Slay::Maker object with its rules. Returns a reference to an array of parse errors.
parse_string ($string, [$filename, [$lineno]])
Method. Parses $string as a SlayMakefile. If $filename and/or $lineno arguments are provided, they are used for more detailed error reporting. Returns a reference to an array of parse errors.
Download (0.013MB)
Added: 2007-05-03 License: Perl Artistic License Price:
904 downloads
Convert::Scalar 1.03
Convert::Scalar is a Perl module that can convert between different representations of perl scalars. more>>
Convert::Scalar is a Perl module that can convert between different representations of perl scalars.
SYNOPSIS
use Convert::Scalar;
This module exports various internal perl methods that change the internal representation or state of a perl scalar. All of these work in-place, that is, they modify their scalar argument. No functions are exported by default.
The following export tags exist:
:utf8 all functions with utf8 in their name
:taint all functions with taint in their name
:refcnt all functions with refcnt in their name
:ok all *ok-functions.
utf8 scalar[, mode]
Returns true when the given scalar is marked as utf8, false otherwise. If the optional mode argument is given, also forces the interpretation of the string to utf8 (mode true) or plain bytes (mode false). The actual (byte-) content is not changed. The return value always reflects the state before any modification is done.
This function is useful when you "import" utf8-data into perl, or when some external function (e.g. storing/retrieving from a database) removes the utf8-flag.
utf8_on scalar
Similar to utf8 scalar, 1, but additionally returns the scalar (the argument is still modified in-place).
utf8_off scalar
Similar to utf8 scalar, 0, but additionally returns the scalar (the argument is still modified in-place).
utf8_valid scalar [Perl 5.7]
Returns true if the bytes inside the scalar form a valid utf8 string, false otherwise (the check is independent of the actual encoding perl thinks the string is in).
utf8_upgrade scalar
Convert the string content of the scalar in-place to its UTF8-encoded form (and also returns it).
utf8_downgrade scalar[, fail_ok=0]
Attempt to convert the string content of the scalar from UTF8-encoded to ISO-8859-1. This may not be possible if the string contains characters that cannot be represented in a single byte; if this is the case, it leaves the scalar unchanged and either returns false or, if fail_ok is not true (the default), croaks.
utf8_encode scalar
Convert the string value of the scalar to UTF8-encoded, but then turn off the SvUTF8 flag so that it looks like bytes to perl again. (Might be removed in future versions).
utf8_length scalar
Returns the number of characters in the string, counting wide UTF8 characters as a single character, independent of wether the scalar is marked as containing bytes or mulitbyte characters.
unmagic scalar, type
Remove the specified magic from the scalar (DANGEROUS!).
weaken scalar
Weaken a reference. (See also WeakRef).
taint scalar
Taint the scalar.
tainted scalar
returns true when the scalar is tainted, false otherwise.
untaint scalar
Remove the tainted flag from the specified scalar.
grow scalar, newlen
Sets the memory area used for the scalar to the given length, if the current length is less than the new value. This does not affect the contents of the scalar, but is only useful to "pre-allocate" memory space if you know the scalar will grow. The return value is the modified scalar (the scalar is modified in-place).
refcnt scalar[, newrefcnt]
Returns the current reference count of the given scalar and optionally sets it to the given reference count.
refcnt_inc scalar
Increments the reference count of the given scalar inplace.
refcnt_dec scalar
Decrements the reference count of the given scalar inplace. Use weaken instead if you understand what this function is fore. Better yet: dont use this module in this case.
refcnt_rv scalar[, newrefcnt]
Works like refcnt, but dereferences the given reference first. This is useful to find the reference count of arrays or hashes, which cnanot be passed directly. Remember that taking a reference of some object increases its reference count, so the reference count used by the *_rv-functions tend to be one higher.
refcnt_inc_rv scalar
Works like refcnt_inc, but dereferences the given reference first.
refcnt_dec_rv scalar
Works like refcnt_dec, but dereferences the given reference first.
ok scalar
uok scalar
rok scalar
pok scalar
nok scalar
niok scalar
Calls SvOK, SvUOK, SvROK, SvPOK, SvNOK or SvNIOK on the given scalar, respectively.
<<lessSYNOPSIS
use Convert::Scalar;
This module exports various internal perl methods that change the internal representation or state of a perl scalar. All of these work in-place, that is, they modify their scalar argument. No functions are exported by default.
The following export tags exist:
:utf8 all functions with utf8 in their name
:taint all functions with taint in their name
:refcnt all functions with refcnt in their name
:ok all *ok-functions.
utf8 scalar[, mode]
Returns true when the given scalar is marked as utf8, false otherwise. If the optional mode argument is given, also forces the interpretation of the string to utf8 (mode true) or plain bytes (mode false). The actual (byte-) content is not changed. The return value always reflects the state before any modification is done.
This function is useful when you "import" utf8-data into perl, or when some external function (e.g. storing/retrieving from a database) removes the utf8-flag.
utf8_on scalar
Similar to utf8 scalar, 1, but additionally returns the scalar (the argument is still modified in-place).
utf8_off scalar
Similar to utf8 scalar, 0, but additionally returns the scalar (the argument is still modified in-place).
utf8_valid scalar [Perl 5.7]
Returns true if the bytes inside the scalar form a valid utf8 string, false otherwise (the check is independent of the actual encoding perl thinks the string is in).
utf8_upgrade scalar
Convert the string content of the scalar in-place to its UTF8-encoded form (and also returns it).
utf8_downgrade scalar[, fail_ok=0]
Attempt to convert the string content of the scalar from UTF8-encoded to ISO-8859-1. This may not be possible if the string contains characters that cannot be represented in a single byte; if this is the case, it leaves the scalar unchanged and either returns false or, if fail_ok is not true (the default), croaks.
utf8_encode scalar
Convert the string value of the scalar to UTF8-encoded, but then turn off the SvUTF8 flag so that it looks like bytes to perl again. (Might be removed in future versions).
utf8_length scalar
Returns the number of characters in the string, counting wide UTF8 characters as a single character, independent of wether the scalar is marked as containing bytes or mulitbyte characters.
unmagic scalar, type
Remove the specified magic from the scalar (DANGEROUS!).
weaken scalar
Weaken a reference. (See also WeakRef).
taint scalar
Taint the scalar.
tainted scalar
returns true when the scalar is tainted, false otherwise.
untaint scalar
Remove the tainted flag from the specified scalar.
grow scalar, newlen
Sets the memory area used for the scalar to the given length, if the current length is less than the new value. This does not affect the contents of the scalar, but is only useful to "pre-allocate" memory space if you know the scalar will grow. The return value is the modified scalar (the scalar is modified in-place).
refcnt scalar[, newrefcnt]
Returns the current reference count of the given scalar and optionally sets it to the given reference count.
refcnt_inc scalar
Increments the reference count of the given scalar inplace.
refcnt_dec scalar
Decrements the reference count of the given scalar inplace. Use weaken instead if you understand what this function is fore. Better yet: dont use this module in this case.
refcnt_rv scalar[, newrefcnt]
Works like refcnt, but dereferences the given reference first. This is useful to find the reference count of arrays or hashes, which cnanot be passed directly. Remember that taking a reference of some object increases its reference count, so the reference count used by the *_rv-functions tend to be one higher.
refcnt_inc_rv scalar
Works like refcnt_inc, but dereferences the given reference first.
refcnt_dec_rv scalar
Works like refcnt_dec, but dereferences the given reference first.
ok scalar
uok scalar
rok scalar
pok scalar
nok scalar
niok scalar
Calls SvOK, SvUOK, SvROK, SvPOK, SvNOK or SvNIOK on the given scalar, respectively.
Download (0.006MB)
Added: 2006-08-02 License: Perl Artistic License Price:
1178 downloads
Variable::Strongly::Typed 1.1.0
Variable::Strongly::Typed is a Perl module to let some variables be strongly typed. more>>
Variable::Strongly::Typed is a Perl module to let some variables be strongly typed.
SYNOPSIS
use Variable::Strongly::Typed;
my $int :TYPE(int); # must have an int value
my $float :TYPE(float); # must have a float value
my $string :TYPE(string); # must not be a reference
my $file :TYPE(IO::File); # must be an IO::File
my @array_of_ints :TYPE(int); # Each slot must contain
# an int
my %hash_of_floats :TYPE(float); # Each value must be a float
my $int_own_error :TYPE(int, &my_own_error_handler);
# Roll my own error handler
my @array_of_rgb :TYPE(&red_green_blue); # my enumerated type
# For subs!!
sub return_an_int :TYPE(int) {
# .. do some stuff ..
return $something;
}
# ... and later ...
$int = 23; # All is well
$int = howdy!; # This line will croak with a good error message
$float = 3.23; # All is well, nothing to see here
$float = new XML::Parser; # croak!
$array_of_ints[23] = 44; # Groovy
$array_of_ints[12] = yah; # croak!
$hash_of_floats{pi} = 3.14159; # no problem
$hash_of_floats{e} = new IO::File; # croak!
# Return 1 if this val is RED, BLUE, or GREEN
# 0 otherwise
sub red_green_blue {
local $_ = shift;
/A RED z/xms || /A BLUE z/xms || /A GREEN z/xms;
}
$array_of_my_very_own_types[23] = 99; # croak!
$array_of_my_very_own_types[2] = BLUE; # OK!
$int_own_error = lksdklwe; # The sub my_own_error_hanlder
# will be # called with the
# offending value
my $got_it = return_an_int(); # Will croak (or call your error
# function) # if this sub doesnt
# return an int
This modules allow you to strongly type your variables. Also known as the no fun module - it can greatly enhance you codes quality and robustness.
By enforcing types on some (or all) of your variables you will eliminate a large class of careless (& not so careless) errors.
This could also aid an editor or code-browsing tools to verify code correctness without having to execute the script.
<<lessSYNOPSIS
use Variable::Strongly::Typed;
my $int :TYPE(int); # must have an int value
my $float :TYPE(float); # must have a float value
my $string :TYPE(string); # must not be a reference
my $file :TYPE(IO::File); # must be an IO::File
my @array_of_ints :TYPE(int); # Each slot must contain
# an int
my %hash_of_floats :TYPE(float); # Each value must be a float
my $int_own_error :TYPE(int, &my_own_error_handler);
# Roll my own error handler
my @array_of_rgb :TYPE(&red_green_blue); # my enumerated type
# For subs!!
sub return_an_int :TYPE(int) {
# .. do some stuff ..
return $something;
}
# ... and later ...
$int = 23; # All is well
$int = howdy!; # This line will croak with a good error message
$float = 3.23; # All is well, nothing to see here
$float = new XML::Parser; # croak!
$array_of_ints[23] = 44; # Groovy
$array_of_ints[12] = yah; # croak!
$hash_of_floats{pi} = 3.14159; # no problem
$hash_of_floats{e} = new IO::File; # croak!
# Return 1 if this val is RED, BLUE, or GREEN
# 0 otherwise
sub red_green_blue {
local $_ = shift;
/A RED z/xms || /A BLUE z/xms || /A GREEN z/xms;
}
$array_of_my_very_own_types[23] = 99; # croak!
$array_of_my_very_own_types[2] = BLUE; # OK!
$int_own_error = lksdklwe; # The sub my_own_error_hanlder
# will be # called with the
# offending value
my $got_it = return_an_int(); # Will croak (or call your error
# function) # if this sub doesnt
# return an int
This modules allow you to strongly type your variables. Also known as the no fun module - it can greatly enhance you codes quality and robustness.
By enforcing types on some (or all) of your variables you will eliminate a large class of careless (& not so careless) errors.
This could also aid an editor or code-browsing tools to verify code correctness without having to execute the script.
Download (0.010MB)
Added: 2007-01-18 License: Perl Artistic License Price:
1009 downloads
Variable Expression Library 1.1
Variable Expression Library is a C++ library that expands variables in text buffers. more>>
libvarexp is a C++ library that allows its users to detach any kind of information from the representation of that information by providing a simple-to-use but powerful text-template mechanism.
Similar mechanisms have been available in tools like sh(1), make(1), or perl(1) forever and have proven to be very useful.
The basic idea is that the relevant information is made available in variables, which the author of the template can than use within the text itself as he or she sees fit.
Consider, for example, a tool that will calculate the monthly financial reports of a small company.
Such a program should only calculate the required values, it should not worry about writing the resulting reports into an HTML file, a CSV file, or whatever format is desired. Instead, it should make the results of the calculation available in the variables "$TURNOVER", "$PROFIT", and "$INCREASE".
Then, using libvarexp, it could load an arbitrary template file and have the actual values inserted at the apropriate positions. Without changing a single line of code, one could generate the monthly report in HTML
<<lessSimilar mechanisms have been available in tools like sh(1), make(1), or perl(1) forever and have proven to be very useful.
The basic idea is that the relevant information is made available in variables, which the author of the template can than use within the text itself as he or she sees fit.
Consider, for example, a tool that will calculate the monthly financial reports of a small company.
Such a program should only calculate the required values, it should not worry about writing the resulting reports into an HTML file, a CSV file, or whatever format is desired. Instead, it should make the results of the calculation available in the variables "$TURNOVER", "$PROFIT", and "$INCREASE".
Then, using libvarexp, it could load an arbitrary template file and have the actual values inserted at the apropriate positions. Without changing a single line of code, one could generate the monthly report in HTML
Download (0.093MB)
Added: 2005-10-06 License: BSD License Price:
1478 downloads
Variable::Strongly::Typed::Scalar 1.1.0
Variable::Strongly::Typed::Scalar is Perl module for strongly typed scalar. more>>
Variable::Strongly::Typed::Scalar is Perl module for strongly typed scalar.
SYNOPSIS
This class is utilized by Variable::Strongly::Typed - you dont access this directly
=head1 DESCRIPTION
<<lessSYNOPSIS
This class is utilized by Variable::Strongly::Typed - you dont access this directly
=head1 DESCRIPTION
Download (0.010MB)
Added: 2007-01-18 License: Perl Artistic License Price:
1009 downloads
Secleted [ 0 ] software to compare
Copyright Notice:
Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future software development. The above scalar variables search only lists software in full, demo and trial versions for free download. Download links are directly from our mirror sites or publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed