randomfox: (Default)
[personal profile] randomfox
#!perl -w
use strict;

use FileHandle;
use File::DosGlob;

sub glob_args {
    map { File::DosGlob::glob $_ } @_;
}

sub write_file {
    my ($fname, $lbound, $ubound, $allviews) = @_;

    my $fh = new FileHandle $fname, "w";
    defined $fh or die "Can't open $fname for writing: $!\n";

    my $lineno = 0;

    for (grep {$_->{views}>=$lbound and $_->{views}<=$ubound} @$allviews) {
	++$lineno;
	local $_ = $_->{line};
	s/^\d+\./$lineno./;
	print $fh $_;
    }

    close $fh;
}

@ARGV = glob_args @ARGV;

my @allviews;

while (<>) {
    /<b>(\d+)<\/b> views/ or next;
    push @allviews, { views=>$1, line=>$_ };
}

@allviews = sort { $a->{views} <=> $b->{views} } @allviews;

write_file "1to25.htm", 1, 24, \@allviews;
write_file "25to50.htm", 25, 49, \@allviews;
write_file "50to75.htm", 50, 74, \@allviews;
write_file "75to100.htm", 75, 99, \@allviews;
write_file "centurian.htm", 100, 199, \@allviews;

__END__

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

randomfox: (Default)
randomfox

November 2012

S M T W T F S
    123
45678910
11121314151617
18192021222324
25262728 2930 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 10th, 2026 09:56 pm
Powered by Dreamwidth Studios