.PerlSetHash {RSPerl}R Documentation

Set elements of a Perl array or (hash) table

Description

These functions allow one to set the values of one more elements of a Perl array or table. They underly the convenience methods for assigning values to a PerlArrayReference and PerlHashReference of the form x[1] <- "a" and x["a"] <- 1

Usage

.PerlSetHash(ref, ..., value)
.PerlSetArray(ref, ..., value)

Arguments

ref the Perl object reference which should be a PerlHashReference or PerlArrayReference for .PerSetHash and .PerlSetArray respectively.
... values identifiying the elements of the array (as integers) or hash-table (as strings) for .PerSetHash and .PerlSetArray respectively.
value the value to be assigned to the elements of the Perl array or table.

Details

This converts the values and the element identifiers to Perl and resolves the Perl reference there and then takes the appropriate action.

Value

The object value so that it can used in linked assignments of the form x <- y <- .PerlSetHash(ref, 1, value="Foo")

Author(s)

Duncan Temple Lang

References

http://www.omegahat.org/RSPerl

See Also

.PerlGet .PerlGetArray .PerlGetHash

Examples

  # Manipulation of an array
 a <- .PerlNewArray()
 .PerlSetArray(a, 1, value="Test")
 .PerlGetArray(a)
 a[1]
 a[1] <- "Again"
 a[1]

 a[2] <- "Foo"

  # Manipulation of a Hash table.
 tb <- .PerlNewTable()
 .PerlSetHash(tb, "a", value="Test")
 .PerlSetHash(tb, "b", value="Again")
 .PerlGetTable(tb)
 tb["c"] <- "Another"
 tb["c"]

[Package RSPerl Index]