use DB_File ; my  %hash;      unlink "tempfile"; #Remove previous file, if any tie %hash, "DB_File", "tempfile", O_RDWR|O_CREAT, 0666, $DB_HASH       or die "Cannot open file 'tempfile': $!\n"; while($sourceString =~ /example(key)regex(value)example\b/ig ) {      my $key = $1;      my $value = $2;      push( @{ $hash{ $key } },  $value );  #Push the value into the hash }