caciqueman has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w print "Content-type: text/html\n\n"; $dir = "/home/usr/public/images/"; $view = "view.html"; $number_to_show = 15; $title = "Your Title Could Go Here"; srand( time() ^ ($$ + ($$ << 15)) ); opendir DIR, "$dir"; my @arr = grep -f, grep /\.jpg$/i, map "$dir/$_", readdir DIR; $n = @arr; foreach (reverse 0..$n) { my $pic = splice(@arr, rand $n, 1); push @arr, $pic; $#arr = $number_to_show; } &print_it(); sub print_it { open (PAGE, "$dir$view") || die ("I am unable to open the template $vi +ew"); while (<PAGE>) { s/%%title%%/$title/g; s/%%images%%/@arr/g; print $_; } close (PAGE); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: array problem
by gav^ (Curate) on Mar 15, 2002 at 02:03 UTC | |
|
Re: array problem
by Trimbach (Curate) on Mar 15, 2002 at 02:18 UTC | |
|
Re: array problem
by dws (Chancellor) on Mar 15, 2002 at 02:44 UTC | |
|
Re: array problem
by particle (Vicar) on Mar 15, 2002 at 05:17 UTC | |
|
Re: array problem
by YuckFoo (Abbot) on Mar 15, 2002 at 14:18 UTC | |
|
Re: array problem
by grummerX (Pilgrim) on Mar 15, 2002 at 18:19 UTC |