Re: [SLUG] Perl Question

From: perthie (perthie@yahoo.com)
Date: Tue Mar 22 2005 - 15:54:57 EST


another possibility is that hex() can't interpret its argument as a hex
string, so it returns 0. in either case, printing $buff after you call
read() will tell you what to look for next.

--- perthie <perthie@yahoo.com> wrote:
>
> --- mark@bish.net wrote:
> >
> > Why doesn't this work?
> >
> > open(SRC, "<$file1") or die "Can't open for reading: $!\n";
> > open(DEST, ">$file2") or die "Can't open for reading: $!\n";
> >
> > binmode(SRC);
> > binmode(DEST);
> >
> > while(read(BRIEF, $buff, 2)){
>
> while(read(SRC, $buff, 2)) {
> #use this to make sure read is doing what you expect.
> #if your output is the same as your xor mask, then
> #you're probably reading 0's.
> print $buff;
>
> > $buff = hex ($buff) ^ 0xAA;
> > print DEST $buff;
> > }
> >
> > close(DEST);
> > close(SRC);
> >
> >
> >
> > I get a text file filled with 170, which is 0xAA.
> >
>
-----------------------------------------------------------------------
> > This list is provided as an unmoderated internet service by
> Networked
> > Knowledge Systems (NKS). Views and opinions expressed in messages
> > posted are those of the author and do not necessarily reflect the
> > official policy or position of NKS or any of its employees.
> >
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/
>
-----------------------------------------------------------------------
> This list is provided as an unmoderated internet service by Networked
> Knowledge Systems (NKS). Views and opinions expressed in messages
> posted are those of the author and do not necessarily reflect the
> official policy or position of NKS or any of its employees.
>

                
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:19:58 EDT