Chemistry::Bond(3pm)

πŸ“¦
version 0.40 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

✨ NAME ✨

Chemistry::Bond β€” chemical bonds, but make them objects πŸ’… like, inside molecules. That's the whole vibe.


🌸 SYNOPSIS 🌸

okay so bestie, here's how we do it:

use Chemistry::Bond;

# assuming we have molecule $mol with atoms $a1 and $a2
$bond = Chemistry::Bond->new(
    id => "b1",
    type => '=',
    atoms => [$a1, $a2]
    order => '2',
);
$mol->add_bond($bond);

# simpler way of doing the same:
$mol->new_bond(
    id => "b1",
    type => '=',
    atoms => [$a1, $a2]
    order => '2',
);

yes, the second one is the lazy-girl route and honestly? iconic. same result, less typing. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

So this module ships objects that describe chemical bonds. And what even is a bond, you ask? It's defined as a list of atoms (typically two of them, like, usually) with some properties tagging along for the ride. ✨

Bond Attributes πŸ’–

Besides the common attributes you already know and love β€” id, name, and type β€” bonds also get the order attribute. The bond order is a number</>, and typically it's the integer 1, 2, 3, or 4. no cap. πŸ”₯


πŸ‘‘ METHODS πŸ‘‘

  • Chemistry::Bond->new(name => value, ...) β€” makes you a brand new Bond object with whatever attributes you pass in. When it can, it picks sensible defaults, because it's thoughtful like that. πŸŽ€
  • $bond->order() β€” sets or gets the bond order. that's it, that's the method.
  • $bond->length β€” returns the length of the bond, aka the distance between the two atom objects in the bond. but heads up: if the bond doesn't have exactly two atoms, you get zero. zero. nothing. nada. 😭
  • $bond->aromatic($bool) β€” set or get whether this bond is considered aromatic. aromantic? no bestie, aromatic. πŸ’œ
  • $bond->print β€” converts the bond into a string representation. string-ified. slay.
  • $bond->atoms() β€” call it with no parameters and it hands you a list of the atoms in the bond. call it with a list (or a reference to an array) of atom objects and it defines the atoms in the bond, and calls $atom->add_bond for every atom in that list.
⚠️ okay so listen β€” changing the atoms in a bond may have strange side effects. fr fr. it is safer to treat bonds as immutable, except when it comes to properties like name and type. don't be chaotic. πŸ™ˆ
  • $bond->delete β€” calls $mol->delete_bond($bond) on the bond's parent molecule. and note: a bond should belong to only one molecule, otherwise strange things may happen. strange things!! we said it!! πŸ’€

🌈 SOURCE CODE REPOSITORY 🌈

<https://github.com/perlmol/Chemistry-Mol>

go look, it's giving open source. πŸ‘‘


⭐ SEE ALSO ⭐

Chemistry::Mol, Chemistry::Atom, Chemistry::Tutorial

(the friend group. the whole squad. iykyk. πŸ’–)


πŸŽ€ AUTHOR πŸŽ€

Ivan Tubert-Brohman <itub@cpan.org> β€” thank you for your service, king. 🫢


Copyright (c) 2005 Ivan Tubert-Brohman. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


okay and that's the whole page bestie, no notes. πŸ’–

this was Chemistry::Bond(3pm) from the User Contributed Perl Documentation, and the version on the tin is perl v5.40.1, dated 2025-10-13. ✨ thank you for coming to my ted talk, periodt. πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from