Last active
August 29, 2015 14:10
-
-
Save pwr22/bf476da4d1fa0460d736 to your computer and use it in GitHub Desktop.
Perl URL path counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use v5.10; use strict; use warnings; | |
my %counts; | |
for my $line (<>) { | |
my $path = (split /\?/, (split / /, $line)[2])[0]; | |
$counts{$path}++ | |
} | |
while (my ($path, $count) = each %counts) { | |
say "$count $path" | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use v5.10; use strict; use warnings; | |
my %counts; | |
for my $line (<>) { | |
# short circuit where possible | |
my $path = (split /\?/, (split / /, $line, 4)[2], 2)[0]; | |
$counts{$path}++ | |
} | |
while (my ($path, $count) = each %counts) { | |
say "$count $path" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment