Hi everyone,
I have not touched Perl in the last 4 years, my books are at work and I have something here I'm struggling to figure out. From a known list of servers, I need to gather up how many clearcase views are on each server and then only choose the one that has the least number of views that given day. This is what I have so far.
my @servers = qw (
srv30bld4
srv30bld5
srv40bld2
srv40bld3
srv40bld4
);
foreach (@servers) {
my @view = `$CT lsview -short -host $_ | wc -l`;
I'm running the clearcase command "lsview" on each server and doing a wc so I know just how many views came back. The result I get is as follows.
srv30bld4 92
srv30bld5 0
srv40bld2 58
srv40bld3 3
srv40bld4 2
So now I know how many clearcase views are on each server but I only want the one with the lowest amount. I'm having difficulty sorting this list. Any help is appreciated.
Thanks.
3 1695 KevinADC 4,059
Recognized Expert Specialist
assuming @view is what needs sorting: - @view = ('srv30bld4 92','srv30bld5 0','srv40bld2 58','srv40bld3 3','srv40bld4 2');
-
@view = map {$_->[0]} sort {$a->[1] <=> $b->[1]} map {chomp;[$_, /\s+(\d+)$/]} @view;
-
print $view[0];
but what if there are two or more servers with the same number of minimum views?
but what if there are two or more servers with the same number of minimum views?
Thanks for taking the time to reply Kevin, I really appreciate this. I tried running this with more than one server set to the same number of views and it picks the one it comes across first in the list. This is fine as this code will be placed in a pre-existing script that people use to create views. We're just trying to prevent an imbalance of views across the five servers that are available. If there is a tie among the lowest number of views, as long as one of them gets picked during a given round that'll work.
Again, thanks so much.
Joe
@joeke3el
If you want to read more about the backgrounds of Kevin's solution, it's called the "Schwarztia n Transform".
Greetz, Doc
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Paul Kirby |
last post by:
Hello All
I am trying to update me code to use arrays to store a group of information
and I have come up with a problem sorting the multiple array :(
Array trying to sort: (7 arrays put into an array) and I want to sort on
Descending.
This is displayed using print_r() function.
Array
|
by: David Pratt |
last post by:
I have been using the following for sorting a list of dictionaries.
This works but only provides sorting on a single key. I am wanting to
extend this with a better comparison expression so that it would sort
on one key as primary, a second key as secondary sort , and maybe even
a third as tertiary.
def sort_by_key(list, i):
list.sort(lambda a, b: cmp(a, b))
test_list =
|
by: Neil Hindry |
last post by:
I wonder if you can help me.
I have been using the very basic functions of Access XP for a while now but
I have just started delving into forms etc.
I have created a form to enter my data and I have a couple of pull down
menus (I think they are called Combo boxes) so that I can only select from a
list of data for that field. What I cannot seem to do is make this list
appear in alphabetical order.
|
by: Owen T. Soroke |
last post by:
Using VB.NET
I have a ListView with several columns.
Two columns contain integer values, while the remaining contain string
values.
I am confused as to how I would provide functionality to sort columns
based on the column header the user has clicked in both Ascending and
Descending formats.
|
by: Brian Henry |
last post by:
Here is another virtual mode example for the .NET 2.0 framework while
working with the list view. Since you can not access the items collection of
the list view you need to do sorting another way... here is my code on how I
did it to help anyone starting out get an idea of how to use virtual mode in
..NET 2.0
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
| |
by: FBM |
last post by:
Hi,
I am working on a program that simulates one of the elements of ATM.
The simulation stores events which occurs every some milliseconds for a
certain amount of time. Every time that an event is stored in a double
linked list, the whole list is sorted for the next round.
My problem appears when subjecting the program to heavy load, that is,
when I run the simulation for more than 10,000 miliseconds (every event
occurs in...
|
by: dwelden |
last post by:
I have successfully used the sort lambda construct described in
http://mail.python.org/pipermail/python-list/2006-April/377443.html.
However, how do I take it one step further such that some values can be
sorted ascending and others descending? Easy enough if the sort values
are numeric (just negate the value), but what about text?
Is the only option to define an external sorting function to loop
through the list and perform the...
|
by: skip |
last post by:
The thread on sorting in Python 3 got me to thinking. How could I sort a
list of complex numbers using key?
As expected:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: no ordering relation is defined for complex numbers
|
by: jrod11 |
last post by:
hi,
I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums there are, it crashes.
There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)?
Here is a link: http://www.jaredmoore.com/tablesorter/docs/salestable.html
Here is some jquery js that I think...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |