in reply to Read the config file and create the INVITE line as per config file

use strict; use warnings; use Config::Tiny; my $DATA =<<EOT localusername=me ip=36.212.176.90 port=5060 remotename=you ip=36.212.176.92 port=5060 transport=udp EOT ; # Create a config my $Config = Config::Tiny->new(); # Open the config, replace with read and $DATA with filename $Config = Config::Tiny->read_string( $DATA ); #$Config = Config::Tiny->read( $filename ); # see perldoc Config::Tiny my $s = $Config->{_}; # I was to lazy to finish this: my $INVITE = join(' ', 'INVITE sip:' . $s->{remotename} .'@'. $s->{ip} +, 'SIP/2.0 Via:SIP/2.0/UDP', $s->{localusername} +. '@' . $s->{ip} .':5060', 'From:sam<sip:me@36.212.176.92>', 'To: you<sip:you@36.212.176.90>', ); print $INVITE;
UPDATE: You probably want to add a [local] and a [remote] section in the config file. Then just access the variables with $r = Config->{remote} and build your INVITE line. See perldoc Config::Tiny.
  • Comment on Re: Read the config file and create the INVITE line as per config file
  • Download Code