Goksie 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 ---
Hope this helps,
Rob
my %test = $test =~ /( "[^"]+" | [^=\s]+ )/gx;
foreach (keys %test) {
print "$_ --- $test{$_}\n";
}
**OUTPUT**
NAS-Port-Type --- Async
Quintum-NAS-Port --- "0 0/0/c1dc2a26"
Acct-Unique-Session-Id --- "87d380e1881d226c"
Called-Station-Id --- "8600508208079"
Quintum-h323-voice-quality --- "0"
Quintum-h323-remote-address --- "192.168.42.8"
Client-IP-Address --- 192.168.42.1
Quintum-h323-setup-time --- "22:58:10.220 UTC Sun Apr 22 2007"
Acct-Status-Type --- Stop
Acct-Output-Packets --- 0
Quintum-h323-disconnect-cause --- "1f"
NAS-IP-Address --- 192.168.42.1
Acct-Output-Octets --- 0
Acct-Session-Time --- 245
h323-incoming-conf-id --- "34363262 65383833 32656366 00340000"
Quintum-AVPair --- "h323-incoming-conf-id=34363262 65383833 32656366 00340000"
Timestamp --- 1177282824
User-Name --- "192.168.42.8"
Acct-Input-Packets --- 0
Acct-Input-Octets --- 0
Acct-Session-Id --- "000000C0000012F5"
Service-Type --- Login-User
Quintum-h323-gw-id --- "ng-la"
Quintum-h323-call-type --- "VoIP"
Quintum-Trunkid-Out --- "10.15.115.79"
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-Trunkid-In --- "192.20.42.8"
Calling-Station-Id --- ""
Quintum-h323-call-origin --- "answer"
Quintum-h323-conf-id --- "34363262 65383833 32656366 00340000"
Acct-Delay-Time --- 0
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/