CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [Alain] Random Picture Loading: Edit Log



Paul
Enthusiast

Feb 16, 2002, 10:54 AM


Views: 2195
Re: [Alain] Random Picture Loading

How about just doing something like:

[perl]
opendir DIR, "/some/dir" or die $!;
my @img = grep { /\.(jpg|gif)$/i } readdir(DIR);
closedir DIR;

my $rand = $img[rand @img];
[/perl]

Then $rand has the image name.


(This post was edited by RedRum on Feb 16, 2002, 10:55 AM)


Edit Log:
Post edited by Paul (Enthusiast) on Feb 16, 2002, 10:55 AM
Post edited by Paul (Enthusiast) on Feb 16, 2002, 10:55 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives