Sponsored Content
Full Discussion: Perl: Reading in reverse.
Top Forums Shell Programming and Scripting Perl: Reading in reverse. Post 302364257 by mrwatkin on Thursday 22nd of October 2009 12:17:23 PM
Old 10-22-2009
Perl: Reading in reverse.

Is there a means of reading files in reverse? I just want to be able to read a file from the beginning and once I read a particular line, I start reading lines backward from there.

Now, I could toss everything into a string array, but the file I'll be reading is roughly 100MB. I don't want 100MB stored in memory. Any ideas here?

Also, is there a way to immediately purge an Array of it's elements without looping and popping? I'm looking to be efficient here.

Last edited by mrwatkin; 10-22-2009 at 01:23 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl Reading from File

is there a perl equivalent to sscanf? or something where I get the strings separated by spaces? (1 Reply)
Discussion started by: karyn1617
1 Replies

2. Shell Programming and Scripting

perl not reading my variable

I'm trying to make changes in a file using the following bash script: #!/bin/bash MYHOME=`echo $HOME` README=$MYHOME"/environment" IAM=`whoami` CHANGEPATHLIST="TALOG TACONFIG TAINFO TAWORK TMPSPACE" for var in $CHANGEPATHLIST do perl -pi -e 's/sacuser1/$IAM/ if m/$var/' $README... (3 Replies)
Discussion started by: yoonixq4u
3 Replies

3. Shell Programming and Scripting

PerL Reverse the string.

Hi, I am very new to perl. My question: How i can reverse the given string using substr function but without using reverse function in perl? Anybody please help. thanks, -Lalit (3 Replies)
Discussion started by: email-lalit
3 Replies

4. Shell Programming and Scripting

perl - reading from a file conditionally

Hi, I am new to perl. I want to read from a file on the basis of some conditions.. I want to define parameters in a configuration file in such a manner like... etc.. in my perl script, theer is a variable like this.. then i want to read values from first if block from the file... (1 Reply)
Discussion started by: shellwell
1 Replies

5. Shell Programming and Scripting

Perl - Reading keyboard keystroke

Hello All, I wounder if any one know if perl have the ability to run script in the background which record each keyboard keystorke? If yes , how can I implement the part which reading the keyboard keystroke? Is there any moudle that handle it ? Thanks a head Alalush (1 Reply)
Discussion started by: Alalush
1 Replies

6. Shell Programming and Scripting

Reading values in perl

Hi whats the easiest way to read data from a feed file? sample data in a file called data.txt: name = varun ip = '23.43.123.2' address = "asd, blah blah blah ..... @#!$%$#%" i want to use this data in a perl script. I thought of initially reading it line by line n then cutting... (7 Replies)
Discussion started by: VGR
7 Replies

7. Shell Programming and Scripting

Perl: Reading data from other file

Hi, I am writting some perl scripts for daily backup process. In which I want to pass some data/referance from another txt file. Text file contains only one column and multiple rows. I want to pass this data to variables of another perl script. e.g. Refdoc.txt file contains data as: perl1... (3 Replies)
Discussion started by: n.dba
3 Replies

8. UNIX for Dummies Questions & Answers

reading a file in Perl

If a form's action is the following Perl script how do I make it print the entire contents of the file on the screen? if(param()) { my $uploadedFile = param('file');#in the html page 'file' is the value of the name attribute of the input my $fh = upload($uploadedFile); ... (1 Reply)
Discussion started by: zerohour
1 Replies

9. Shell Programming and Scripting

for loop - reverse reading

All, Here is my for loop export CFGLIST="LIST1 LIST2 LIST3" for i in $CFGLIST do echo print $i done The output will be LIST1 LIST2 LIST3 But i want it display LIST3 LIST2 LIST1 (8 Replies)
Discussion started by: baluchen
8 Replies

10. Shell Programming and Scripting

Perl :: reading values from Data Dumper reference in Perl

Hi all, I have written a perl code and stored the data into Data structure using Data::Dumper module. But not sure how to retreive the data from the Data::Dumper. Eg. Based on the key value( Here CRYPTO-6-IKMP_MODE_FAILURE I should be able to access the internal hash elements(keys) ... (1 Reply)
Discussion started by: scriptscript
1 Replies
io_waitread(3)						     Library Functions Manual						    io_waitread(3)

NAME
io_waitread - read from a descriptor SYNTAX
#include <io.h> int io_waitread(int64 fd,char* buf,int64 len); DESCRIPTION
io_waitread tries to read len bytes of data from descriptor fd into buf[0], buf[1], ..., buf[len-1]. (The effects are undefined if len is 0 or smaller.) There are several possible results: o o_waitread returns an integer between 1 and len: This number of bytes was available for immediate reading; the bytes were read into the beginning of buf. Note that this number can be, and often is, smaller than len; you must not assume that io_waitread always succeeds in reading exactly len bytes. o io_waitread returns 0: No bytes were read, because the descriptor is at end of file. For example, this descriptor has reached the end of a disk file, or is reading an empty pipe that has been closed by all writers. o io_waitread returns -3, setting errno to something other than EAGAIN: No bytes were read, because the read attempt encountered a persis- tent error, such as a serious disk failure (EIO), an unreachable network (ENETUNREACH), or an invalid descriptor number (EBADF). SEE ALSO
io_nonblock(3), io_waitread(3), io_waitreadtimeout(3) io_waitread(3)
All times are GMT -4. The time now is 05:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy