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 thes///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::Commentobject. 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::Whitespacetoken. 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 π
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
- fedora 44: perl-PPI 1.284-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