while (<>) {
    chomp;
    $text = $text.$_;
}

@text = split(" ",$text);

foreach $paraula (@text) {
    $ocurrencies{$paraula}++;
}

@ordenats = sort numerically (values %ocurrencies);

foreach $valor (@ordenats) {
    foreach $paraula (keys %ocurrencies) {
	if ( $ocurrencies{$paraula} == $valor ) {
	    print "$valor $paraula\n";
	}
    }
}

sub numerically { $b <=> $a }
