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


In reply to Missing array values after sub routine? by heezy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.