#!/usr/bin/perl -w use 5.030; my $opt; decision: print "Do you want small number of firms index of concentration [H] or a [B]ig number of firms index: "; chomp (my $r = ); if ($r =~ /[Bb]/) { $opt = 2; big(); }elsif ($r =~ /[Hh]/) { $opt = 1 ; Herfindahl(); }else{ goto decision; } say "Remember that all oligopoly carry inside the seed of its destruction."; exit 1; sub big { n: print "Enter the number of firms in the sector: "; chomp (my $n = ); goto n if (0+$n ne $n); V: print "Enter the variance of market quota of a normal firm: "; chomp (my $V = ); goto V if (0+$V ne $V); my $result = 1/$n + $n * $V; say "The aproximate H index is $result"; if ($result >= 1800){ say "Begin to bother!"; }else{ print "Begin to bother if variance goes up ", (1800-1/$n)/$n, "\n"; } } sub Herfindahl { say "Enter the quota of the market in % number of the big firms, separated by spaces: "; chomp ($r = ); my @q = split /\s+/, $r; my $sum; for my $i (@q){ $sum += $i*$i if (0+$i eq $i); } say "The minimun HH index is $sum"; say "Begin to bother!" if ($sum >= 1800); } __END__ Search more info in the wikipedia.