Pattern::Atom(3)

πŸ“¦ version 0.27, in fedora 44

πŸ’– 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_sub must 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 ✨


✨ AUTHOR ✨

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


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