As mentioned by others already, your ding sub isn't doing anything terribly useful other than returning as an array the length of the first array passed in by reference. What do you purport to use ding for?
use warnings;
use strict;
use 5.012;
use Smart::Comments '###';
my @foo;
sub ding {
@{$_[0]} || ();
}
my @a = qw(apple banana pear grapes);
my @b = qw(lettuce onions);
my @c = qw(popcorn ice-cream);
@foo = ding(\@a, \@b, \@c);
### @foo
#--- Result:
#### @foo: [
#### 4
#### ]
Also, rather than assigning to @foo inside ding and having to rely on the closure (i.e. @foo being defined prior to the sub being defined), why not just return from the sub and assign outside of the sub?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.