in reply to Passing Hash to Subroutine

Your two biggest problems are:
  1. fubar()'s argument passing is really messed up. fubar() expects a plain hash, but you pass it a ref to a ref to a hash. One side or the other needs to be fixed. (Data::Dumper could have shown you this in two seconds.)

  2. Your foreach loop does the same thing in both passes. You need to assign the array elements to a temporary variable, and then use that variable in the loop. The default temporary variable is $_, but you can make it whatever you want using "foreach $temp (LIST) BLOCK".
Some other comments, in no particular order:

You need to read perldoc perlreftut, but also perldoc perlsub (argument passing conventions) and perldoc perlsyn (foreach syntax).

Here is the fixed code. Notice how you can tell what the subroutines will do -- by their names -- before you even read them.

#!/bin/perl use strict; use warnings; my @items = init_items(); print "Printing the array ...\n"; foreach my $item (@items) { print_items($item); } ###################### sub init_items { return ( { id => 1, status => 0, loc => 'awx1', }, { id => 2, status => 1, loc => 'xxx1', }, ); } sub print_items { my $item = shift; print "Thread <$item->{id}>, status <$item->{status}>, location <$ +item->{loc}>\n"; }