use strict; my $msg= "INVITE sip:paka@36.212.176.92 SIP/2.0 To:samir <sip:paka@36.212.176.92> Via: SIP/2.0/udp 36.212.176.90:5060;branch=z9hG4bk_Vn Via: SIP/2.0/udp 36.212.176.66:5060;branch=z9hG4bk_oo From: sanjay<sip:sanjay@36.212.176.90> Call-ID: _Vn8TZTk2H@36.212.176.90 CSeq: 215 INVITE Max-Forwards: 70 Contact: sanjay<sip:sanjay@36.212.176.90:5060>"; my @fields = split /\n/, $msg; my %config = ( URI => { regex => qr/^INVITE\ssip:/}, To => { regex => '^To:'}, From => { regex => '^From:'}, Via => { regex => '^Via:'}, Via1 => { regex => '^Via:'}, Call_ID => { regex => '^Call-ID:'}, CSeq => { regex => '^CSeq:'}, MaxForwards => { regex => '^Max-Forwards:'}, Contact => { regex => '^Contact:'}, ); my %cnf; foreach (@fields) { chomp; foreach my $c (keys %config) { if (/$config{$c}{regex}/) { $cnf{$c} = $_; last; } } }
How can i store two Via in the two keys(Via and Via1) of hash. So that when i will give
print $cnf{Via};
It prints
Via: SIP/2.0/udp 36.212.176.90:5060;branch=z9hG4bk_Vn
When i will give
print $cnf{Via1};
It prints
Via: SIP/2.0/udp 36.212.176.66:5060;branch=z9hG4bk_oo

2006-10-12 Retitled by g0n, as per Monastery guidelines
Original title: 'How can I do it?'


In reply to How can I store two values with the same key in a hash? by sanjay nayak

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.