LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] [OT] perl question...

[ILUG] [OT] perl question...

Declan Grady Declan.Grady at nuvotem.com
Thu Jul 15 14:00:56 IST 2004


Niall O Broin wrote:

>On Thursday 15 July 2004, Declan.Grady at nuvotem.com (Declan Grady) wrote:
>
>
>  
>
>>I have two arrays,  @openitems, and @customernames.
>>I need to create a new array which will take all the openitems, and lookup
>>a customer name in the @customernames array, based on the customercode,
>>which is common to both arrays.
>>
>>i.e.
>>@openitems is:
>>code, type, value, date, ref, ... etc
>>
>>@customernames is:
>>code, name
>>    
>>
>
>Arrays are lists, indexed by number. So what exactly do you have as the
>contents of your arrays - comma separated strings? references to something
>else (I doubt this, but . . .)?  i.e. how are you storing in @openitems all of
>code, type, value, date, ref, ... etc  because an array has only an index, and
>a value - but that value can be a string, which you can be parsing to get
>those things, or a reference to a has, or  . . .
>  
>
OK, Sorry .. my explanation is a bit lacking....
I have an array of strings - I read the array from a fixed-width ascii 
file, so my array would be :
@openitems[1]="d3_code    d3_ref     t d3_val     d3_date  d3_rate    f 
d3_paid"
@openitems[2]="========== ========== = ========== ======== ========== = 
=========="
@openitems[3]="     10130       1509 A   53.07000 20030430    
1.00000      0.00000"
@openitems[4]="     10130       1567 A   53.20000 20040611    
1.00000      0.00000"
@openitems[5]="     10130     992820 1 4468.60000 20040628    
1.00000      0.00000"
@openitems[6]="     10181     962652 A  100.99037 19970217    
1.00000      0.00000"
@openitems[7]="     10224     992863 1  572.92000 20040701    
1.00000      0.00000"
@openitems[8]="     10228          B E  -28.82664             1.00000 
0    0.00000"
@openitems[9]="     10228     992779 1  693.10000 20040621    
1.00000      0.00000"

I then have a similar array for the customer names:

@custname[1]="d1_code    d1_name                      "
@custname[2]="========= =============================="
@custname[3]="    10166 Customer Name A                   "
@custname[4]="    10170 Customer Name B                   "
@custname[5]="    10171 Customer Name C                   "
@custname[6]="    10175 Customer Name D                   "
@custname[7]="    10176 Customer Name E                   "
@custname[8]="    10177 Customer Name F                   "
@custname[9]="    10181 Customer Name G                   "
@custname[10]="   10186 Customer Name H                   "


Does this mean I can have a hash of the customer names, and reference 
the element in the hash by the customer code from the openitems array ? 
- Or am I way off the point.

i.e.  Somehow automate putting the  file into  a custnmae hash:
%custname = ( 10166 => "Customer Name A", 10170 => "Customer Name B" ... 
etc );

Then get the customer name from
$this_customer="10167";
print $custname{ $this_customer };

so.. how do I fill up the hash from my custname ascii file ?


Thanks,
Declan












More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell