Chemistry::Bond(3pm)
β¨ 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_bondfor 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 likenameandtype. 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 π
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
- ubuntu resolute: libchemistry-mol-perl 0.40-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libchemistry-mol-perl 0.40-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms