zoukankan      html  css  js  c++  java
  • perl 中的面向对象多继承

     perl 面向对象继承:
    [root@jxglapp1 pfwx-master]# pwd
    /root/pfwx-master
    
    
    use lib "./lib";
    use mojo::Client;
    use Data::Dumper;
    use Mojolicious::Lite;
    use JSON qw/encode_json decode_json/;  
    use Encode;
    no strict;
    no warnings;
    use JSON; 
    use POSIX;
    use JSON::RPC::Client;
    use Data::Dumper;
    use URI::Escape;
    use DBI; 
    my $dbName = 'serv';  
    my $dbUser = 'SMSsendx';  
    my $dbUserPass = 'SMSsendx';
    #my $dbh = DBI->connect("dbi:Oracle:$dbName", $dbUser, $dbUserPass) or die "can't connect to database " ;
    my $client = mojo::Client->new();
      print Dumper($client);
      get '/api/SMSsendx' => sub {
       my $c = shift;
       #my $sourceip=$c->param('sourceip');
       my $message = $c->param('message');
          print "Length1==";
          print length($message)."
    "; 
          $sms=$message;
          ##utf-8 flag
          my $flag=Encode::is_utf8($message);
          print "$flag===$flag
    ";
          if ($flag)
              { 
             Encode::_utf8_off($message);
             print "Length2==";
             print length($message)."
    ";
             $sms=encode_utf8($sms);
             $sms=encode("gbk",decode("utf8",$sms)) }
          else
              {$message=encode("utf8",decode("gbk",$message)) };
               
          #$message=encode_utf8($message);g===$flag
    ";
          my $phone = $c->param('phone');
          my @phone= split(/|/,$phone);
          $client->SMSsendx("$sms",@phone);
          #mojo::Client::LoadDb::insertdb(1,$sourceip,$message,$phone);
          #$client->insertdb($sourceip,$message,$phone);
         $c->render(json =>{retcode,0000});
           };
    
          get '/api/SMSinfo' => sub {
          my $c=shift;
          my $sourceip=$c->param('sourceip');
          my @arr=$client->SMSinfo($sourceip);
            $c->render(json =>@arr);
           };
      app->start;
      
      ------------------------------------------------------------------------
      [root@jxglapp1 pfwx-master]# cat lib/mojo/Client.pm 
    package mojo::Client;
    use base qw(
        mojo::Client::SMSsendx
        mojo::Client::LoadDb
       
    );
    
    our $VERSION = "1.0";
    sub new{
        my $class = shift;
            my $self= {
            client_version          => $VERSION
            };
            bless $self,$class;
           return $self;
    };
    1;
    
    
    让 mojo::Client 去继承 mojo::Client::SMSsendx
    
    
    [root@jxglapp1 pfwx-master]# cat lib/mojo/Client/SMSsendx.pm
    package mojo::Client::SMSsendx;
        use IO::Socket::INET;
        use Data::Dumper;
        use Encode;
    sub SMSsendx {
       my $self=shift;
       my $message=shift;
       my $refphone=shift;
       # print "sock$message is $message
    ";
       foreach $phone (@{$refphone}){ 
        $|=1;
        $sock = IO::Socket::INET->new(PeerAddr => '10.3.229.1',
                                       PeerPort => '745',
                                       Proto=>'tcp'
                                   ) or die "$!
    ";
       my $data="";
       my $tab=chr(9);
    

  • 相关阅读:
    POJ-2456(二分+贪心)
    二分的神奇边界
    最大值最小化
    HDU6231(二分+尺取)
    POJ 1321
    document操作例题1-延迟注册与二级菜单
    DOM2-document操作
    DOM1-基本概念及window操作
    函数递归调用
    JS基础4-函数
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349456.html
Copyright © 2011-2022 走看看