I assume that you mean you want to pass two hashes to a subroutine. You have already been told a few times that this can only be done by passing references. Although it is generally considered bad practice to do so, this fact can be hidden from the calling program by the use of prototypes. Note that the real arguments are converted to references. The subroutine must treat them as such.
use strict; use warnings; use Data::Dumper; sub some_sub (\%\%) { my ($hash_ref1, $hash_ref2) = @_; my %sub_hash1 = %$hash_ref1; my %sub_hash2 = %$hash_ref2; print Dumper( \%sub_hash1, \%sub_hash2 ); } do { my %hash1 = (key_a => 'value_a', key_b =>'value_b'); my %hash2 = (key_c => 'value_c', key_d =>'value_d'); some_sub( %hash1, %hash2 ); # Args appear to be hashes. } OUTPUT: $VAR1 = { 'key_b' => 'value_b', 'key_a' => 'value_a' }; $VAR2 = { 'key_d' => 'value_d', 'key_c' => 'value_c' };
Bill

In reply to Re: Hash user input by BillKSmith
in thread Hash user input by Nansh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.