I have two text files that are exported from our shipping computers each
night.

One is FedEx and contains a space delimitated file with two fields.
OrderNumber TrackingNumber

The other is UPS and contains a CSV file with two fields.
"OrderNumber","TrackingNumber"

I wanted to have a script that would dump both files into a simple 3
field database.
Trackingnumber(key),date,ordernumber.

I then was going to create a web page that could be used as a front end
to perform searches on these numbers.

My thinking was to just store them into a packed dmbhash. Seemed
reasonable as I think a full fledge DB would be overkill.

The problem is that the fields from the two files are of different
lengths meaning my original solution will not work. 

I guess I could create to dbm databases and have them both queried for
the search but that would be to easy.
I could also record the length of the fields in the first 4 characters
of the packed string and then use them as references but that seems
messy :)

XXYYDATA1DATA2
XX = length of datafield1
YY = length of datafield2

 Any other suggestions on a way to handle this?

Paul Kraus

-----Original Message-----
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, January 21, 2003 3:37 PM
To: '[EMAIL PROTECTED]'; Wagner, David --- Senior Programmer Analyst
--- WGO; 'Perl'
Subject: RE: Pack syntax


Paul Kraus wrote:
> You are of course correct. After some digging I seems that the problem

> was in my unpack statement. When I actually checked the packed 
> variable all the data was there.
> 
> I was doing .. My ($a,$b) = unpack("A A",$buffer);
> When I added ... Unpack "A* A*"....
> It sort of worked. It just unloads $buffer into $a.
> 
> Here is the snippet of code.
> $date contains scalar(localtime).
> $fields[0] contains a 10 character order number.
> 
>  $buffer = pack("A* A*",$date,$fields[0]);
>     print "\$buffer = $buffer\n";
> 
>     my ($a, $b) = unpack("A* A*", $buffer);
>     print "\$a=$a\n\$b=$b\n";
> 
> Output
> ------
> $buffer = Tue Jan 21 15:17:09 2003GULLIFER
> $a=Tue Jan 21 15:17:09 2003GULLIFER
> $b=
> 
> So know I am going to assume that pack and unpack could care less 
> about the data. The unpack needs to know the exact length of each 
> record in order to unpack the data correctly into separate variables.
> 
> If so then that really makes this useless to me :(
> So all pack and unpack are is wrapped up '.' and substr.
> 

Paul,
        Usually you have a set length that you are going with. SO date
is 10 maybe and order # is 20, so you would use "A10A20" for the pack
and unpack to break out the data into variables or arrays.  The
pack/unpack is really for extracting from fix length record setups
and/or getting of binary data so you can work with it.  Not useless, but
depends on what you are after and what you want to do.

Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


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

Reply via email to