PPI::To...:Comment(3)

πŸ’¬ PPI::Token::Comment β€” bestie, it's literally just comments πŸ’¬

okay so you're in the PPI docs, that's the Perl Parsing Interface, and this page is all about PPI::Token::Comment β€” a comment living inside Perl source code. that's it. that's the token. she's giving "i'm just a little guy" energy and honestly? iconic. 🌸


🌈 INHERITANCE 🌈

the family tree, no cap:

PPI::Token::Comment
isa PPI::Token
    isa PPI::Element

so she inherits from PPI::Token, which inherits from PPI::Element. nepotism but make it class hierarchy πŸ’…


✨ SYNOPSIS ✨

here's the vibe check β€” some of these are comments and some of them are deceiving you:

# This is a PPI::Token::Comment

print "Hello World!"; # So it this

$string =~ s/ foo  # This, unfortunately, is not :(
      bar
      /w;
warning bestie: that third one? the # inside the s/// substitution? NOT a comment 😭 the parser knows the difference and so should you. rip.

πŸ¦‹ DESCRIPTION πŸ¦‹

so in PPI, comments get represented by PPI::Token::Comment objects. that's the whole thing. she is the moment. ✨

but plot twist: there are two flavours of comment, and you need to know the difference because it actually matters.

  • line comments β€” a comment that stands on its own line, all by herself, main character style. these ones hold their own newline and whitespace (both the leading AND the trailing stuff) as part of the single PPI::Token::Comment object. everything's bundled. she's self-sufficient. 🫢
  • inline comments β€” a comment that shows up after some code and keeps going until the end of the line. this one does not include whitespace, and that terminating newline is considered a separate PPI::Token::Whitespace token. so she's a little more independent than you'd think. πŸ’…

ngl this split is largely a convenience thing β€” it simplifies a LOT of normal code relating to the common stuff people do with comments. lowkey genius.

most commonly, it means: when you prune or delete a comment,

  • a line comment disappears and takes the entire line with it, bye girl πŸ‘‹
  • an inline comment is removed from the inside of the line, and the newline drops back onto the end of the code, exactly as you'd expect it to. ✨

it also means you can move comments around in blocks much more easily. slay.

for now, this is a suitably handy way to do things. however β€” and this is the author being real with you β€” he reserves the right to change his mind on this one if it gets dangerously anachronistic somewhere down the line. so like. noted. πŸ“


πŸ‘‘ METHODS πŸ‘‘

only very limited methods are available here, beyond the ones you already get from your parents β€” PPI::Token and PPI::Element. so don't come in expecting a whole toolbox, bestie. it's giving minimalist. πŸŽ€

πŸ’– line πŸ’–

the line accessor returns true if the PPI::Token::Comment is a line comment, or false if it's an inline comment.

that's the whole method. one boolean. one vibe. periodt. πŸ’…


🫢 SUPPORT 🫢

see the support section in the main module. (yes that's literally all it says, go check the main module, iykyk πŸ’œ)


🌟 AUTHOR 🌟

Adam Kennedy <adamk@cpan.org>


Copyright 2001 - 2011 Adam Kennedy.

this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

the full text of the license can be found in the LICENSE file included with this module.


okay bestie that's the whole page, you ate that, go forth and parse comments responsibly πŸ§šβ€β™€οΈπŸ’– this was PPI::Token::Comment(3) from perl v5.42.0, dated 2026-01-17 β€” part of the User Contributed Perl Documentation. mwah. πŸŽ€βœ¨πŸ”₯

πŸ“¦ where this page comes from