heezy has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I have a perl script that passes an array into a sub routine ( &viewThumbnails(@files) ) The array has the following elements in the showAllFiles() subroutine...
(output from browser $cgi output)
./pics ./pics/0001-20021005-005-002-002-001013007-Me_in_some_snow_somewhere.j +pg ./pics/0003-20021101-004-003-002-001-Me_ontop_of_flat_top_mountain.jpg ./pics/0000-20020918-001-005-003-013011005-Me_in_a_bush.jpg
However once I have passed @files into "&viewThumbnails(@files)" the array only contains...
(output from browser $cgi output)
./pics
What am I missing here? The first element of the array has been passed to the subroutine but nothing else? Thats crazy!
Here's a few code snipets to help...
sub showAllFiles{ &printHeader("Displaying All Files"); @files = (); find(sub{push @files, $File::Find::name}, $picPath); foreach $file (@files){ print $cgi->p("$file"); } &viewThumbnails(@files); } $numCols = 4; sub viewThumbnails{ @filesToDisplay = @_[0]; foreach $file (@filesToDisplay){ print $cgi->p("$file"); } $count = 0; print "\n<table>\n"; print " <tr>\n"; foreach $file (@filesToDisplay){ if ($count = $numCols){ $count = 0; print " <\/tr>\n"; print " <tr>\n"; print " <td><img src=\"$file\"><\/td>\n"; }else{ $count++; print " <td><img src=\"$file\"><\/td>\n"; } } print " <\/tr>\n"; print "<\/table>\n"; }
The two subroutines are in different perl scripts but are being related by...
use lib('.'); require 'viewThumbnails.pl';
But I don't think this is breaking it. Just though I should mention it incase I'm missing something obvious.
Thanks for reading this far!
Any help is much appreciated
M
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Missing array values after sub routine?
by Mr. Muskrat (Canon) on Nov 15, 2002 at 23:35 UTC | |
by heezy (Monk) on Nov 15, 2002 at 23:38 UTC | |
|
Re: Missing array values after sub routine?
by Zaxo (Archbishop) on Nov 15, 2002 at 23:36 UTC | |
by heezy (Monk) on Nov 15, 2002 at 23:41 UTC | |
|
Re: Missing array values after sub routine?
by Enlil (Parson) on Nov 15, 2002 at 23:39 UTC | |
|
Re: Missing array values after sub routine?
by janjan (Beadle) on Nov 16, 2002 at 01:10 UTC | |
|
Re: Missing array values after sub routine?
by robartes (Priest) on Nov 15, 2002 at 23:39 UTC |