How do I create a Lookup table in Powershell? [closed] - powershell

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a list of servernames
PARDC1 EURDC2 EURDC3 USADC1 USADC22 CHNDC1 CHNDC2
I have created a hashtable to pick the first 3 letters of servernames, and classify it in a region.
PAR = EMEA
EUR = EMEA
USA = NAM
CHN = APAC
I want to use the lookup table to classify all servers in appropriate regions.
How do I go about doing this in Powershell ?

You can create an empty hash table with
$hash = #{}
You can then add entries to it with
$hash['foo'] = $bar
or
$hash.foo = $bar
and access them the same way later again.

Related

How do I sum the "money" values in the Foreach loop in my project with Swift? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
I created a loop with foreach. My data is coming through firebase. How do I sum the "money" values in the Foreach loop in my project with Swift? Please help!
TODOS.swift / Image
IncomeList.swift / Image
Text(String("\(self.session.items.map({ $0.money }).reduce(0, +))"))
could you try insert above code below "List {" code line in "TODOS.swift / Image"?

Drop Down GUI matlab [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
function DoneButtonPushed(app, event)
assignin('base','roll_no_GUI1',app.StudentInfoDropDown.Value);
assignin('base','projname_GUI1',app.ProjectInfoDropDown.Value);
assignin('base','roll_no_GUI2',app.StudentInfoDropDown_2.Value);
assignin('base','projname_GUI2',app.ProjectInfoDropDown_2.Value);
assignin('base','roll_no_GUI3',app.StudentInfoDropDown_3.Value);
assignin('base','projname_GUI3',app.ProjectInfoDropDown_3.Value);
assignin('base','roll_no_GUI4',app.StudentInfoDropDown_4.Value);
assignin('base','projname_GUI4',app.ProjectInfoDropDown_4.Value);
assignin('base','roll_no_GUI5',app.StudentInfoDropDown_5.Value);
assignin('base','projname_GUI5',app.ProjectInfoDropDown_5.Value);
closereq
end
Hi, I am creating a GUI which contains DropDowns. They are 10 dropdowns as you can see from the code. And I am using assignin to save each one of them into base workspace. But I would like to club all of them into a 2 char array's or 2 cell array's and send only two variables into the base workspace viz, Roll_nos and Projnames_GUI
Create two cell arrays and assign them in the base workspace:
roll_nos = {
app.StudentInfoDropDown.Value,
app.StudentInfoDropDown_2.Value,
app.StudentInfoDropDown_3.Value,
app.StudentInfoDropDown_4.Value,
app.StudentInfoDropDown_5.Value
};
projnames_gui = {
app.ProjectInfoDropDown.Value,
app.ProjectInfoDropDown_2.Value,
app.ProjectInfoDropDown_3.Value,
app.ProjectInfoDropDown_4.Value,
app.ProjectInfoDropDown_5.Value
};
assignin('base','Roll_nos',roll_nos)
assignin('base','Projnames_GUI',projnames_gui)

How to store an array in session in Perl [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am using Mojolicious Perl framework in my application. I want to store an array in session, but is not successful.
my #returnResult;
$returnResult['fn'] = $decoded->{'fn'};
$returnResult['ln'] = $decoded->{'ln'};
$self->session(returnResult => #returnResult);
Please help.
See hashes in Modern Perl and perldata.
my %return_result;
$returnResult{fn} = $decoded->{fn};
$returnResult{ln} = $decoded->{ln};
or
my %return_result = (
fn => $decoded->{fn},
ln => $decoded->{ln},
);
or simply
# http://perldoc.perl.org/perl5200delta.html#New-slice-syntax
my %return_result = %$decoded{qw(fn ln)};
You do not get automatic references like in other languages. Use the \ operator.
$self->session(returnResult => \%return_result);

Remove common values from multidimension array perl [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I want remove common element from array. For example:
array1 =
[
{'id'=>78597,'data'=>'great'}
];
array2=
[
{'id'=>78345,'data'=>'first'},{'id'=>78597,'data'=>'great'},
{'id'=>78355,'data'=>'second'}
]
Now key Id '78597' is common in both array
Now i to want remove that element from array2 based on the key 'id'. The examples I referred where all single dimension.
You can build %seen hash lookup and filter #$array2,
my %seen;
#seen{ map $_->{id}, #$array1 } = ();
#$array2 = grep { !exists $seen{$_->{id}} } #$array2;

Please anyone be so kind help! Matlab [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have this data of year, month, date. I want this to show as year,month,date in Matlab and don't know how to do.
X=(2014,01,02 2014,01,03 2014,01,07 2014,01,08 2014,01,09 2014,01,10 2014,01,13
2014,01,14 2014,01,15 2014,01,16 2014,01,17 2014,01,20 2014,01,21 2014,01,22
2014,01,23 2014,01,24 2014,01,27 2014,01,28 2014,01,29 2014,01,30 2014,01,31
2014,02,03 2014,02,04 2014,02,05 2014,02,06 2014,02,07 2014,02,10 2014,02,11
2014,02,12 2014,02,13 2014,02,14 2014,02,17 2014,02,18 2014,02,19 2014,02,20
2014,02,21 2014,02,24 2014,02,25 2014,02,26 2014,02,27 2014,02,28 2014,03,03)
The simplest way would be to reshape the matrix and use it accordingly. I demonstrate the way to reshape and print all the dates in US (MM/DD/YYYY) format.
X=[2014,01,02 2014,01,03 2014,01,07 2014,01,08 2014,01,09 2014,01,10 2014,01,13 2014,01,14 2014,01,15 2014,01,16 2014,01,17 2014,01,20 2014,01,21 2014,01,22 2014,01,23 2014,01,24 2014,01,27 2014,01,28 2014,01,29 2014,01,30 2014,01,31 2014,02,03 2014,02,04 2014,02,05 2014,02,06 2014,02,07 2014,02,10 2014,02,11 2014,02,12 2014,02,13 2014,02,14 2014,02,17 2014,02,18 2014,02,19 2014,02,20 2014,02,21 2014,02,24 2014,02,25 2014,02,26 2014,02,27 2014,02,28 2014,03,03];
X_in_better_format = reshape(X,3,42)';
for it = 1:size(X_in_better_format,1)
sprintf('The date is %d/%d/%d',X_in_better_format(it,2),X_in_better_format(it,3),X_in_better_format(it,1)) %US Format
end