Advertisement
Guest User

sample

a guest
Oct 23rd, 2011
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.37 KB | None | 0 0
  1.  
  2. my @scores = 'Ana' => 8, 'Dave' => 6, 'Charlie' => 4, 'Beth' => 4;
  3.  
  4. my $screen-width = 30;
  5.  
  6. my $label-area-width = 1 + [max] @scores».key».chars;
  7. my $max-score = [max] @scores».value;
  8. my $unit = ($screen-width - $label-area-width) / $max-score;
  9. my $format = '%-' ~ $label-area-width ~ "s%s\n";
  10.  
  11. for @scores {
  12.     printf $format, .key, 'X' x ($unit * .value);
  13. }
  14.  
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement