Pattern::Bond(3)

πŸ“¦ version 0.27, in fedora 44

πŸ’– Pattern::Bond(3) πŸ’–

okay bestie, welcome to Chemistry::Pattern::Bond, a little corner of the User Contributed Perl Documentation and honestly? she's iconic. pull up a chair 🫢


✨ NAME ✨

Chemistry::Pattern::Bond β€” a bond that knows how to match πŸ‘‘


🌸 SYNOPSIS 🌸

my $patt_bond = Chemistry::Pattern::Bond->new(order => 2);
$patt_bond->test_sub( sub {
    my ($what, $where) = @_;
    $where->type eq 'purple' ? 1 : 0; # only match purple bonds
});

like yes, you can absolutely just make one with an order, or you can get fancy and hand her a whole custom test sub. main character energy fr fr πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, objects of this class represent bonds in a pattern. she's a subclass of Chemistry::Bond, so she inherited all the regular bond stuff β€” but on top of that, pattern bonds have a method for testing if they match a bond in a molecule. that's the whole point of her existence, no cap.

by default, a pattern bond matches a bond if they have the same bond order or both are aromatic. cute, right?

and if that default isn't giving what you need? you can swap it out for an arbitrary criterion by providing a custom test subroutine. your pattern, your rules ✨


πŸŽ€ METHODS πŸŽ€

  • $patt_bond->test($bond) β€” tests if the pattern bond matches the bond given by $bond. returns true or false. simple, clean, slay.
  • $patt_bond->test_sub(\&my_test_sub) β€” 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 bond and the second is the bond to match. it must return true if there is a match. that's it, that's the contract πŸ”₯
  • $patt_bond->map_to([$bond]) β€” returns or sets the bond that is considered to be matched by $patt_bond. she's a getter and a setter, a true multi-hyphenate πŸ’–

⭐ VERSION ⭐

0.27 β€” yeah she's been around, she's got lore


🌈 SEE ALSO 🌈


πŸ’œ AUTHOR πŸ’œ

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


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.

like, legally speaking: free software, same terms as Perl itself, you know the vibe πŸ’…


real talk though: the legal bits above stay exactly as written, bestie. i'm just here for the vibes, not to rewrite a license 😭

and that's the whole page!! this one came from perl v5.42.0, dated 2026-01-17, and it's filed under Pattern::Bond(3). go forth and match some bonds, you've got this πŸ§šπŸ’–

πŸ“¦ where this page comes from