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.



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


Paul Kraus wrote:
> I am creating a simple database that needs to contain 3 fields. Date, 
> order number, tracking number.
> 
> I figured I would use a dbmhash and use pack to get the data in. So my

> hash would be %hash{tracking_number}=$packeddata.
> 
> The date and order number are both strings.
> So using the information I received from perldoc -f pack.
> I determined that I need to use the format 'A'.
>       $stuffed = pack("A A", $date, $order);
> 
> All this does is steal the first character of each string.
> 
> So reading more I find that I need a quantifier so I tried *
>       $stuffed = pack("A* A*", $date, $order);
> This stole the 1st char of $date and the second char of $order.
> 
> Any ideas?
> 
> Paul

        Why do you say that? I ran under w2k AS 5.6.0 build 623 and
placed all in $stuffed. I printed it out and $stuffed had te data from
both items as one long stream.

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]


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

Reply via email to