Skip to content

Instantly share code, notes, and snippets.

@xtetsuji
Created June 16, 2024 04:22
Show Gist options
  • Save xtetsuji/c264175485427959c1d1862100105039 to your computer and use it in GitHub Desktop.
Save xtetsuji/c264175485427959c1d1862100105039 to your computer and use it in GitHub Desktop.
Perl feature bundle list from %feature::feature_bundle on curren command perl
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw(say postderef);
use Data::Dumper;
my $table_col_separator = " | ";
my $table_first_row_separator = "| ";
my $table_last_row_separator = " |";
my %bundle_seen;
my %version_bundle_seen; # $version_bundle_seen->{"5.16"}->{"say"} ? "ok" : "ng"
my ($current_minor) = $^V =~ /^v5\.(\d+)/;
my @minors = grep { $_ % 2 == 0 } (10..$current_minor);
my @versions = ("default", map { "5.$_" } @minors);
$version_bundle_seen{$_} = +{} for @versions; # autovivification に頼らない
for my $version ( "default", @versions ) {
my $bundles = $feature::feature_bundle{$version};
$bundle_seen{$_}++ for @$bundles;
$version_bundle_seen{$version}->{$_}++ for @$bundles;
printf "%s: %s\n", $version, join " ", @$bundles;
}
table_row_output("bundle", @versions);
table_row_output( ("----") x (1 + scalar @versions) );
for my $bundle ( sort keys %bundle_seen ) {
table_row_output(
$bundle,
map { $version_bundle_seen{$_}->{$bundle} ? ":ok:" : "" } @versions
);
}
sub table_row_output {
my @rows = @_;
printf "%s%s%s\n",
$table_first_row_separator,
join( $table_col_separator, @rows),
$table_last_row_separator;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment