develooper Front page | perl.perl6.users | Postings from February 2019

Re: Start reading at a specific index?

Thread Previous | Thread Next
From:
ToddAndMargo via perl6-users
Date:
February 3, 2019 03:02
Subject:
Re: Start reading at a specific index?
Message ID:
ab567e77-6a12-c2ae-4840-68f554194515@zoho.com
On 2/2/19 3:16 AM, Shlomi Fish wrote:
> On Sat, 2 Feb 2019 01:08:39 -0800
> ToddAndMargo via perl6-users <perl6-users@perl.org> wrote:
> 
>> Hi All,
>>
>> Is there a way to modify this to start reading at
>> a specific index?  And include how many bytes (3000000)
>> to read as well?
>>
>>        my $FileHandle     = open( $FileName, :bin, :ro );
>>        my Buf $BinaryFile = $FileHandle.read( 3000000 );
>>
>> Many thanks,
>> -T
> 
> See https://docs.perl6.org/routine/seek .
> 
> 


Thank you!


I am not sure exactly what they mean by "$whence".

method seek(IO::Handle:D: Int:D $offset, SeekType:D $whence --> True)

     SeekFromBeginning: The beginning of the file.

my Bool $GoodRead = seek($FileHandle, $offset, SeekFromBeginning );
my Bool $GoodRead = seek.$FileHandle( $offset, SeekFromBeginning );

Or do I need to assign something to a variable called "$whence"?

Many thanks,
-T



-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About