Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Loading a part of the file to array using Tie::File

by karlgoethebier (Abbot)
on Nov 22, 2017 at 10:56 UTC ( [id://1204007]=note: print w/replies, xml ) Need Help??


in reply to Loading a part of the file to array using Tie::File

"...a part of a file using Tie::File..."

You might try something like this:

#!/usr/bin/env perl use strict; use warnings; use feature qw(say); use Tie::File; my $file = q(data.txt); my ( $start, $end ) = ( 1, 3 ); tie my @array, 'Tie::File', $file or die $!; for ( $start .. $end ) { $_ = -$_; say qq($_: ), $array[$_]; } untie @array; __END__ karls-mac-mini:monks karl$ ./tie.pl -1: cuke -2: nose -3: baz karls-mac-mini:monks karl$ cat data.txt foo bar baz nose cuke

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1204007]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2024-04-25 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found