Re: Fixed Length Text Extract, Write to Excel

2004-01-07 Thread R. Joseph Newton
William Martell wrote:

 Hello All,

 I am trying to work with the code I have to extract fields from a text file report, 
 and write the values into excel.

 I am having trouble.

 When I get to push @order_detail, %item
 I understand that this is pushing an associative array onto a list. (array
 of hashes)

That is the problem,  a list cannot contain a hash.  The keys and values of the hash 
simply become flattened into list
elements, and all the hashing magic is lost.

perldoc perlref

will explain how references can help resolve this problem..

Joseph



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Fixed Length Text Extract, Write to Excel

2004-01-07 Thread William Martell
Thanks for your reply Joseph,  I am reading perlref now.  If you can offer
some pointers on how to access the key value pairs of the reference object
%item.  I would appreciate it.


- Original Message -
From: R. Joseph Newton [EMAIL PROTECTED]
To: William Martell [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, January 07, 2004 11:20 AM
Subject: Re: Fixed Length Text Extract, Write to Excel


 William Martell wrote:

  Hello All,
 
  I am trying to work with the code I have to extract fields from a text
file report, and write the values into excel.
 
  I am having trouble.
 
  When I get to push @order_detail, %item
  I understand that this is pushing an associative array onto a list.
(array
  of hashes)

 That is the problem,  a list cannot contain a hash.  The keys and values
of the hash simply become flattened into list
 elements, and all the hashing magic is lost.

 perldoc perlref

 will explain how references can help resolve this problem..

 Joseph



 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Fixed Length Text Extract, Write to Excel

2004-01-07 Thread NYIMI Jose (BMB)
while(my($key,$val)=each %item){
#do stuff
}

HTH,

José.

-Original Message-
From: William Martell [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 07, 2004 6:46 PM
To: R. Joseph Newton; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Fixed Length Text Extract, Write to Excel


Thanks for your reply Joseph,  I am reading perlref now.  If you can offer some 
pointers on how to access the key value pairs of the reference object %item.  I would 
appreciate it.


- Original Message -
From: R. Joseph Newton [EMAIL PROTECTED]
To: William Martell [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, January 07, 2004 11:20 AM
Subject: Re: Fixed Length Text Extract, Write to Excel


 William Martell wrote:

  Hello All,
 
  I am trying to work with the code I have to extract fields from a 
  text
file report, and write the values into excel.
 
  I am having trouble.
 
  When I get to push @order_detail, %item
  I understand that this is pushing an associative array onto a list.
(array
  of hashes)

 That is the problem,  a list cannot contain a hash.  The keys and 
 values
of the hash simply become flattened into list
 elements, and all the hashing magic is lost.

 perldoc perlref

 will explain how references can help resolve this problem..

 Joseph



 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED] 
 http://learn.perl.org/ http://learn.perl.org/first-response



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ 
http://learn.perl.org/first-response




 DISCLAIMER 

This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer.

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Fixed Length Text Extract, Write to Excel

2004-01-07 Thread Rob Dixon
William Martell wrote:

 I am trying to work with the code I have to extract fields from a text file
 report, and write the values into excel.

 I am having trouble.

 When I get to push @order_detail, %item

Looking at your code, you mean

  push @order_detail, \%item

 I understand that this is pushing an associative array onto a list. (array
 of hashes)

 I am trying to write code that will open a new worksheet in excel and print
 the values of %item onto a row.  When Perl encounters a certain key
 (cust_number), I would like it to start a new row.

 I have tried keys(), values(), pop() but I can't get it right.  I think some
 of my trouble is b/c of the reference \%item.  When I remove the reference
 backslash operator like this %item and type print. Perl returns with the
 contents in scalar.

 So.  My main question is how do I access the values and keys of %item in
 @order_detail???

Hi William.

You're building an array of hash references. To access a hash values
from a given array element, write

  my $cust_number = $order_detail[0]{cust_number}

To do the same for each detail record, do this

  foreach my $detail (@order_detail) {
my $cust_number = $detail-{cust_number};
  }

The value returned will be 'undef' if there is no such element for a given
order detail record.

I hope this helps.

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Fixed Length Text Extract, Write to Excel

2004-01-07 Thread Wiggins d Anconia
Please bottom post...

 Thanks for your reply Joseph,  I am reading perlref now.  If you can offer
 some pointers on how to access the key value pairs of the reference object
 %item.  I would appreciate it.
 

May I also suggest the little easier reading of, 

perldoc perlreftut
perldoc perldsc
perldoc perllol

To go along with, and usually (at least the first) before perlref. It
can be quite thick to try and get through. The above are designed to be
less of a complete reference and more of a real world help tool

Good luck,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response