Pattern::Atom(3)
π Pattern::Atom β Chemistry::Pattern::Atom π
okay bestie, gather round, because this is a page from the User Contributed Perl Documentation and it's literally about Pattern::Atom(3), a tiny little module with main character energy. no cap, it's short, it's sweet, and it knows how to match. let's get into it π«Ά
β¨ NAME β¨
Chemistry::Pattern::Atom β an atom that knows how to match π
β¨ SYNOPSIS β¨
my $patt_atom = Chemistry::Pattern::Atom->new(symbol => C);
$patt_atom->test_sub( sub {
my ($what, $where) = @_;
$where->bonds == 3 ? 1 : 0; # only match atoms with three bonds
});
like, look at her go. she's an atom and she has opinions about who she matches. obsessed. π
β¨ DESCRIPTION β¨
so, objects of this class represent atoms in a pattern. she's a subclass of Chemistry::Atom, which means she inherits all the regular atom behaviour but also picked up some extra β¨talentsβ¨ along the way.
on top of the properties that regular atoms have, pattern atoms have a method for testing whether they match an atom in a molecule. πΈ
by default, a pattern atom matches an atom if they have the same symbol. that's the default vibe check. but β and this is the slay part β it is possible to substitute this with an arbitrary criterion by providing a custom test subroutine. yes bestie, you can define your own rules. iconic behaviour fr fr. π₯
β¨ METHODS β¨
$patt_atom->test($atom)β tests if the pattern atom matches the atom given by$atom. returns true or false. that's it, that's the whole method, no notes. π―$patt_atom->test_sub(\&my_test_sub)β lets you specify an arbitrary test subroutine to be used instead of the default one.&my_test_submust take two parameters: the first one is the pattern atom, and the second is the atom to match. it must return true if there's a match. no pressure or anything, but the fate of the match rests on your return value. π$patt_atom->map_to([$atom])β returns or sets the atom that is considered to be matched by$patt_atom. getter and setter, one method, double duty, she contains multitudes. π
β¨ VERSION β¨
0.27 β vintage but still serving. π
β¨ SEE ALSO β¨
- Chemistry::Pattern β her bestie, go say hi.
- the PerlMol website β
<http://www.perlmol.org/>π
β¨ AUTHOR β¨
Ivan Tubert-Brohman <itub@cpan.org> β thank you for your service, king π«Ά
β¨ COPYRIGHT β¨
Copyright (c) 2009 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. π
ngl "same terms as Perl itself" is the most iconic license line in the game. periodt.
and that's the whole page bestie, you ate it π β¨ this little gem was brought to you by perl v5.42.0, dated 2026-01-17, and honestly? she's still cute. bye babe π¦π
π¦ where this page comes from
- fedora 44: perl-Chemistry-Pattern 0.27-2.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms