Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/usr/local/bin/perl -w use strict; use Module::Dependency::Info; # Point this to the data file you created with Module::Dependency::Ind +exer. # See the docs on this module for details. # Tip: to index all of your perl files, run this (thanks merlyn): # indexer.plx -t -b `perl -e 'print "@INC"'` Module::Dependency::Info::setIndex( 'unified.dat' ); use Graph; use Data::Dumper; use Module::CoreList; # This is your autobundle file. open (IN, "<", "") or die "Can't open autobundle file."; # This is the new autobundle file. open (OUT, ">", "") or die "Can't open new bundle file."; my $in_content = 0; my $post_content = 0; my @module_list; my %module_list; my $tail; while( <IN> ){ # Get start of autobundle. unless (/^=head1\s+CONTENTS/ or $in_content ){ print OUT $_; next; } # Get tail of autobundle. if (/^=head1\s+CONFIGURATION/ or $post_content){ $post_content = 1; $tail .= $_; next; } # Get the module list. chomp; $in_content = 1; if (/^\w+/){ my @items = split ' '; $module_list{$items[0]} = $items[1]; push @module_list, $items[0]; } } # Sort the module list. my $listref = Module::Dependency::Info::allItems(); my $g = Graph->new; foreach my $item ( @$listref ){ # My index had a bunch of pls and cgis, so sort them out. next if ($item =~ /\.pl$/); next if ($item =~ /\.cgi$/); my $childref = Module::Dependency::Info::getChildren( $item ); foreach ( @$childref ){ # Skip modules in core. # Remove this line to process core modules. next if ($Module::CoreList::version{ $] }{$item}); $g->add_edge($item, $_); } } # Try to remove remaining cycles, if there are any. my @cycle = $g->find_a_cycle; while (@cycle){ $cycle[1] = $cycle[0] if ( not $cycle[1] ); print "Removing edge $cycle[0], $cycle[1] from graph to prevent cycl +e...\n"; $g->delete_edge($cycle[0], $cycle[1]); @cycle = $g->find_a_cycle; } my @sorted = reverse $g->topological_sort; print OUT "=head1 CONTENTS\n\n"; foreach (@sorted){ print OUT $_ . "\n\n" if exists $module_list{$_}; } print OUT $tail; close IN; close OUT;

In reply to Order your autobundle by dependency by cbrandtbuffalo

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (4)
    As of 2021-02-26 04:35 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found