Changeset 8034 in genesis for tools/proxy-8.0/g_list.pl


Ignore:
Timestamp:
May 25, 2010, 5:30:26 PM (15 years ago)
Author:
rick
Message:

Cosmetic:

  • Sort ordering more logical, based on the Key and then the #
  • Instead of fixed matches allow regEx so we can only list proxies for example
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/proxy-8.0/g_list.pl

    r7037 r8034  
    4040  foreach $dir (sort @tmpdirs) {
    4141    no warnings "once";
    42     if( not exists($removefromnodelist{$dir}) )
     42    my $remove = 0;
     43    foreach $pattern (@removefromnodelist) {
     44      print $pattern;
     45       if ($dir =~ /$pattern/i) {
     46          $remove = 1;
     47          break;
     48       }
     49    };
     50    if( $remove == 0 )
    4351    {
    4452      push(@nodelist, $dir);
     
    5058    use warnings "once";
    5159  };
    52   return @nodelist;
     60  # Looks like magic, but actually just sorting an array, first based on
     61  # the Alpha key and next numerics sort on the numeric port
     62  return sort {
     63     $a =~ m/^([a-zA-Z]+)([0-9]+)$/; $nameA = $1; $numberA = $2;
     64     $b =~ m/^([a-zA-Z]+)([0-9]+)$/; $nameB = $1; $numberB = $2;
     65     if ($nameA == $nameB) {
     66      $numberA <=> $numberB;
     67     } else {
     68       $nameA cmp $nameB;
     69     } } @nodelist;
    5370}
    5471
     
    158175
    159176  @dirs = listnodes( );
    160   foreach $dir (sort @dirs) {
     177  foreach $dir (@dirs) {
    161178    if( $dir=~/attic/ ) {
    162179      next;
Note: See TracChangeset for help on using the changeset viewer.