-
-
Save hitode909/3385268 to your computer and use it in GitHub Desktop.
Perlで音楽
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use IO::Handle; | |
STDOUT->autoflush; | |
while(1) { | |
print "\a"; | |
sleep 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Time::HiRes qw(usleep); | |
use IO::Handle; | |
STDOUT->autoflush; | |
while(1) { | |
print "\a"; | |
usleep 250000; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Time::HiRes qw(usleep); | |
use IO::Handle; | |
sub setup_sound_effect { | |
my $script = <<APPLE_SCRIPT; | |
tell application "System Preferences" | |
activate | |
set current pane to pane "com.apple.preference.sound" | |
end tell | |
APPLE_SCRIPT | |
system "osascript", "-e", $script, "&"; | |
} | |
sub set_sound_effect { | |
my ($i) = @_; | |
my $script = <<APPLE_SCRIPT; | |
tell application "System Events" | |
get properties | |
tell process "System Preferences" | |
set i to $i | |
click radio button 1 of tab group 1 of window 1 | |
set selected of row i of table 1 of scroll area 1 of tab group 1 of window 1 to true | |
end tell | |
end tell | |
APPLE_SCRIPT | |
system "osascript", "-e", $script, "&"; | |
} | |
STDOUT->autoflush; | |
setup_sound_effect(); | |
my $sequence = [2..5]; | |
my $i = 0; | |
while (++$i < 64) { | |
set_sound_effect($sequence->[$i % (scalar(@$sequence))]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use IO::Handle; | |
sub setup_sound_effect { | |
my $script = <<APPLE_SCRIPT; | |
tell application "System Preferences" | |
activate | |
set current pane to pane "com.apple.preference.sound" | |
end tell | |
APPLE_SCRIPT | |
system "osascript", "-e", $script, "&"; | |
} | |
sub set_sound_effect { | |
my ($i) = @_; | |
my $script = <<APPLE_SCRIPT; | |
tell application "System Events" | |
get properties | |
tell process "System Preferences" | |
set i to $i | |
click radio button 1 of tab group 1 of window 1 | |
set selected of row i of table 1 of scroll area 1 of tab group 1 of window 1 to true | |
end tell | |
end tell | |
APPLE_SCRIPT | |
system "osascript", "-e", $script, "&"; | |
} | |
STDOUT->autoflush; | |
setup_sound_effect(); | |
my $sequence = [2..5]; | |
my $i = 0; | |
while (1) { | |
set_sound_effect(int(rand()*14)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment