Opening a random file .pl

From Visual Basic to GNU C, this is the place to talk programming.

Moderators: SecretSquirrel, just brew it!

Opening a random file .pl

Postposted on 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]

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
My Dreamcast PC thread
Main Rig: FX-6100 / Radeon 6950 / Velociraptor HD because old school rotations
pikaporeon
Graphmaster Gerbil
 
Posts: 1312
Joined: Mon Nov 19, 2007 4:42 pm
Location: Mississauga, ON, Canada.

Re: Opening a random file .pl

Postposted on Fri Jan 30, 2009 1:36 am

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.
Matter is merely energy condensed to a slow vibration, we are all one consciousness experiencing itself subjectively, there is no such thing as death, life is only a dream, and we are the imagination of ourselves... back to you with the weather, Bob!
computron9000
Minister of Gerbil Affairs
 
Posts: 2416
Joined: Sun Oct 16, 2005 7:21 pm

Re: Opening a random file .pl

Postposted on Sat Feb 14, 2009 6:32 pm

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.
My Dreamcast PC thread
Main Rig: FX-6100 / Radeon 6950 / Velociraptor HD because old school rotations
pikaporeon
Graphmaster Gerbil
 
Posts: 1312
Joined: Mon Nov 19, 2007 4:42 pm
Location: Mississauga, ON, Canada.

Re: Opening a random file .pl

Postposted on Sun Feb 15, 2009 4:59 am

lol.
Matter is merely energy condensed to a slow vibration, we are all one consciousness experiencing itself subjectively, there is no such thing as death, life is only a dream, and we are the imagination of ourselves... back to you with the weather, Bob!
computron9000
Minister of Gerbil Affairs
 
Posts: 2416
Joined: Sun Oct 16, 2005 7:21 pm

Re: Opening a random file .pl

Postposted on Thu Feb 19, 2009 1:32 pm

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)
i7-920 @ 4.20GHz | Biostar Tpower X58 | 4870 1GB | 3x2 DDR3-1600 OCZ Gold Modules | Windows 7 Ultimate x64 | 4x 1TB Black WD Hard Disk Raid 1
Master Kenobi
Gerbil First Class
 
Posts: 121
Joined: Wed Aug 15, 2007 9:08 am

Re: Opening a random file .pl

Postposted on Wed Feb 25, 2009 6:35 am

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)
My Dreamcast PC thread
Main Rig: FX-6100 / Radeon 6950 / Velociraptor HD because old school rotations
pikaporeon
Graphmaster Gerbil
 
Posts: 1312
Joined: Mon Nov 19, 2007 4:42 pm
Location: Mississauga, ON, Canada.


Return to Developer's Den

Who is online

Users browsing this forum: No registered users and 1 guest