Do you only need the last line or are you processing each line of the file?
If you only need the last line you can use:
while (READIN) {
$last = $_;
}
# ... perform your match on $last here
-Dave
- Original Message -
From: Grace Huang [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Title: RE: how to match the last line in a file
could you not also do
open(FILE, file_for_read.txt);
@array = FILE;
$last_line_number = $#array;
$last_line = $array[$last_line_number];
??
you may have to add one or subtract one I can't remember =)
-Original Message-
From: Dave
You could do that but if the file is VERY large it can take up quie a bit of
memory to hold the whole file in the array.
Matthew
--- FARRINGTON, RYAN [EMAIL PROTECTED] wrote:
could you not also do
open(FILE, file_for_read.txt);
@array = FILE;
$last_line_number = $#array;
$last_line =
Title: RE: how to match the last line in a file
Another possibility is to begin by
appending a known unique new last line, testing for it each time, and quitting
when you reach it.
-Original Message-
From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of FARRINGTON,
- Original Message -
From: Grace Huang [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, June 19, 2003 3:16 PM
Subject: how to match the last line in a file
Hi
I use while (my $line = READIN) {...} to read a file, how can I determine
if a line is the last line in the file since I
Hello.
I am accustomed to trapping errors and piping them to Unix Mail.
Does anyone know of a utility to be exploited this way under DOS?
Thanks in advance,
-
Peter Lehman[EMAIL PROTECTED]
Boeing SGML
There are several Perl SMTP modules that will work with both
Windows/DOS and Unix. That would be my first preference. Check the CPAN
archive http://www.perl.com/CPAN-local/.
Or, you can use blat which most sites seem to prefer
http://www.interlog.com/~tcharron/blat.html
On Thursday, June 19,
Title: Message
I'm writing an app
that allows the user to search for 1+ files in a directory using either standard
Unix wildcard characters, or a regexp.
Basically, I read
all the directory entries using readdir, and iterate through themdoing a
regexp match of the entry against the search
---8---
Basically, I read all the directory entries using readdir, and iterate
through them doing a regexp match of the entry against the search
string. If a Unix-wildcard formatted string is entered, I need to do
the following
Escape all regexp meta characters that may be legitimate
Perfect. Thanks very much.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Allegakoen, Justin Devanandan
Sent: Friday, 20 June 2003 11:57 AM
To: [EMAIL PROTECTED]
Subject: RE: Regexp problem
---8---
Basically, I read all the directory
10 matches
Mail list logo