#!/usr/bin/perl -w use strict; my %octave = ('A', '-', 'A#', '-', 'B', '-', 'C', '-', 'C#', '-', 'D', '-', 'D#', '-', 'E', '-', 'F', '-', 'F#', '-', 'G', '-', 'G#', '-'); my @strings = ('G', 'D', 'A', 'E'); my @notes = @ARGV; my $note; foreach $note (@notes) { $note = uc($note); if($note =~ /^([A-G])B$/) { if($1 eq "A") { $note = "G#"; } else { $note = chr(ord($1) - 1) . "#"; } } $octave{$note} = $note; } my @octave_old = sort keys %octave; my @octave_new = (); foreach (@octave_old) { push(@octave_new, $octave{$_}); } print " 0 1 2 3 4 5 6 7 8 9 10 11 12\n"; foreach $note (@strings) { while ($note ne $octave_old[0]) { push(@octave_new, shift(@octave_new)); push(@octave_old, shift(@octave_old)); } foreach $note (@octave_new) { print "| $note "; if ($note !~ /[#&]/) { print " "; } } print "| $octave_new[0]\n"; }