---
name: "Set::Scalar::Valued"
section: "3pm"
platform: "linux"
package: "libset-scalar-perl"
version: "1.29-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Set::Scalar::Valued"
---

# Set::Scalar::Valued(3pm)

valued sets

## NAME

Set::Scalar::Valued - valued sets

## SYNOPSIS

```
    use Set::Scalar::Valued;
    $s = Set::Scalar::Valued->new;
    $s->insert(a => 12, 'b c' => $d);
    $s->delete('b c' => $d);
    $t = Set::Scalar->new(x => $y, y => $z);
```

## DESCRIPTION

Valued sets are an extension of the traditional set concept.  In addition to a member just existing in the set, the member also has a distinct value.  You can think of this a combination of a traditional set and a Perl hash.

The used methods are as for the traditional of Set::Scalar, with the difference that when creating (**new()**) or modifying (**insert()**, **delete()**, **invert()**), you must supply twice the number of arguments: the member-value pairs, instead of just the members.  Note, though, that in the current implementation of **delete()** the value half is unused, the deletion is by the member.  In future implementation this behavior may change so that also the value matters.

There are a couple of additional methods:

```
    %ve = $s->valued_members;
```

which returns the member-value pairs, and

```
    @v  = $s->values;
```

which returns just the values (in the same order as the **members()** method would return the members), and

```
    $v  = $s->value($member);
```

which returns the value of the member.

The display format of a valued set is the member-value pairs separated by " =\> ", the pairs separated by ", " and enclosed in curly brackets {}.

## AUTHOR

Jarkko Hietaniemi \<jhi@iki.fi\>
