I think something like this would work for you.

my %test;
map { my ($fn,$val) = split(/=/,$_,2); $test{$fn}=$val;} split(/\n/, $test);

I noticed some of your values had equal signs in them, so in the inside
split, I also specified you wanted 2 values so that you receive the full
expected value back.

Hope this helps.

-Dave


On 4/29/07, Goksie <[EMAIL PROTECTED]> wrote:

hello,

Can someone help me correct this code.

if i print, it only print the first line.

Goksie

#!/usr/bin/perl
use strict;

my $test =
        'NAS-IP-Address = 192.168.42.1
    Quintum-NAS-Port = "0 0/0/c1dc2a26"
    NAS-Port-Type = Async
    User-Name = "192.168.42.8"
    Called-Station-Id = "8600508208079"
    Calling-Station-Id = ""
    Acct-Status-Type = Stop
    Acct-Delay-Time = 0
    Acct-Input-Octets = 0
    Acct-Output-Octets = 0
    Acct-Session-Id = "000000C0000012F5"
    Acct-Session-Time = 245
    Acct-Input-Packets = 0
    Acct-Output-Packets = 0
    Service-Type = Login-User
    Quintum-AVPair = "h323-ivr-out=ACCESSCODE:8600508208079"
    Quintum-h323-conf-id = "34363262 65383833 32656366 00340000"
    Quintum-AVPair = "h323-incoming-conf-id=34363262 65383833 32656366
00340000"
    Quintum-h323-gw-id = "ng-la"
    Quintum-h323-call-origin = "answer"
    Quintum-h323-call-type = "VoIP"
    Quintum-h323-setup-time = "22:58:10.220 UTC Sun Apr 22 2007"
    Quintum-h323-connect-time = "22:59:09.550 UTC Sun Apr 22 2007"
    Quintum-h323-disconnect-time = "22:59:09.550 UTC Sun Apr 22 2007"
    Quintum-h323-remote-address = "192.168.42.8"
    Quintum-h323-disconnect-cause = "1f"
    Quintum-h323-voice-quality = "0"
    Quintum-Trunkid-In = "192.20.42.8"
    Quintum-Trunkid-Out = "10.15.115.79"
    h323-incoming-conf-id = "34363262 65383833 32656366 00340000"
    Client-IP-Address = 192.168.42.1
    Acct-Unique-Session-Id = "87d380e1881d226c"
    Timestamp = 1177282824';

   my %test = my($fname, $fvalu)=split(/=/, $test);
       foreach(keys %test)
        {
         print "$_ --- $test{$_}";
     }

OUTPUT
NAS-IP-Address  ---  192.168.42.1
Quintum-NAS-Port  ---



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/



Reply via email to