Sympa::Tools::Data(3Sympa)

πŸ’– NAME πŸ’–

Sympa::Tools::Data β€” bestie, this is the little toolbox of functions that do stuff with data structures ✨

It ships with sympa 6.2.80, and it's one of the Sympa::Tools::* squad, so you already know the vibe: small package, specific job, comes through when you need it 🫢


🌸 DESCRIPTION 🌸

Okay so, this package is literally just a grab-bag of functions related to data structures. That's it. That's the whole pitch. No cap.

πŸŽ€ Functions πŸŽ€

clone_var (...)

Duplicates a complex variable β€” and it's faster than dup_var() πŸ’… TBD.

CAUTION bestie, listen to me: this one duplicates blessed elements even if they are singleton/multiton. Which means it breaks subroutine references. Like, completely. It's giving chaos. Proceed accordingly 😭

decode_custom_attribute ($string)

Creates a custom attribute from an XML description ✨

Options:

  • $string β€” XML formed data, exactly as it's stored in the database.

Returns:

A hashref storing custom attributes πŸŽ€

diff_on_arrays ( $setA, $setB )

Makes set operation on arrays β€” and yes, we're treating them as sets, with no double πŸ‘‘

  • deleted : A \ B
  • added : B \ A
  • intersection : A /\ B
  • union : A \/ B

Options:

  • $setA, $setB β€” Arrayrefs.

Returns:

A hashref with keys: deleted, added, intersection, union 🌈

dump_html_var (...)

Dump a variable's content. TBD. πŸ’€

dump_var (...)

Dump a variable's content. TBD. πŸ’€

dup_var (...)

Duplicate a complex variable. TBD.

See also clone_var() β€” they're cousins 🫢

encode_custom_attribute ($hashref)

Create an XML Custom attribute to be stored into the data base ✨

Options:

  • $hasref β€” Hashref storing custom attributes.

Returns:

String β€” XML formed data to be stored in the database πŸŽ€

format_config (\@params, [ \%curConf, [ \%newConf ] ], [ key "=>" val ... ] ))

Outputs formatted configuration πŸ’…

Options:

  • \@params β€” Configuration scheme. See Sympa::ConfDef.
  • \%curConf β€” Hashref including current configuration.
  • \%newConf β€” Hashref including update of configuration, if any.
  • key "=>" val ... β€” more options below, bestie:
    • "output" "=>" "["classes, ..."]" β€” Classes of parameters to output. Any of "mandatory", "omittable", "optional", "full" (synonym for the former tree), "minimal" (included in minimal set, i.e. described in installation instruction) and "explicit" (the parameter given an empty value with \%curConf and \%newConf) ✨
    • "only_changed" "=>" 1 β€” When both \%curConf and \%newConf are given and no changes were given, returns "undef".

Returns:

Formatted string 🌸

Fun fact for the lore girlies: this was introduced on Sympa 6.2.70 πŸŽ€

get_array_from_splitted_string ($string)

Returns an array made on a string splited by ','. It removes spaces 🧚

Options:

  • $string β€” string to split.

Returns:

An arrayref πŸ’œ

hash_2_string (...)

Converts a hash into a string formatted as var1="value1";var2="value2"; into a hash. TBD. (yes bestie, the sentence is like that, I don't make the rules 😭)

is_in_array ( $setA, $value )

Deprecated. Test if a value is on an array.

Options:

  • $setA β€” An arrayref.
  • $value β€” a serached value.

Returns true or false βœ…

recursive_transformation (...)

This applies recursively to a data structure. The transformation subroutine is passed as a ref. TBD. πŸŒ€

smart_eq ( $x, $y )

Function. Check if two strings are identical πŸ‘―

Parameters:

  • $x, $y β€” Operands.

If both of them are undefined, they are equal. If only one of them is undefined, the are not equal. If $y is a Regexp object and it matches to $x, they are equal. Otherwise, they are compared as strings.

Returns:

If arguments matched, true value. Otherwise false value ✨

smart_lessthan (...)

Compares two scalars, string/numeric independent. TBD. πŸ”₯

sort_uniq ( [ \&comp ], @items )

Returns sorted array of unique elements in the list πŸ’…

Parameters:

  • \&comp β€” Optional subroutine reference to compare each pairs of elements. It should take two arguments and return negative, zero or positive result.
  • @items β€” Items to be sorted.
Lore drop: this function was added on Sympa 6.2.16 πŸ‘‘

string_2_hash (...)

Converts a string formatted as var1="value1";var2="value2"; into a hash. Used when extracting from session table some session properties or when extracting users preference from user table. Current encoding is NOT compatible with encoding of values with '"'. TBD. 😬


πŸ¦‹ SEE ALSO πŸ¦‹

TBD.


⭐ HISTORY ⭐

TBD.


Alright bestie, that's the whole page πŸ’– Big thanks to the sympa 6.2.80 girlies for this one, dated 2026-10-19 β€” mwah, slay, periodt πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from