It would have been helpful to point out that lines 212 and 213 are:

my @data = shift; my $loop_count = 0; while (@data) { $data[$loop_count] =~ m{s/^\s*//}xms;#line 212 $data[$loop_count] =~ m{s/\s*$//}xms;#line 213 $loop_count++; }

So first of all, shift gets _one scalar_ off the arguments. You can't pass arrays around like that in Perl, you pass lists. If you call a sub with an array as the argument, it comes in as a list. If you pass in *two* arrays, they get flattened into a single list of scalar arguments. Secondly, in Perl you can iterate over the elements of an array like so:

foreach $element (@array) { do_stuff_to($element); }
so you don't need a loop counter at all. If you *do* need a loop counter (i.e. to synchronize two array walks), you would be better off doing something like
for $index (0..$#array) { # $#array is the last index of @array do_stuff_to($array[$index]); do_stuff_to($other_array[$index]); };

Also your matches appear to be looking for some strange things. The s/// inside the m//, if it even works at all, is operating on $_, not on $data[$loop_count], I believe, which is unlikely to be what you want. m// should contain a regex, not code. s/// is code.


In reply to Re: Returning and passing data to and from subroutines by ssandv
in thread Returning and passing data to and from subroutines by vendion

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.