1
0
.dotfiles/home/bin/openrand

25 lines
489 B
Plaintext
Raw Normal View History

2014-02-28 23:42:51 +00:00
#!/usr/bin/perl -w
# openrand - Opens a random file in the current working directory.
#
# Requires GNOME desktop environment with `gnome-open` command.
#
# --Kirsle
# http://sh.kirsle.net/
use strict;
use warnings;
my @files = ();
opendir (DIR, ".");
foreach my $file (readdir(DIR)) {
next unless -f $file;
next unless -r $file;
push (@files,$file);
}
closedir (DIR);
my $rnd = $files [ int(rand(scalar(@files))) ];
print "Exec gnome-open $rnd\n";
system ("gnome-open \"$rnd\" &");