Re: Can pack do what I want?

2002-12-13 Thread Todd Beverly
Allegakoen, Justin Devanandan wrote:


So question is, if this string was packed with pack in Perl would it be 
interpreted by the hardware that it's pumped into in the same way
that the resultant compiled Pascal output would?

If it helps any here's a sample Pascal line that gets compiled:-

write ('@@@FF1');

The resultant compiled output is a binary file which
doesnt display correctly when pasted in this e-mail.

But when opened with gvim you can see control characters all the way
through i.e.
^@^@^@^F^F1^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F^
F^F^F^F^F^F^@^@^A/

Could I write pack("a*",
'@@@FF1');
and get it to behave as I expect? 
 

I think that the ascii value of ^@ (control @) is 0   and the ascii 
value of  control F is 6,  expressed as the ascii value of "F"  70 - 64 
= 6.   If this is the conversion that you're looking for, then something 
like

my $j = '@@@FF1';
$j =~ tr/@A-Z/\000-\026/;
print $j;

might work.



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Can pack do what I want?

2002-12-10 Thread Thomas_M
Justin wrote:
> You'll forgive me, I graduated in Triple E, so I'm
> not sure of what I mean, but I do know what I need.

Well I'm a Double E, so you're one E up on me!
 
> So question is, if this string was packed with pack in Perl 
> would it be 
> interpreted by the hardware that it's pumped into in the same 
> way that the resultant compiled Pascal output would?

Rephrased question: Can perl produce the same binary file that
the Pascal program did, using pack()? Answer: yes.

> If it helps any here's a sample Pascal line that gets compiled:-
> 
> write ('@@@FF1');
> 
> The resultant compiled output is a binary file which
> doesnt display correctly when pasted in this e-mail.

But in order for us to provide more help, we'll need to know
precisely what output you need. Can you supply a hex dump of the
output of the above command? The input string doesn't seem to be
hex, and also you haven't said if the system is big-endian or
little-endian with respect to byte order.

-- 
Mark Thomas   |_|
Internet Systems Architect-+-
User Technology Associates, Inc.   |
[EMAIL PROTECTED]  /-\

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs