---
name: "Config::Model::HashId"
section: "3pm"
platform: "linux"
package: "libconfig-model-perl"
version: "2.155-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Config::Model::HashId"
---

# Config::Model::HashId(3pm)

Handle hash element for configuration model

## NAME

Config::Model::HashId - Handle hash element for configuration model

## VERSION

version 2.155

## SYNOPSIS

See "SYNOPSIS" in Config::Model::AnyId

## DESCRIPTION

This class provides hash elements for a Config::Model::Node.

The hash index can either be en enumerated type, a boolean, an integer or a string.

## CONSTRUCTOR

HashId object should not be created directly.

## Hash model declaration

See model declaration section from Config::Model::AnyId.

## Methods

### get\_type

Returns `"hash"`.

### fetch\_size

Returns the number of elements of the hash.

### sort

Sort an ordered hash. Throws an error if called on a non ordered hash.

### insort

Parameters: key

Create a new element in the ordered hash while keeping alphabetical order of the keys

Returns the newly created element.

Throws an error if called on a non ordered hash.

### firstkey

Returns the first key of the hash. Behaves like `"each"` core perl function.

### nextkey

Returns the next key of the hash. Behaves like `"each"` core perl function.

### swap

Parameters: `"( key1 , key2 )"`

Swap the order of the 2 keys. Ignored for non ordered hash.

### move

Parameters: `"( key1 , key2 )"`

Rename key1 in key2.

Also also optional check parameter to disable warning:

```
 move ('foo','bar', check => 'no')
```

### move\_after

Parameters: `"( key_to_move [ , after_this_key ] )"`

Move the first key after the second one. If the second parameter is omitted, the first key is placed in first position. Ignored for non ordered hash.

### move\_up

Parameters: `"( key )"`

Move the key up in a ordered hash. Attempt to move up the first key of an ordered hash is ignored. Ignored for non ordered hash.

### move\_down

Parameters: `"( key )"`

Move the key down in a ordered hash. Attempt to move up the last key of an ordered hash is ignored. Ignored for non ordered hash.

### load\_data

Parameters: `"( data => ( hash_ref | array_ref ) [ , check => ... , ... ])"`

Load data as a hash ref for standard hash.

Ordered hash should be loaded with an array ref or with a hash containing a special `"__order"` element. E.g. loaded with either:

```
  [ a => 'foo', b => 'bar' ]
```

or

```
  { __order => ['a','b'], b => 'bar', a => 'foo' }
```

`"__skip_order"` parameter can be used if loading order is not important:

```
  { __skip_order => 1, b => 'bar', a => 'foo'}
```

load\_data can also be called with a single ref parameter.

Return 1 of some data was loaded.

### get\_info

Returns a list of information related to the hash. See "get\_info" in Config::Model::Value for more details.

## AUTHOR

Dominique Dumont, (ddumont at cpan dot org)

## SEE ALSO

Config::Model,  Config::Model::Instance,  Config::Model::AnyId, Config::Model::ListId, Config::Model::Value

## AUTHOR

Dominique Dumont

## COPYRIGHT AND LICENSE

This software is Copyright (c) 2005-2022 by Dominique Dumont.

This is free software, licensed under:

```
  The GNU Lesser General Public License, Version 2.1, February 1999
```
