Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > PerlIO omission

Reply
Thread Tools

PerlIO omission

 
 
Bo Lindbergh
Guest
Posts: n/a
 
      06-08-2006
Why is there no truncate operation in PerlIO?

/Bo Lindbergh
 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      06-08-2006

Quoth Bo Lindbergh <(E-Mail Removed)>:
> Why is there no truncate operation in PerlIO?


Err...cos PerlIO's broken?
There seems to be some sort of abstraction of the operation, but systems
with ftruncate(2) always end up calling it on fileno($FH).

Ben

--
If you put all the prophets, | You'd have so much more reason
Mystics and saints | Than ever was born
In one room together, | Out of all of the conflicts of time.
http://www.velocityreviews.com/forums/(E-Mail Removed) The Levellers, 'Believers'
 
Reply With Quote
 
 
 
 
Charles DeRykus
Guest
Posts: n/a
 
      06-08-2006
Bo Lindbergh wrote:
> Why is there no truncate operation in PerlIO?
>


There is though: perldoc -f truncate

--
Charles DeRykus


 
Reply With Quote
 
Charles DeRykus
Guest
Posts: n/a
 
      06-08-2006
Charles DeRykus wrote:
> Bo Lindbergh wrote:
>> Why is there no truncate operation in PerlIO?
>>

>
> There is though: perldoc -f truncate
>


I think there is an emulation even on OS's
which don't have ftruncate(2).

On Win32 for instance, truncate still succeeds:

C:\temp>perl -V:d_truncate
d_truncate='undef';

C:\temp>perl
open my $fh, "+<", "foo" or die "open: $!";
truncate $fh,0 or die "truncate failed";
^D


--
Charles DeRykus
 
Reply With Quote
 
Bo Lindbergh
Guest
Posts: n/a
 
      06-08-2006
In article <(E-Mail Removed)>,
Charles DeRykus <(E-Mail Removed)> wrote:

> Bo Lindbergh wrote:
> > Why is there no truncate operation in PerlIO?
> >

>
> There is though: perldoc -f truncate


"PerlIO", not "Perl I/O". There's a difference.


/Bo Lindbergh
 
Reply With Quote
 
Bo Lindbergh
Guest
Posts: n/a
 
      06-08-2006
In article <(E-Mail Removed)>,
Ben Morrow <(E-Mail Removed)> wrote:

> Quoth Bo Lindbergh <(E-Mail Removed)>:
> > Why is there no truncate operation in PerlIO?

>
> Err...cos PerlIO's broken?
> There seems to be some sort of abstraction of the operation, but systems
> with ftruncate(2) always end up calling it on fileno($FH).


And so truncate fails with EBADF in the example below.

{
open(my $fh,">",\my $buffer)
or die "open: $!";
print $fh "Hello, World!\n"
or die "print: $!";
truncate($fh,5)
or die "truncate: $!";
}

This is sad, because truncating a Perl scalar is a perfectly
reasonable thing to want to do.


/Bo Lindbergh
 
Reply With Quote
 
Charles DeRykus
Guest
Posts: n/a
 
      06-08-2006
Bo Lindbergh wrote:
> In article <(E-Mail Removed)>,
> Charles DeRykus <(E-Mail Removed)> wrote:
>
>> Bo Lindbergh wrote:
>>> Why is there no truncate operation in PerlIO?
>>>

>> There is though: perldoc -f truncate

>
> "PerlIO", not "Perl I/O". There's a difference.
>


Oops, yes. That's "big boy" stuff...

--
Charles DeRykus
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Test::Unit::Omission - Unable to omit tests Champak Ch Ruby 11 03-09-2010 11:11 PM
Minor Omission in Explorer 64-bit TE-ret via WindowsKB.com Windows 64bit 1 10-13-2005 07:54 PM
STL: malloc_alloc - omission of types Shoban Jeyaraj C++ 2 02-17-2004 10:38 PM
Templates as inheritence omission workaround Ray Gardener C++ 5 12-27-2003 02:38 AM
perlio problem? redhat 9, perl 5.8.0 gordon Perl Misc 3 06-27-2003 09:39 AM



Advertisments