#!/usr/bin/perl # Usage: count_descending.pl digits.txt while (<>) { foreach $n (/ (\d\d\d\d\d)/g) { $d1=int($n/10000); $d2=int($n/1000)%10; $d3=int($n/100)%10; $d4=int($n/10)%10; $d5=$n%10; if ($d1>$d2 && $d2>$d3 && $d3>$d4 && $d4>$d5) { ++$count; } } } print $count;