Perl初试

通过接口发送短信的socket小样:

#!/usr/bin/perl -w
# auth:lichmama@cnblogs.com
# what:send message to phone
# usage: sms.pl [phonenumber] [text] use strict;
use Socket; if(scalar @ARGV != ){
die "Usage: sms.pl [phonenumber] [text]\n";
} my $phone = $ARGV[];
my $text = $ARGV[]; my $sms_host = "xxx.xxx.xxx.xxx";
my $sms_port = ; socket(SOCK, AF_INET, SOCK_STREAM, getprotobyname("tcp"))
or die "Error: cannot create socket\n";
connect(SOCK, sockaddr_in($sms_port, inet_aton($sms_host)))
or die "Error: cannot connect sms server\n";
send(SOCK, "$phone||$text", )
or die "Error: an unexpected exception occurred when sending message\n"; close(SOCK);
上一篇:FILE不是C语言关键字


下一篇:20165214 2017-2018-2 《Java程序设计》课程总结