in reply to Using array elements as subroutine args
You are passing the argument to the subroutine, but your subroutine is not using it (it is using the uninitialized $item from the file scope). When you pass parameters to a subroutine, those values will be available in the special @_ array within the subroutine. You need to either use the @_element directly ($_[0] in your case), or assign a copy of it to another variable. Try starting your subroutine like:
sub some_sub { my $item = shift; my $string; # rest of subroutine }
Just so you know: the shift() function, when not given an array to shift from will automatically shift from @_ inside of a subroutine, or @ARGV otherwise.
|
|---|