
# SUMMARY NOTES
# -------------
# => appears only to "scale down" vertically
# => 
#

use strict;
use warnings;

our( $HISTOGRAM_WIDTH, $HISTOGRAM_HEIGHT, $HISTOGRAM_CHAR );

sub histogram {
	my @data;
	if (@_ <= $HISTOGRAM_WIDTH) { @data = @_; }
	else {
		for (my $i = 1; int($i * (scalar(@_) / $HISTOGRAM_WIDTH)) < @_; $i++) 
{
			push @data, $_[int($i * (scalar(@_) / $HISTOGRAM_WIDTH))];
		}
	}
	my $highest = 0;
	foreach (@data) { $highest = $_ if $_ > $highest; }
	my $scale;
	if ($highest <= $HISTOGRAM_HEIGHT) { $scale = 1; }
	else { $scale = int($highest / $HISTOGRAM_HEIGHT); }
	
	my @chart;
	for (my $i = $scale; $i <= $highest; $i += $scale) {
		my $line = '';
		foreach (@data) { $line .= $_ >= $i ? $HISTOGRAM_CHAR : ' '; }
		unshift @chart, $line . "\n";
	}
	return @chart;
}

1;

__END__


Original code also had the lines:

   our($HISTOGRAM_WIDTH, $HISTOGRAM_HEIGHT) = (80, 24);
   our $HISTOGRAM_CHAR = '*';
   print histogram(@ARGV);

plus a shebang.

