PPIx::...s::Node(3pm)

πŸ“¦
version 1.001000 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

PPIx::Utilities::Node β€” it's literally Extensions to PPI::Node, bestie. That's the whole vibe. (iykyk, the manpage calls itself PPIx::...s::Node at the top which is just the header being extra and truncating, the real name is right here πŸ’…)


✨ VERSION ✨

This doc describes PPIx::Utilities::Node version 1.1.0. Write it down, she's specific πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

use PPIx::Utilities::Node qw< split_ppi_node_by_namespace >;

my $dom = PPI::Document->new("...");

while (
    my ($namespace, $sub_doms) = each split_ppi_node_by_namespace($dom)
) {
    foreach my $sub_dom ( @{$sub_doms} ) {
        ...
    }
}

okay so that's the whole mood right there πŸ‘‘ you pull in one function, you feed it a PPI::Document, and you just... vibe through the namespaces one at a time. slay.


🌸 DESCRIPTION 🌸

It's giving a collection of functions for dealing with PPI::Nodes. That's it, that's the description, no notes πŸ’–


πŸ’… INTERFACE πŸ’…

Nothing is exported by default. Not one thing. You have to ask for what you want, main character energy only.

🧚 split_ppi_node_by_namespace($node)

Returns the sub-trees for each namespace in the node as a reference to a hash of references to arrays of PPI::Nodes. Yes, a hash of arrayrefs. She's layered. 🫢

So say we've got this code:

#!perl

my $x = blah();

package Foo;

my $y = blah_blah();

{
    say 'Whee!';

    package Bar;

    something();
}

thingy();

package Baz;

da_da_da();

package Foo;

foreach ( blrfl() ) {
    ...
}

Calling this function on a PPI::Document for the above returns a value that looks like this β€” and bestie, heads up, they use multi-line string literals for the actual code parts instead of PPI trees, just to make this easier to read πŸ’€:

{
    main    => [
        q<
            #!perl

            my $x = blah();
        >,
    ],
    Foo     => [
        q<
            package Foo;

            my $y = blah_blah();

            {
                say 'Whee!';

            }

            thingy();
        >,
        q<
            package Foo;

            foreach ( blrfl() ) {
                ...
            }
        >,
    ],
    Bar     => [
        q<
            package Bar;

            something();
        >,
    ],
    Baz     => [
        q<
            package Baz;

            da_da_da();
        >,
    ],
}
⚠️ IMPORTANT ONE, don't skip it: note that the return value contains copies of the original nodes, and not the original nodes themselves, due to the need to handle namespaces that are not file-scoped. (Notice how the first element for "Foo" above differs from the original code. She moved out and got her own apartment. 🏠)

πŸ’€ BUGS AND LIMITATIONS πŸ’€

Please report any bugs or feature requests to "bug-ppix-utilities@rt.cpan.org", or through the web interface at <http://rt.cpan.org>. Do it, the maintainers wanna hear from you fr fr 😭


πŸ‘‘ AUTHOR πŸ‘‘

Elliot Shank "<perl@galumph.com>" β€” legend behavior, honestly. 🫑


Copyright (c)2009-2010, Elliot Shank "<perl@galumph.com>".

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. πŸŽ€


and that's the page bestie!! she was generated by perl v5.36.0 on 2022-11-27, and yes the footer also calls her PPIx::...s::Node(3pm) because the header and footer are both committed to the bit βœ¨πŸ¦‹πŸ’– periodt.

πŸ“¦ where this page comes from