[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] truncate Question



At 17.20 -0400 1998.07.10, Dave Emme wrote:
>  #!perl -w
>  open(XXX, ">test");
>  print XXX "Hi there";
>  truncate(XXX, 5);
>
>produces the following file (hex dump):
>
>  00 00 00 00 00 48 69 20 74 58 65 72 65
>
>What I expected was:
>
>  48 69 20 74 58
>
>What am I missing?

Works the same for me.  Looks like a bug.  This does work as expected, though:

  #!perl -w
  open(XXX, ">test");
  print XXX "Hi there";
  close(XXX);
  truncate('test', 5);

As I have not used truncate() much on Unix or Mac OS, I can't say much more
than this.  :-)  Hm, I tried something else:

  #!perl -w
  open(XXX, ">test");
  print XXX "Hi there";
  seek(XXX, 0, 0);
  truncate(XXX, 5);

This also worked as expected.  I don't have time to test on a Unix box
right now.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch