in reply to XML::Twig Question (sorta)
Anno is quite right. Here's a quick explanation.
When you call a subroutine, the arguments are flattened into a list.
sub foo { print("There are ", 0+@_, " args\n"); print("They are @_\n"); } my @a = qw( a b c ); my $n = 123; foo(@a, $n);
There are 4 args They are a b c 123
For this reason, an array reference is usually passed instead of the contents of the array.
foo(\@a, $n);
There are 2 args They are ARRAY(0x1829aec) 123
In your case, it would be
populateEventManifest(\@projectEvents, $eventManFh); # <-- extra \ sub populateEventManifest { my( $events, $eventManFh ) = @_; # <-- scalar foreach my $event (@$events) { # <-- extra $ $event->print($eventManFh); } }
Anno provided an alternative solution.
|
|---|