Page 1 of 1

Opening a random file .pl

Posted: Fri Jan 16, 2009 9:04 am
by pikaporeon
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]

$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

Re: Opening a random file .pl

Posted: Fri Jan 30, 2009 1:36 am
by computron9000
Why?

Maybe this? I have no idea.

#!/usr/bin/perl
print "Content-Type: text/html\n\n";
$ExecString = 'C:\*image viewer*.exe -something imagename.jpg
exec $ExecString;

http://forums.codewalkers.com/server-ad ... 84128.html

hope this stuff helps. no idea what you're doing.

Re: Opening a random file .pl

Posted: Sat Feb 14, 2009 6:32 pm
by pikaporeon
ehhh its a bit embarassing

Friend wanted me to write a program to pick which adult image he had in a folder to open. I thought it was a strange idea so i gave it a shot


Windows 7's random slideshow i figure has made this obsolete lol.

Re: Opening a random file .pl

Posted: Sun Feb 15, 2009 4:59 am
by computron9000
lol.

Re: Opening a random file .pl

Posted: Thu Feb 19, 2009 1:32 pm
by Master Kenobi
I'm not sure about perl, but in all other programming languages, since Windows uses an association system, you simply need to execute the JPEG file. Upon recieving an execution request for the JPEG, it would open it in the program that currently controls the JPEG extension. Does that help you?

(Disclaimer: I think perl sucks :P)

Re: Opening a random file .pl

Posted: Wed Feb 25, 2009 6:35 am
by pikaporeon
Master Kenobi wrote:
I'm not sure about perl, but in all other programming languages, since Windows uses an association system, you simply need to execute the JPEG file. Upon recieving an execution request for the JPEG, it would open it in the program that currently controls the JPEG extension. Does that help you?

Thats what I thought too
(Disclaimer: I think perl sucks :P)

Dont make fun of my chainsaw!

(Perl I like via rationalizing the familiar. I got started with java and the C-based syntax makes me feel at home)