scalar
Sponsored Links
Sponsored Links
Secleted [ 0 ] software to compare
Results 1 - 15 of about 327
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
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::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::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
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
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
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
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::Footnote 0.99_02
Scalar::Footnote is a Perl module that can attach hidden scalars to references. more>>
Scalar::Footnote is a Perl module that can attach hidden scalars to references.
SYNOPSIS
use Data::Dumper;
use Scalar::Footnote;
my $obj = Foo->new;
# attach invisible footnote to $obj:
$obj->Scalar::Footnote::set( my_key => my footnote );
print Dumper( $obj );
# get it back:
my $note = $obj->Scalar::Footnote::get( my_key );
print "footnote: $noten";
# remove it:
my $note = $obj->Scalar::Footnote::remove( my_key );
Scalar::Footnote lets you attach scalar footnotes to an object (or any kind of reference, really) that are essentially invisible from Perl. For example, if you try dumping an object that has a footnote attached to it, you wont actually see the footnote:
my $obj = bless [qw( foo bar )], Foo;
$obj->Scalar::Footnote::set( Foo => foo note );
print Dumper( $obj );
prints:
$VAR1 = bless [
foo,
bar
], Foo;
You can of course still access the footnote with Scalar::Footnote::get.
<<lessSYNOPSIS
use Data::Dumper;
use Scalar::Footnote;
my $obj = Foo->new;
# attach invisible footnote to $obj:
$obj->Scalar::Footnote::set( my_key => my footnote );
print Dumper( $obj );
# get it back:
my $note = $obj->Scalar::Footnote::get( my_key );
print "footnote: $noten";
# remove it:
my $note = $obj->Scalar::Footnote::remove( my_key );
Scalar::Footnote lets you attach scalar footnotes to an object (or any kind of reference, really) that are essentially invisible from Perl. For example, if you try dumping an object that has a footnote attached to it, you wont actually see the footnote:
my $obj = bless [qw( foo bar )], Foo;
$obj->Scalar::Footnote::set( Foo => foo note );
print Dumper( $obj );
prints:
$VAR1 = bless [
foo,
bar
], Foo;
You can of course still access the footnote with Scalar::Footnote::get.
Download (0.009MB)
Added: 2007-05-21 License: Perl Artistic License Price:
889 downloads
Tie::Scalar::Sticky 1.06
Tie::Scalar::Sticky is a Perl module with block assignments to scalars. more>>
Tie::Scalar::Sticky is a Perl module with block assignments to scalars.
SYNOPSIS
use strict;
use Tie::Scalar::Sticky;
tie my $sticky, Tie::Scalar::Sticky;
$sticky = 42;
$sticky = ; # still 42
$sticky = undef; # still 42
$sticky = 0; # now its zero
tie my $sticky, Tie::Scalar::Sticky => qw/ foo bar /;
$sticky = 42;
$sticky = foo; # still 42
$sticky = bar; # still 42
$sticky = 0; # now its zero
Scalars tieed to this module will reject any assignments of undef or the empty string or any of the extra arugments provided to tie(). It simply removes the need for you to validate assignments, such as:
$var = $val unless grep $val eq $_, qw(not one of these);
Actually, that is the exact idea used in this module ...
So, why do this? Because i recently had to loop through a list where some items were undefined and the previously defined value should be used instead. In a nutshell:
tie my $sticky, Tie::Scalar::Sticky => 9, string;
for (3,undef,string,2,,1,9,0) {
$sticky = $_;
print $sticky, ;
}
Should print: 3 3 2 2 1 0
<<lessSYNOPSIS
use strict;
use Tie::Scalar::Sticky;
tie my $sticky, Tie::Scalar::Sticky;
$sticky = 42;
$sticky = ; # still 42
$sticky = undef; # still 42
$sticky = 0; # now its zero
tie my $sticky, Tie::Scalar::Sticky => qw/ foo bar /;
$sticky = 42;
$sticky = foo; # still 42
$sticky = bar; # still 42
$sticky = 0; # now its zero
Scalars tieed to this module will reject any assignments of undef or the empty string or any of the extra arugments provided to tie(). It simply removes the need for you to validate assignments, such as:
$var = $val unless grep $val eq $_, qw(not one of these);
Actually, that is the exact idea used in this module ...
So, why do this? Because i recently had to loop through a list where some items were undefined and the previously defined value should be used instead. In a nutshell:
tie my $sticky, Tie::Scalar::Sticky => 9, string;
for (3,undef,string,2,,1,9,0) {
$sticky = $_;
print $sticky, ;
}
Should print: 3 3 2 2 1 0
Download (0.003MB)
Added: 2007-02-13 License: Perl Artistic License Price:
983 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
fields::aliased 1.05
fields::aliased is a Perl module that can create aliases for object fields. more>>
fields::aliased is a Perl module that can create aliases for object fields.
SYNOPSIS
package MyPackage;
use strict;
use fields qw($scalar @array %hash);
sub new {
my $class = shift;
my $self = fields::new($class);
return $self;
}
sub mymethod {
my MyPackage $self = shift;
use fields::aliased qw($self $scalar @array %hash);
$scalar = 1;
@array = (2 .. 4);
%hash = (one => 1, two => 2);
}
This module is a companion to the fields module, which allows efficient handling of instance variables with checking at compile time. It goes one step further and actually creates lexical aliases to the instance values, which can make code not only easier to type, but easier to read as well.
Declarations
You declare the fields using the fields pragma, as always.
use fields qw($scalar @array %hash nosigil);
Each field name may be preceded by a type sigil to indicate which kind of variable it is. Names without the type sigil are treated as scalars.
For names beginning with an underscore, see "PRIVATE FIELDS" below.
Constructors
You call fields::new to create the object.
my $self = fields::new($class);
Usage
In each method that uses the individual fields, you add a line similar to the following:
use fields::aliased qw($self $scalar @array %hash nosigil);
That is, list the variable being used for the object reference, and then the names of the fields that you are going to use in this method. fields::aliased takes care of declaring the appropriate Perl lexical variables and linking them to the appropriate field. You only need to specify the fields you are actually going to use, including any inherited from superclasses.
<<lessSYNOPSIS
package MyPackage;
use strict;
use fields qw($scalar @array %hash);
sub new {
my $class = shift;
my $self = fields::new($class);
return $self;
}
sub mymethod {
my MyPackage $self = shift;
use fields::aliased qw($self $scalar @array %hash);
$scalar = 1;
@array = (2 .. 4);
%hash = (one => 1, two => 2);
}
This module is a companion to the fields module, which allows efficient handling of instance variables with checking at compile time. It goes one step further and actually creates lexical aliases to the instance values, which can make code not only easier to type, but easier to read as well.
Declarations
You declare the fields using the fields pragma, as always.
use fields qw($scalar @array %hash nosigil);
Each field name may be preceded by a type sigil to indicate which kind of variable it is. Names without the type sigil are treated as scalars.
For names beginning with an underscore, see "PRIVATE FIELDS" below.
Constructors
You call fields::new to create the object.
my $self = fields::new($class);
Usage
In each method that uses the individual fields, you add a line similar to the following:
use fields::aliased qw($self $scalar @array %hash nosigil);
That is, list the variable being used for the object reference, and then the names of the fields that you are going to use in this method. fields::aliased takes care of declaring the appropriate Perl lexical variables and linking them to the appropriate field. You only need to specify the fields you are actually going to use, including any inherited from superclasses.
Download (0.008MB)
Added: 2007-05-14 License: Perl Artistic License Price:
894 downloads
Test::Data 1.20
Test::Data is a Perl module to test functions for particular variable types. more>>
Test::Data is a Perl module to test functions for particular variable types.
SYNOPSIS
use Test::Data qw(Scalar Array Hash Function);
Test::Data provides utility functions to check properties and values of data and variables.
Functions
Plug-in modules define functions for each data type. See the appropriate module.
How it works
The Test::Data module simply emports functions from Test::Data::* modules. Each module defines a self-contained function, and puts that function name into @EXPORT. Test::Data defines its own import function, but that does not matter to the plug-in modules.
If you want to write a plug-in module, follow the example of one that already exists. Name the module Test::Data::Foo, where you replace Foo with the right name. Test::Data should automatically find it.
<<lessSYNOPSIS
use Test::Data qw(Scalar Array Hash Function);
Test::Data provides utility functions to check properties and values of data and variables.
Functions
Plug-in modules define functions for each data type. See the appropriate module.
How it works
The Test::Data module simply emports functions from Test::Data::* modules. Each module defines a self-contained function, and puts that function name into @EXPORT. Test::Data defines its own import function, but that does not matter to the plug-in modules.
If you want to write a plug-in module, follow the example of one that already exists. Name the module Test::Data::Foo, where you replace Foo with the right name. Test::Data should automatically find it.
Download (0.008MB)
Added: 2007-05-03 License: Perl Artistic License Price:
904 downloads
Safe::World 0.14
Safe::World can create multiple virtual instances of a Perl interpreter that can be assembled together. more>>
Safe::World can create multiple virtual instances of a Perl interpreter that can be assembled together.
SYNOPSIS
See USE section for complexer example and the test.pl script.
use Safe::World ;
my $world = Safe::World->new(
stdout => $stdout , ## - redirect STDOUT to this scalar.
stderr => $stderr , ## - redirect STDERR to this scalar.
flush => 1 , ## - output is flushed, soo dont need to wait exit to
## have all the data inside $stdout.
) ;
## Evaluate some code:
$world->eval(q`
use Data::Dumper ;
print Dumper( {a => 1 , b => 2} ) ;
`);
$world->close ; ## ensure that everything is finished and flushed.
die($stderr) if $stderr ;
print $stdout ;
$world = undef ; ## Destroy the world. Here the compartment is cleanned.
Note that in this example, inside the World is loaded Data::Dumper, but Data::Dumper was loaded only inside of it, keeping the outside normal.
<<lessSYNOPSIS
See USE section for complexer example and the test.pl script.
use Safe::World ;
my $world = Safe::World->new(
stdout => $stdout , ## - redirect STDOUT to this scalar.
stderr => $stderr , ## - redirect STDERR to this scalar.
flush => 1 , ## - output is flushed, soo dont need to wait exit to
## have all the data inside $stdout.
) ;
## Evaluate some code:
$world->eval(q`
use Data::Dumper ;
print Dumper( {a => 1 , b => 2} ) ;
`);
$world->close ; ## ensure that everything is finished and flushed.
die($stderr) if $stderr ;
print $stdout ;
$world = undef ; ## Destroy the world. Here the compartment is cleanned.
Note that in this example, inside the World is loaded Data::Dumper, but Data::Dumper was loaded only inside of it, keeping the outside normal.
Download (0.034MB)
Added: 2007-08-15 License: Perl Artistic License Price:
802 downloads
Contextual::Return 0.1.0
Contextual::Return is a Perl module to create context-senstive return values. more>>
Contextual::Return is a Perl module to create context-senstive return values.
SYNOPSIS
use Contextual::Return;
use Carp;
sub foo {
return
SCALAR { thirty-twelve }
BOOL { 1 }
NUM { 7*6 }
STR { forty-two }
LIST { 1,2,3 }
HASHREF { {name => foo, value => 99} }
ARRAYREF { [3,2,1] }
GLOBREF { *STDOUT }
CODEREF { croak "Dont use this result as code!"; }
;
}
# and later...
if (my $foo = foo()) {
for my $count (1..$foo) {
print "$count: $foo is:n"
. " array: @{$foo}n"
. " hash: $foo->{name} => $foo->{value}n"
;
}
print {$foo} $foo->();
}
Usually, when you need to create a subroutine that returns different values in different contexts (list, scalar, or void), you write something like:
sub get_server_status {
my ($server_ID) = @_;
# Acquire server data somehow...
my %server_data = _ascertain_server_status($server_ID);
# Return different components of that data,
# depending on call context...
if (wantarray()) {
return @server_data{ qw(name uptime load users) };
}
if (defined wantarray()) {
return $server_data{load};
}
if (!defined wantarray()) {
carp Useless use of get_server_status() in void context;
return;
}
else {
croak q{Bad context! No biscuit!};
}
}
That works okay, but the code could certainly be more readable. In its simplest usage, this module makes that code more readable by providing three subroutines--LIST(), SCALAR(), VOID()--that are true only when the current subroutine is called in the corresponding context:
use Contextual::Return;
sub get_server_status {
my ($server_ID) = @_;
# Acquire server data somehow...
my %server_data = _ascertain_server_status($server_ID);
# Return different components of that data
# depending on call context...
if (LIST) { return @server_data{ qw(name uptime load users) } }
if (SCALAR) { return $server_data{load} }
if (VOID) { print "$server_data{load}n" }
else { croak q{Bad context! No biscuit!} }
}
Contextual returns
Those three subroutines can also be used in another way: as labels on a series of contextual return blocks (collectively known as a context sequence). When a context sequence is returned, it automatically selects the appropriate contextual return block for the calling context. So the previous example could be written even more cleanly as:
use Contextual::Return;
sub get_server_status {
my ($server_ID) = @_;
# Acquire server data somehow...
my %server_data = _ascertain_server_status($server_ID);
# Return different components of that data
# depending on call context...
return (
LIST { return @server_data{ qw(name uptime load users) } }
SCALAR { return $server_data{load} }
VOID { print "$server_data{load}n" }
DEFAULT { croak q{Bad context! No biscuit!} }
);
}
The context sequence automatically selects the appropriate block for each call context.
<<lessSYNOPSIS
use Contextual::Return;
use Carp;
sub foo {
return
SCALAR { thirty-twelve }
BOOL { 1 }
NUM { 7*6 }
STR { forty-two }
LIST { 1,2,3 }
HASHREF { {name => foo, value => 99} }
ARRAYREF { [3,2,1] }
GLOBREF { *STDOUT }
CODEREF { croak "Dont use this result as code!"; }
;
}
# and later...
if (my $foo = foo()) {
for my $count (1..$foo) {
print "$count: $foo is:n"
. " array: @{$foo}n"
. " hash: $foo->{name} => $foo->{value}n"
;
}
print {$foo} $foo->();
}
Usually, when you need to create a subroutine that returns different values in different contexts (list, scalar, or void), you write something like:
sub get_server_status {
my ($server_ID) = @_;
# Acquire server data somehow...
my %server_data = _ascertain_server_status($server_ID);
# Return different components of that data,
# depending on call context...
if (wantarray()) {
return @server_data{ qw(name uptime load users) };
}
if (defined wantarray()) {
return $server_data{load};
}
if (!defined wantarray()) {
carp Useless use of get_server_status() in void context;
return;
}
else {
croak q{Bad context! No biscuit!};
}
}
That works okay, but the code could certainly be more readable. In its simplest usage, this module makes that code more readable by providing three subroutines--LIST(), SCALAR(), VOID()--that are true only when the current subroutine is called in the corresponding context:
use Contextual::Return;
sub get_server_status {
my ($server_ID) = @_;
# Acquire server data somehow...
my %server_data = _ascertain_server_status($server_ID);
# Return different components of that data
# depending on call context...
if (LIST) { return @server_data{ qw(name uptime load users) } }
if (SCALAR) { return $server_data{load} }
if (VOID) { print "$server_data{load}n" }
else { croak q{Bad context! No biscuit!} }
}
Contextual returns
Those three subroutines can also be used in another way: as labels on a series of contextual return blocks (collectively known as a context sequence). When a context sequence is returned, it automatically selects the appropriate contextual return block for the calling context. So the previous example could be written even more cleanly as:
use Contextual::Return;
sub get_server_status {
my ($server_ID) = @_;
# Acquire server data somehow...
my %server_data = _ascertain_server_status($server_ID);
# Return different components of that data
# depending on call context...
return (
LIST { return @server_data{ qw(name uptime load users) } }
SCALAR { return $server_data{load} }
VOID { print "$server_data{load}n" }
DEFAULT { croak q{Bad context! No biscuit!} }
);
}
The context sequence automatically selects the appropriate block for each call context.
Download (0.022MB)
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 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