Basically I have inherited a massive excel workbook. In one of the worksheets I have a column where I have server names and the next column I have user Ids like this;


server1 JohnB
server5 JohnB
server3 LisaG
Server2 LisaG
server7 AdamX
server1 Adamx
server3 PaulK
server5 PaulK


For each account name there is only one server where the users home drives are located, what I need to do is to:
1- Check which is the correct server.
2- Edit the excel sheet by inserting ok next to the correct server name or Del for the incorrect one.
So i get this results below;

server1 JohnB Ok
server5 JohnB Del
server3 LisaG Del
Server2 LisaG Ok
server7 AdamX Del
server1 Adamx Ok
server3 PaulK Ok
server5 PaulK Del


I have written a script that that checks which is the correct home server using combination of AdminMisc and Netadmin, but I need to do is get the script to edit this massive list with correct information rather than me doing it manually so I wrote this bit (or nicked it form someone here)
use strict 'vars'; use OLE; use Win32::NetAdmin; use Win32::AdminMisc; my @Domains = ('Dom_UK','Dom_US'); my $xl = CreateObject OLE 'Excel.Application' || die $!; my $workbook = $xl->Workbooks->Open("C:\\myfiles\\test.xls"); my $worksheet = $workbook->Worksheets(1); my $xls = $worksheet->Range("A1:B10000")->{'Value'}; my @DataLst; my $count=0; for (@$xls) { print ++$count." @$_\n"; }
Now, I need to have a hash where I have the following information
Row -> Row number, ID -> User ID, Server -> the server where the correct home drive is.
And push each record (or Hash) into and a one big array, so that I can loop this array, and access each record, check the user ID against the server is correct or not, if its correct then I use the row number (columns is constant and = 3) to insert ok or del. And that’s it. But I am not sure on how to split $@_ into two element $srv and $id, insert them into and array and loop through the array to access each item the amend the excel file with the findings. Any suggestions or Perls of wisdom (with and example or 2) are welcome

Many thanks indeed.

In reply to Re: Re: The @$ array construct by blackadder
in thread The @$ array construct by blackadder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.