0

Suppose, I have 2 cases one is for sms and another for mail. I need to send a message in both cases. Now, for sending sms I use the following xml.

my $addxml="<tolist><to>";
$addxml=$addxml."<name>".$name."</name>";
$addxml=$addxml."<contactpersonname>".$name."</contactpersonname>";
$addxml=$addxml."<number>".$number."</number>";
$addxml=$addxml."</tolist></to>"

Now, for sending the email, I will be using the same xml except that instead of number I use email tag.

my $addxml="<tolist><to>";
$addxml=$addxml."<name>".$name."</name>";
$addxml=$addxml."<contactpersonname>".$name."</contactpersonname>";
$addxml=$addxml."<email>".$email."</email>";
$addxml=$addxml."</tolist></to>"

How can I write a subroutine in perl that is going to use the above xml once but change the tags (number and email) whenever necessary for sms or email.

4

2 に答える 2