473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

assign pipe delimited file to hash??

1
hi,

i am doing a lookup using hash table. I have a pipe delimited file that i have to search for a new invocie number field by checking of an old invoice number-customer number key combination exists in hash:

sample input file:

===
1wwwwwwwwwwwwhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhh0
4wwwwwwwwww00002635168A0000C10139hhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhh9
===

sample lookup table rec:

ABC|C10139|35168A|2635168A-9z9866|5513975|2936554
DEF|C10139|956772|26956772-A05836|5513975|2936554

====


my code so far is as below:

===

open(INPUT,"<input_file") || die "Can't open lbx input file $input_file. $?\n";

while (<INPUT>)
{
chop;
$_ =~ s/#.*//; # strip comments
$_ =~ s/\s*$//; # remove trailing white space
$_ =~ s/^\s*//; # remove leading white space
next if ($_ =~ /^$/); # skip blank lines
$input_record = $_;
if (grep /^4/, $input_record)
{
$Invoice_record = $_;
$Full_invoice_number = substr($Invoice_record,11,12);
$District_identifier = substr($Invoice_record,15,2);
$invoice_number = substr($Invoice_record,17,6);
$customer_number = substr($Invoice_record,27,6);

open(LOOKUP,"<$Lookup_file") || die "Can't open lookup table $Lookup_file. $?\n";

while (<LOOKUP>)
{
chop;
$_ =~ s/#.*//; # strip comments
$_ =~ s/\s*$//; # remove trailing white space
$_ =~ s/^\s*//; # remove leading white space
next if ($_ =~ /^$/); # skip blank lines
my (@Lookup_record) = split '\|',$_;
$Path = $Lookup_record[0];
$CustomerNumber = $Lookup_record[1];
$InvoiceNumber = $Lookup_record[2];
$OraInvoiceNumber = $Lookup_record[3];
$OracustomerNumber = $Lookup_record[4];
$OraCustomeraccntNumber = $Lookup_record[5];

%Lookup_table = (

Path => "$OmdPath",

Customer_Number => "$CustomerNumber",

Invoice_Number => "$InvoiceNumber",

OraInvoice_Number => "$OraInvoiceNumber",

Oracustomer_Number => "$OracustomerNumber",

OraCustomeraccnt_Number => "$OraCustomeraccntNumber",


);



foreach $Customer_Number(keys %Lookup_table)
{
if ($Lookup_table{$Customer_Number} > 1)
{
print "duplicate";
print "count for duplicate user [$Customer_Number] is [$Lookup_table{$Customer_Number}]\n";
$duplicates = ($duplicates+($Lookup_table{$Customer_Number}-1));
print $duplicates;
}
}



}
close (LOOKUP);
next;
}
else
{
open(OUT,">>$modified_input_file") or die "Can't open output file $modified_input_file... $?\n";
print OUT "$input_record\n";
close OUT;
next;
}
}
close (INPUT);

=====

please advice!!!

regards,
Bhups
Nov 6 '06 #1
1 3638
GunnarH
83
  • Let Perl help you debug your script by including
    Expand|Select|Wrap|Line Numbers
    1. use strict;
    2. use warnings;
    at the top, and declare the variables with my().
  • If necessary, post your debugged code within CODE tags.
Good luck!
Nov 6 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: richard | last post by:
I have a simple test to pass information from a client to a server using named pipe. what I really want is: when I type a line on the client, the server will output the line immediately. but to my...
1
by: DCM Fan | last post by:
Access 2K, SP3 on Windows 2K, SP4 All, I have an import spec set up with quoted Identifiers and comma-separated values. The text file is produced by a 3rd-party program of which I have no...
3
by: Ben | last post by:
Hi all - I am having a bit of trouble and thought maybe someone in this group could shed some light. Here's the skinny... I am creating an automated process to import a bunch of text files...
2
by: Ray Stevens | last post by:
I am loading a pipe-delimited string from a DataSet into StringBuilder, such as 00P|23423||98723 (etc.). For some reason the pipe character is displaying in the debugger as "o" with two small dots...
0
by: Masa Ito | last post by:
I have pipe delimited (and comma/tab) files that I read with JET using a schema file. Occasionally a field has multiple quotes (") inside a single field - which chokes the line (the rest of the...
1
by: Fordraiders | last post by:
vb.net 2003 Office 2003 What I have: C:\TestData\Input.txt Text File Pipe Delimited : 4 columns Of data example: 00001|NO BRAND NAME ASSIGNED|6DU27|M3-.5 X 6 FLAT HD SOCKET CAP SCREW,...
1
by: bhapate1 | last post by:
Hi all, I Have a Table with 10 Columns, Among those i have Data in just 3 Columns. Rest of columns wil be blank. I want to Export that Table as a Pipe Delimited Text File. I am using...
8
benchpolo
by: benchpolo | last post by:
Data Row 1 -> AAA|123|ABCDE|929292||183 EAST WAY #A11|223|TX|CA|12 Data Row 2 -> BBB|123|ABCDE|||183 EAST WAY #A11|223|TX|CA|12 Data Row 3 -> VVV||ABCDE|929292||183 EAST WAY #A11|223|TX|CA|12 Data...
1
by: chiku1523 | last post by:
Hi All, In file1.txt I have following data. 1B13C1311945038FE0440003BA1DC817-PLC13|1B13C1311945038FE0440003BA1DC817-PLC130.18063115540216856...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.