Changeset 29

Show
Ignore:
Timestamp:
04/23/07 13:41:28 (2 years ago)
Author:
root
Message:

Improve and optimize perl splits. Use warnings pragma instead of -w.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/op_server.pl

    r28 r29  
    1 #!/usr/bin/perl -w 
     1#!/usr/bin/perl 
    22 
    33#  Flash Operator Panel.    http://www.asternic.org 
     
    2222 
    2323use strict; 
     24use warnings; 
    2425use integer; 
    2526 
     
    644645 
    645646    if ( $tipo eq "buttons" ) { 
    646         if ( ! grep {$filename eq $_} @btninclude ) { 
     647        if ( !grep { $filename eq $_ } @btninclude ) { 
    647648            push( @btninclude, $filename ); 
    648649        } 
     
    653654    } 
    654655    if ( $tipo eq "style" ) { 
    655         if ( ! grep {$filename eq $_} @styleinclude ) { 
     656        if ( !grep { $filename eq $_ } @styleinclude ) { 
    656657            push( @styleinclude, $filename ); 
    657658        } 
     
    15061507            my $contextoboton = $key; 
    15071508            if ( $contextoboton =~ m/\@/ ) { 
    1508                 my @parte = split( /\@/, $contextoboton, 2 ); 
    1509                 $contextoboton = $parte[1]; 
     1509                ($contextoboton) = split( /\@/, $contextoboton, 2 ); 
    15101510                $contextoboton =~ tr/a-z/A-Z/; 
    15111511            } 
     
    15251525            my $contextoboton = $key; 
    15261526            if ( $contextoboton =~ m/\@/ ) { 
    1527                 my @parte = split( /\@/, $contextoboton, 2 ); 
    1528                 $contextoboton = $parte[1]; 
     1527                ($contextoboton) = split( /\@/, $contextoboton, 2 ); 
    15291528                $contextoboton =~ tr/a-z/A-Z/; 
    15301529            } 
     
    15441543                my $contextoboton = $key; 
    15451544                if ( $contextoboton =~ m/\@/ ) { 
    1546                     my @parte = split( /\@/, $contextoboton, 2 ); 
    1547                     $contextoboton = $parte[1]; 
     1545                    ($contextoboton) = split( /\@/, $contextoboton, 2 ); 
    15481546                    $contextoboton =~ tr/a-z/A-Z/; 
    15491547                } 
     
    15641562                my $contextoboton = $key; 
    15651563                if ( $contextoboton =~ m/\@/ ) { 
    1566                     my @parte = split( /\@/, $contextoboton, 2 ); 
    1567                     $contextoboton = $parte[1]; 
     1564                    ($contextoboton) = split( /\@/, $contextoboton, 2 ); 
    15681565                    $contextoboton =~ tr/a-z/A-Z/; 
    15691566                } 
     
    15841581                my $contextoboton = $key; 
    15851582                if ( $contextoboton =~ m/\@/ ) { 
    1586                     my @parte = split( /\@/, $contextoboton, 2 ); 
    1587                     $contextoboton = $parte[1]; 
     1583                    ($contextoboton) = split( /\@/, $contextoboton, 2 ); 
    15881584                    $contextoboton =~ tr/a-z/A-Z/; 
    15891585                } 
     
    21812177    # Removes the context if its set 
    21822178 
    2183     my @pedazos = split( /&/, $canal ); 
    2184     $canal = $pedazos[0]; 
     2179    ($canal) = split( /&/, $canal ); 
    21852180 
    21862181    # Checks if the channel name has an equal sign 
     
    22332228    my $server  = ""; 
    22342229 
    2235     my @pedazos = split( /&/, $canal ); 
    2236     $canal = $pedazos[0]; 
     2230    ($canal) = split( /&/, $canal ); 
    22372231 
    22382232    if ( $canal =~ /\^/ ) { 
    2239         @pedazos = split( /\^/, $canal ); 
    2240         $server  = $pedazos[0]; 
    2241         $canal   = $pedazos[1]; 
     2233        ( $server, $canal ) = split( /\^/, $canal ); 
    22422234    } 
    22432235 
     
    22762268    print_datos(1); 
    22772269 
    2278     my @pedazos = split( /&/, $canal ); 
    2279     $canal = $pedazos[0]; 
     2270    ($canal) = split( /&/, $canal ); 
    22802271 
    22812272    if ( $canal =~ /\^/ ) { 
    2282         @pedazos = split( /\^/, $canal ); 
    2283         $server  = $pedazos[0]; 
    2284         $canal   = $pedazos[1]; 
     2273        ( $server, $canal ) = split( /\^/, $canal ); 
    22852274    } 
    22862275 
     
    27402729        while ( my ( $key, $val ) = each(%hash_temporal) ) { 
    27412730            if ( defined($val) && $val =~ /\^/ ) { 
    2742                 my @partes = split( /\^/, $val, 2 ); 
    2743                 $hash_temporal{$key} = $partes[0]; 
    2744                 my $resto_de_parametros = $partes[1]; 
    2745                 @partes = split( /\^/, $resto_de_parametros ); 
     2731 
     2732                #my @partes = split( /\^/, $val, 2 ); 
     2733                #$hash_temporal{$key} = $partes[0]; 
     2734                #my $resto_de_parametros = $partes[1]; 
     2735                ( $hash_temporal{$key}, my $resto ) = split( /\^/, $val, 2 ); 
     2736                my @partes = split( /\^/, $resto ); 
    27462737                foreach my $value (@partes) { 
    27472738                    my @partes2 = split( /: /, $value ); 
     
    28032794    if ( defined( $hash_temporal{"ActionID"} ) ) { 
    28042795        if ( $hash_temporal{"ActionID"} =~ /^timeout/i ) { 
    2805             ($canalid, $timeout) = split( /\|/, $hash_temporal{"ActionID"} ); 
     2796            ( $canalid, $timeout ) = split( /\|/, $hash_temporal{"ActionID"} ); 
    28062797            $evento   = "Timeout"; 
    28072798            $unico_id = "YYYY-$server"; 
     
    29982989 
    29992990            if ( $tempval =~ m/\@/ ) { 
    3000                 my @partes = split( /\@/, $tempval, 2 ); 
    3001                 $dst_exten   = $partes[0]; 
    3002                 $dst_context = $partes[1]; 
     2991                ( $dst_exten, $dst_context ) = split( /\@/, $tempval, 2 ); 
    30032992            } 
    30042993            else { 
     
    47014690 
    47024691            for ( keys %datos ) { 
    4703                 my $ignorame       = 0; 
    4704                 my @pedazote       = split( /-/, $_ ); 
    4705                 my $current_server = $pedazote[1]; 
     4692                my $ignorame = 0; 
     4693                my ($current_server) = split( /-/, $_ ); 
    47064694                if ( "$server" ne "$current_server" ) { 
    47074695                    next; 
     
    64606448 
    64616449        # The closed connections belong to an asterisk manager port 
    6462         my @partes  = split( /\|/, $manager_socket{$socket} ); 
    64636450        my @pp      = (); 
    64646451        my $counter = 0; 
     
    71127099                @pedazos = split( /&/, $canal ); 
    71137100                $origin_context = $pedazos[1]; 
    7114                 my @pedazos2 = split( /\^/, $pedazos[0] ); 
    7115                 $origin_server  = $pedazos2[0]; 
    7116                 $origin_channel = $pedazos2[1]; 
     7101                ( $origin_server, $origin_channel ) = split( /\^/, $pedazos[0] ); 
    71177102            } 
    71187103            else { 
    7119                 my @pedazos2 = split( /\^/, $canal ); 
    7120                 $origin_server  = $pedazos2[0]; 
    7121                 $origin_channel = $pedazos2[1]; 
     7104                ( $origin_server, $origin_channel ) = split( /\^/, $canal ); 
    71227105            } 
    71237106        } 
     
    72807263                if ( $destino ne "0" ) { 
    72817264                    log_debug( "$heading destino es igual a $destino", 32 ) if DEBUG; 
    7282                     my @pedazos2 = split( /\^/, $destino ); 
    7283                     $destin_server = $pedazos2[0]; 
    7284                     $destino       = $pedazos2[1]; 
    7285                     ( $destino, my $nada ) = split( /\&/, $pedazos2[1] ); 
     7265                    ( $destin_server, $destino ) = split( /\^/, $destino ); 
     7266                    ($destino) = split( /\&/, $destino ); 
    72867267                    log_debug( "$heading El boton de destino es $destino en el server $destin_server", 64 ) if DEBUG; 
     7268                    print("$heading El boton de destino es $destino en el server $destin_server\n"); 
    72877269                } 
    72887270            } 
     
    75317513                if ( $canal_destino ne "-1" ) { 
    75327514                    if ( $canal_destino =~ /\@/ ) { 
    7533                         @pedazos       = split( /\@/, $canal_destino ); 
    7534                         $canal_destino = $pedazos[0]; 
    7535                         $contexto      = $pedazos[1]; 
     7515                        ( $canal_destino, $contexto ) = split( /\@/, $canal_destino ); 
    75367516                    } 
    75377517 
     
    76297609 
    76307610                    if ( $extension_destino =~ /\@/ ) { 
    7631                         @pedazos           = split( /\@/, $extension_destino ); 
    7632                         $extension_destino = $pedazos[0]; 
    7633                         $contexto          = $pedazos[1]; 
     7611                        ( $extension_destino, $contexto ) = split( /\@/, $extension_destino ); 
    76347612                    } 
    76357613 
     
    83188296            my $estado = substr( $valor, $statPos ); 
    83198297            $valor =~ s/\s+/ /g; 
    8320             my @parametros = split( " ", $valor ); 
    8321             my $interno    = $parametros[0]; 
     8298            my ( $interno, $dirip ) = split( " ", $valor ); 
    83228299 
    83238300            if ( $interno =~ /\// ) { 
    8324                 my @partecitas = split( /\//, $interno ); 
    8325                 $interno = $partecitas[0]; 
    8326             } 
    8327             my $dirip = $parametros[1]; 
     8301                ($interno) = split( /\//, $interno ); 
     8302            } 
    83288303 
    83298304            if ( defined($estado) && $estado ne "" ) { 
     
    84128387            $valor =~ s/\s+/ /g; 
    84138388            if ( $valor eq "" ) { next; } 
    8414             my @parametros = split( " ", $valor ); 
    8415             my $interno    = $parametros[0]; 
    8416             my $dirip      = $parametros[1]; 
    8417             $interno =~ s/(.*)\/(.*)/$1/g; 
     8389            my ( $interno, $dirip ) = split( " ", $valor ); 
     8390            ( $interno, undef ) = split( /\//, $interno ); 
    84188391 
    84198392            if ( defined($interno) ) { 
     
    86248597        if ( defined($_) && $_ ne "" ) { 
    86258598            log_debug( "$heading Enviando status a " . $ip_addy{$_}, 16 ) if DEBUG; 
    8626             my @pedazos = split( /\|/, $manager_socket{$_} ); 
    8627  
    8628             if ( $pedazos[0] eq $ip_addy{$_} ) { 
     8599            my ($ip) = split( /\|/, $manager_socket{$_} ); 
     8600 
     8601            if ( $ip eq $ip_addy{$_} ) { 
    86298602                my $contador = 0; 
    86308603                foreach my $valor (@manager_host) { 
    8631                     if ( $valor eq $pedazos[0] ) { 
     8604                    if ( $valor eq $ip ) { 
    86328605                        $nro_servidor = $contador; 
    86338606                    } 
     
    86548627                # Send commands to check the mailbox status for each mailbox defined 
    86558628                while ( my ( $key, $val ) = each(%mailbox) ) { 
    8656                     my @pedacitos = split( /\^/, $key ); 
    8657                     my $servidormbox = $pedacitos[0]; 
     8629                    my ($servidormbox) = split( /\^/, $key ); 
    86588630                    if ( "$servidormbox" eq "$nro_servidor" ) { 
    86598631                        log_debug( "$heading mailbox $ip_addy{$_} $key $val", 32 ) if DEBUG; 
     
    87928764        return; 
    87938765    } 
    8794  
    8795     #    my @partes = split( /\|/, $manager_socket{$socket} ); 
    8796  
    8797     #    $comando = ""; 
    87988766 
    87998767    if ( $comando eq "" ) { 
     
    90339001 
    90349002    @chars_number = split( //, $numero ); 
    9035     @chars_format = split( //, $format ); 
    9036  
    9037     @chars_format = reverse @chars_format; 
     9003    @chars_format = reverse split( //, $format ); 
    90389004 
    90399005    my $parate = 0; 
     
    90619027    } 
    90629028 
    9063     @result = reverse @result; 
    9064     $devuelve = join( "", @result ); 
     9029    $devuelve = join( "", reverse @result ); 
    90659030    $devuelve =~ s/\${CLIDNAME}/$name/gi; 
    90669031    return $devuelve;