Opening a random file .pl
Posted: Fri Jan 16, 2009 9:04 am
Im.. really... new to perl, and I want to make a simple script that will open a file at random in the folder I'm in [it's a folder full of .jpg files + the index.txt]
This is in windows, im not sure how to tell perl to tell windows to open the image with its default program [or even just pass the filename to the command line and run it htat way, as the desired result is the same as just typing "randomed filename.jpg" at the command line.
here's what i've got so far and im not sure where to go from here; i can figure out the random numbers by myself but this is more just trying to get the files accessed
[the index.txt file was formed by dir/b > index.txt]
This is in windows, im not sure how to tell perl to tell windows to open the image with its default program [or even just pass the filename to the command line and run it htat way, as the desired result is the same as just typing "randomed filename.jpg" at the command line.
here's what i've got so far and im not sure where to go from here; i can figure out the random numbers by myself but this is more just trying to get the files accessed
[the index.txt file was formed by dir/b > index.txt]
Code: Select all
$count = 0;
while (defined($line =<>)){ #store all this fun stuff
$lines[$count] = $line;
print "$line";
$count++;
}
print "$lines[1]" # just to see if the array can be accessed