Try changing to this.

printf "emaildata is $emaildata[0]";

$emaildata[0] is using the element in a scalar format
@emaildata[0] is using the element in an array format, which is converted to
scalar by perl when printing out in this case. The array only has the one
element [0]. When you take an array in scalar context you get the number of
elements in the array, hence it prints 1.

HTH

John

-----Original Message-----
From: Conor Lillis [mailto:[EMAIL PROTECTED]]
Sent: 11 January 2002 13:08
To: PERL Beginners (E-mail); Perl-Win32-Users (E-mail)
Subject: Data manipulation problem


Hi all,
hopefully someone can help me with this, I will describe my problem as best
as I can. I am opening 2 files, one has a list of NT account names, The 2nd
has a list of NT account names & e-mail addresses. I am trying to match an
NT account name from the first list to an e-mail address in the second file
by NT account name. 
My comments are to explain what my bumbling logic is, can someone tell me
how I might try and pull the e-mail address from the @emaildata ?

--------------script starts
-----------------------------------------------------
open (LIST1, "<input.txt");
open (MAILLIST, "<nt-smtp.txt");
@maillist=<MAILLIST>;
while(<LIST1>) 

{
        # Split the name from the .txt extension eg. conorl
        @data = split(/\./, $_);                

        # read the name
        $Name=$data[0];                 

        # print the name so we know what is happening
        printf "$Name\n";               

        # Grep the name from the second file, outputting result to @data1
        @data1=grep /$Name/i, @maillist;        

        # print the @data1 so we know wheat is happening again
        printf "DATA1 @data1";          

        # split @data1, to isolate the e-mail address from the name eg.
[EMAIL PROTECTED]
        @emaildata = split(/,/, @data1);                

        # print the e-mail address, NOT. This prints an integer, I am not
sure why. HELP this where it goes pear-shaped.
        printf "emaildata is @emaildata[0]";    
}
----------script
ends------------------------------------------------------------
sample input.txt data
conorl.txt

sample nt-smtp.txt data
conorl,[EMAIL PROTECTED]




The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised.if you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it is prohibited and may be unlawful. Please note that any
views, opinions or advice contained in this email are those of the sending
individual and not necessarily those of the firm. It is possible for data
transmitted by e-mail to be deliberately or accidentally corrupted or
intercepted. For this reason, where the communication is by e-mail, J&E Davy
does not accept any responsibility for any breach of confidence which may
arise from the use of this medium. If you have received this e-mail in error
please notify us immediately at mailto:[EMAIL PROTECTED] and delete this
e-mail from your system.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to