use strict; use warnings; use threads; sub getArray { my( $arg1, $arg2, $fn ) = @_; my @array = 'a' .. 'z'; return @array; } sub getHash { my( $arg1, $arg2, $arg3, $fn ) = @_; my( $key, $value ) = ( 'A', 1 ); return map{ $key++ => $value++ } 1 .. 10; } my( $arg1, $arg2, $arg3, $filename ) = @ARGV; ### Note: The function that is run in the thread ### is called in the same context as the call to create. ### If you want the function called in a llist context, ### you must call create in a list context. my( $thrArray ) = threads->create( \&getArray, $arg1, $arg2, $filename ); my( $thrHash ) = threads->create( \&getHash, $arg1, $arg2, $arg3, $filename ); ### Do anything else the main thread needs to do here, *before* calling join. ### The joins will block until their threads complete. ### The values returned by the functions are returned when you join the thread. my @array = $thrArray->join; my %hash = $thrHash->join; print "@array\n"; print map( "$_:$hash{ $_ }, ", sort keys %hash ), $/; __END__ C:\test>533816 One Two Three apath\to\afile a b c d e f g h i j k l m n o p q r s t u v w x y z A:1, B:2, C:3, D:4, E:5, F:6, G:7, H:8, I:9, J:10,