Re: What is the easiest way to get the last line of a file.

2004-10-01 Thread $Bill Luebkert
Randy W. Sims wrote: On 9/30/2004 11:54 PM, $Bill Luebkert wrote: Petr Vileta wrote: So I decided on: open(TMP, $filename ) or die Cannot open $filename $!\n; @tmp = TMP; close( TMP); ($requiredword)=(split(/\s+/,pop(@tmp)))[0]; How to do this with file of 3GB size? :-) my

RE: What is the easiest way to get the last line of a file.

2004-10-01 Thread Brian Raven
Dave Blakemore wrote: Thanks for everyone's input. The file in question is of variable length (# of lines) but guaranteed to be of managable size. I did not mention (in order not to cloud the issue) that I just wanted the first word (seperated by white space) from that last line

Re: What is the easiest way to get the last line of a file.

2004-10-01 Thread Gisle Aas
$Bill Luebkert [EMAIL PROTECTED] writes: my $last_line; do{ $last_line = $_ if eof() } while ; That could take a while on a 3GB file. ;) In a bored moment I decided to figure out what the simplest program that get this right is. This is what I ended up with.

Looking for a regexp solution

2004-10-01 Thread Steve Sarapata
Hell-o gurus, First, as a lurker on this listserve I've seen some amazing code come through. Keep it up. Someday too I may be able to join the ranks of the enlightened. Second, I work in a Windows shop with a hoard of VB.NETers being the lone PERLer. I have two issues I think can be resolved

Re: Looking for a regexp solution

2004-10-01 Thread Craig Cardimon
You have spoken aloud my super secret mission here: To be able to join the ranks of the enlightened. Not once have I beseached this list for a solution to a problem and come away empty-handed. Steve Sarapata wrote: Hell-o gurus, First, as a lurker on this listserve I've seen some amazing code

RE: Looking for a regexp solution

2004-10-01 Thread Erik Felton
Here's a solution using XML::Simple And I cannot say enough about the value of the Regular Expression editor built into Komodo! Erik --- #! perl.exe use XML::Simple; my ($blob) = recordtag1aValue/tag1tag2aa:bb:cc:last/tag2/record; my ($p1, $result); my $XMLResultRef = XMLin($blob); my

Re: What is the easiest way to get the last line of a file.

2004-10-01 Thread $Bill Luebkert
Gisle Aas wrote: $Bill Luebkert [EMAIL PROTECTED] writes: my $last_line; do{ $last_line = $_ if eof() } while ; That could take a while on a 3GB file. ;) In a bored moment I decided to figure out what the simplest program that get this right is. This is what I ended up with.

Re: Looking for a regexp solution

2004-10-01 Thread $Bill Luebkert
Steve Sarapata wrote: Hell-o gurus, First, as a lurker on this listserve I've seen some amazing code come through. Keep it up. Someday too I may be able to join the ranks of the enlightened. Second, I work in a Windows shop with a hoard of VB.NETers being the lone PERLer. I have two

RE: Looking for a regexp solution

2004-10-01 Thread Bullock, Howard A.
use strict; my ($blob) = recordtag1aValue/tag1tag2aa:bb:cc:last/tag2/record; my ($result, $last) = $blob =~ /\/tag1tag2(.*:(.*))\/tag2/i; print $result\n; print $last\n; -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Sarapata Sent: Friday,

RE: Looking for a regexp solution

2004-10-01 Thread Steve Sarapata
Thanks to all. I've got working solution. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Sarapata Sent: Friday, October 01, 2004 8:08 AM To: [EMAIL PROTECTED] Subject: Looking for a regexp solution Hell-o gurus, First, as a lurker on this

Re: Looking for a regexp solution

2004-10-01 Thread Mark Mielke
On Fri, Oct 01, 2004 at 06:14:52AM -0700, $Bill Luebkert wrote: my ($blob) = recordtag1aValue/tag1tag2aa:bb:cc:last/tag2/record; $blob =~ /tag1([^]+)\/tag1/; print $1, \n; If you have to do it this way (rather than a real XML parser/scanner), I would suggest using list assign, including the

Re: What is the easiest way to get the last line of a file.

2004-10-01 Thread Andy_Bach
Using a 25k line dictionary file: Benchmark: timing 100 iterations of array, assign, eof... array: 40 wallclock secs (39.07 usr + 0.42 sys = 39.49 CPU) @ 2.53/s (n=100) assign: 20 wallclock secs (19.63 usr + 0.25 sys = 19.88 CPU) @ 5.03/s (n=100) eof: 19 wallclock secs (18.13

IO::Socket

2004-10-01 Thread Louie Iturzaeta
Hello Perl Guru's! Does anyone know of a way to get the remote clients hostname with IO::Socket? I am new to this socket programming and I am writing a simple socket server that uses telnet as a client. I want to have the remote clients hostname appear on the server console when they connect. Any

Re: ls dates vs. stat() ages

2004-10-01 Thread Jerry
You're right, I had confusedst_ctimeas the file creation time, it's the last time the file was changed. I've been working in UNIX for 22 years starting with PDP/11-780 and everything in between including two N-Cube Supercomputers. This is from the same book I referenced before, it's a

Re: ls dates vs. stat() ages

2004-10-01 Thread Jerry
Mark, Within UNIX SVR4.x, ctime iswell defined as the following: ctime - last time file/inode changed You are correct, most people confuse ctime for the file creation time, myself included, it's not hard to forget if you don't work with it all the time! Jerry Simons Sn. System Analyst

RE: A shorter regexp?

2004-10-01 Thread Arms, Mike
Not shorter, but maybe more readable :-) This is a regex I have to match ls -la output on Unix/Linux/Cygwin systems for directories, files, and symlinks. /^ ([-dl]\S{9}) # perms (\+)?\s+ # access control list present (\d+)\s+ # number

RE: A shorter regexp?

2004-10-01 Thread Gerber, Christopher J
At one point in my script, I still use ls to get a line of data for files, what I'm trying for is a regexp that'll pull the filename out--including soft links. What I have right now--while it works--is rather, um, long: $line =~ /^[-l][-rswx]{9}\s+\d+\s+\w+\s+\w+\s+\d+\s+\w+\s+\d+\s+

Re: A shorter regexp?

2004-10-01 Thread Todd Beverly
[EMAIL PROTECTED] wrote: At one point in my script, I still use ls to get a line of data for files, what I'm trying for is a regexp that'll pull the filename out--including soft links. What I have right now--while it works--is rather, um, long: $line =~

Re: ls dates vs. stat() ages

2004-10-01 Thread Mark Mielke
On Fri, Oct 01, 2004 at 03:42:08PM -0400, Jerry wrote: In filehdr.h should be the answer to the data object that holds the file's creation time (and date), it's name is f_timdat. Here is the structure for filehdr: ... longf_timdattime and date object file

RE: A shorter regexp?

2004-10-01 Thread Arms, Mike
Todd Beverly [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: At one point in my script, I still use ls to get a line of data for files, what I'm trying for is a regexp that'll pull the filename out--including soft links. What I have right now--while it works--is rather, um, long: $line =~

Re: ls dates vs. stat() ages

2004-10-01 Thread T. William Schmidt
Concur with Mark. That date is the product of compilation. This is a long response but is worth reading for Perl folks who work in both Win32 and UNIX and are concerned with writing portable Perl. Or when portability is not possible, how to deal with the different semantics of the Perl stat

Re: IO::Socket

2004-10-01 Thread $Bill Luebkert
Louie Iturzaeta wrote: Hello Perl Guru's! Does anyone know of a way to get the remote clients hostname with IO::Socket? I am new to this socket programming and I am writing a simple socket server that uses telnet as a client. I want to have the remote clients hostname appear on the server