Inline::SLang::Assoc module contains support for associative arrays.
SYNOPSIS
use Inline 'SLang';
# you can send hash references to S-Lang
print_in_slang( { a => 23, "b b" => "foo" } );
# and get them back from S-Lang
$href = get_from_slang();
print "The assoc array contains:n" .
join( "", map { "t$_ => $$href{$_}n"; } keys %$href );
__END__
__SLang__
define print_in_slang (assoc) {
message( "SLang thinks you sent it an assoc. array with:" );
foreach ( assoc ) using ( "keys", "values" ) {
variable k, v;
( k, v ) = ();
vmessage( " key %s = %S", k, v );
}
}
define get_from_slang() {
variable x = Assoc_Type [String_Type];
x["a key"] = "a value";
x["another key"] = "another value";
return x;
}
The output of this code - which can be found in the source-code distribution as examples/assoc.pl - is:
SLang thinks you sent it an assoc. array with:
key a = 23
key b b = foo
The assoc array contains:
another key => another value
a key => a value
Product's homepage
Requirements:
· Perl v5.6.0 or higher.
· Test::More module (comes with perl 5.8.0)
· Inline module version 0.42 or higher.
· PDL v2.4.0 or higher will be used if installed