25 lines
489 B
Plaintext
25 lines
489 B
Plaintext
|
#!/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\" &");
|