Re: translate following files based on the last line of the previous file

2012-04-23 Thread lina
, "<","text_2.xvg"; while(<$fh>){ print $_; } Of course, it is possible to read the last line of a file without resorting to creating a child process. See, for example, the module File::ReadBackwards. Thanks. Here I came up a working script (unavoidably clumsy). I don&#

Re: translate following files based on the last line of the previous file

2012-04-23 Thread lina
t;$fh>){ print $_; } Of course, it is possible to read the last line of a file without resorting to creating a child process. See, for example, the module File::ReadBackwards. Thanks. Here I came up a working script (unavoidably clumsy). I don't know how to refine it, or make i

Re: translate following files based on the last line of the previous file

2012-04-22 Thread Jim Gibson
stem function. It does not return the output of the child process to your program. For that, you need the qx() operator, or backticks: my $dict = qx("tail -n 1 text_1.xvg"); > print $dict; > print "\n\n"; > open my $fh, "<","text_2.xvg"; &g

translate following files based on the last line of the previous file

2012-04-22 Thread lina
Hi, I have a series of files. $ cat text_1.xvg 0 0 1 2 3 2 1 0 2 3 4 1 2 0 3 $ cat text_2.xvg 0 0 1 2 3 2 1 0 3 2 4 1 3 0 2 I wish to translate the text_2 numbers (except the first field) based on the last line of the text_1.xvg namely text_2.xvg will

Re: read the time from last line of a file in unix

2008-09-10 Thread Mr. Shawn H. Corey
On Tue, 2008-09-09 at 22:44 -0700, John W. Krahn wrote: > Rodrick Brown wrote: > > On Tue, Sep 9, 2008 at 3:23 PM, <[EMAIL PROTECTED]> wrote: > >> > >> i want get the time specified in last line of the file. > >> For eg: > >> $tail -2 test.log

Re: read the time from last line of a file in unix

2008-09-09 Thread John W. Krahn
Rodrick Brown wrote: On Tue, Sep 9, 2008 at 3:23 PM, <[EMAIL PROTECTED]> wrote: i want get the time specified in last line of the file. For eg: $tail -2 test.log 2008 aug 25 14:48:42.800 Sending ping message; 2008 aug 25 14:48:43.390 Sending ping message; The file size is huge, so i don

Re: read the time from last line of a file in unix

2008-09-09 Thread Rodrick Brown
On Tue, Sep 9, 2008 at 3:23 PM, <[EMAIL PROTECTED]> wrote: > Hi All, > > i want get the time specified in last line of the file. > For eg: > $tail -2 test.log > 2008 aug 25 14:48:42.800 Sending ping message; > 2008 aug 25 14:48:43.390 Sending ping message; > The fil

Re: read the time from last line of a file in unix

2008-09-09 Thread Mr. Shawn H. Corey
On Tue, 2008-09-09 at 12:23 -0700, [EMAIL PROTECTED] wrote: > Hi All, > > i want get the time specified in last line of the file. > For eg: > $tail -2 test.log > 2008 aug 25 14:48:42.800 Sending ping message; > 2008 aug 25 14:48:43.390 Sending ping message; > The file size

Re: read the time from last line of a file in unix

2008-09-09 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi All, Hello, i want get the time specified in last line of the file. For eg: $tail -2 test.log 2008 aug 25 14:48:42.800 Sending ping message; 2008 aug 25 14:48:43.390 Sending ping message; The file size is huge, so i dont want to read the entire file to get the

Re: read the time from last line of a file in unix

2008-09-09 Thread Jeff Pang
2008/9/10 <[EMAIL PROTECTED]>: > Hi All, > > i want get the time specified in last line of the file. > For eg: > $tail -2 test.log > 2008 aug 25 14:48:42.800 Sending ping message; > 2008 aug 25 14:48:43.390 Sending ping message; > The file size is huge, so i dont w

read the time from last line of a file in unix

2008-09-09 Thread devika84
Hi All, i want get the time specified in last line of the file. For eg: $tail -2 test.log 2008 aug 25 14:48:42.800 Sending ping message; 2008 aug 25 14:48:43.390 Sending ping message; The file size is huge, so i dont want to read the entire file to get the last line. Is there any way to get the

Re: how to read the last line of a file directly?

2008-07-07 Thread Randal L. Schwartz
> "Thomas" == Thomas Bätzler <[EMAIL PROTECTED]> writes: Thomas> Off the top of my head: And off the top of your head, you reinvented File::ReadBackwards for no real purpose. Might as well use the tested module instead. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503

RE: how to read the last line of a file directly?

2008-07-06 Thread Thomas Bätzler
loody <[EMAIL PROTECTED]> asked: > I try to read the last line of a file directly instead of using > while(<>) or something else to read each line until "undef" > bumped to me. > If you know some build-in functions or another modules for me > to use, pl

Re: how to read the last line of a file directly?

2008-07-06 Thread Amit Saxena
Hi Though I am not very sure, but can we use inbuilt seek function in perl ? Regards, Amit Saxena On Mon, Jul 7, 2008 at 12:39 AM, Rob Dixon <[EMAIL PROTECTED]> wrote: > loody wrote: > > > > I try to read the last line of a file directly instead of using > > while(&l

Re: how to read the last line of a file directly?

2008-07-06 Thread Rob Dixon
loody wrote: > > I try to read the last line of a file directly instead of using > while(<>) or something else to read each line until "undef" bumped to > me. > If you know some build-in functions or another modules for me to use, > please help me. Like

Re: how to read the last line of a file directly?

2008-07-06 Thread Gunnar Hjalmarsson
loody wrote: I look at http://perldoc.perl.org/index-modules-F.html but I cannot see File::Tail. File::Tail is not a core module. Neither is File::ReadBackwards which was suggested by somebody else. You get non-core modules from CPAN http://search.cpan.org/ -- Gunnar Hjalmarsson Email: http

Re: how to read the last line of a file directly?

2008-07-06 Thread Telemachus Odysseos
On Sun Jul 06 2008 @ 8:09, loody wrote: > Dear all: > I try to read the last line of a file directly instead of using > while(<>) or something else to read each line until "undef" bumped to > me. > If you know some build-in functions or another modules for me to u

Re: how to read the last line of a file directly?

2008-07-06 Thread loody
Hi: I look at http://perldoc.perl.org/index-modules-F.html but I cannot see File::Tail. Would you please tell me where I can get the document describing how to use it? appreciate your help, miloody 2008/7/6 Aruna Goke <[EMAIL PROTECTED]>: > loody wrote: >> >> Dear all: >

Re: how to read the last line of a file directly?

2008-07-06 Thread Aruna Goke
loody wrote: Dear all: I try to read the last line of a file directly instead of using while(<>) or something else to read each line until "undef" bumped to me. If you know some build-in functions or another modules for me to use, please help me. appreciate your help, miloody

how to read the last line of a file directly?

2008-07-06 Thread loody
Dear all: I try to read the last line of a file directly instead of using while(<>) or something else to read each line until "undef" bumped to me. If you know some build-in functions or another modules for me to use, please help me. appreciate your help, miloody -- To uns

Re: Last line issue

2008-01-27 Thread Dr.Ruud
"John W. Krahn" schreef: > tr/\t/ /s; To also squash adjacent space characters: tr/\t / /s; -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Last line issue

2008-01-26 Thread John W. Krahn
Andrej Kastrin wrote: John W. Krahn wrote: This should do what you want: #!/usr/bin/perl use warnings; use strict; my $FNI = shift; my $FNO = "$FNI.dat"; open my $OUT, '>', $FNO or die "Cannot open '$FNO' $!"; open my $IN, '<', $FNI or die "Cannot open '$FNI' $!"; my ( $id, $line ); while

Re: Last line issue

2008-01-26 Thread Andrej Kastrin
Dear Jonh, many, many thanks for your quick answer. I modified your script a bit: $line .= $_ if /Id|To|From/; print $OUT "$id\t$line\n" if m!/Note!; to: $line .= $_ if m!! .. m!!; print $OUT "$id\t$line\n" if m!!; but some problem still persists with the output: 001 001Tho

Re: Last line issue

2008-01-26 Thread John W. Krahn
Andrej Kastrin wrote: Dear all, Hello, to pre-process my XML dataset in run simple Perl script on it, which extract Id identifier from XML data and paste the whole XML record to it. For example, the input data looks like: 001 Thomas Joana 002

Last line issue

2008-01-26 Thread Andrej Kastrin
Dear all, to pre-process my XML dataset in run simple Perl script on it, which extract Id identifier from XML data and paste the whole XML record to it. For example, the input data looks like: 001 Thomas Joana 002 John Paula

Re: Get the byte position of previous line from last line in file

2007-11-06 Thread Gunnar Hjalmarsson
sivasakthi wrote: I have the text file as following, this first line this is the second line this the third line this is the fourth line this is the sixth line this is the seventh line while opening and reading that text file, is it possible to get the byte position of "this is the sixth line"

Re: Get the byte position of previous line from last line in file

2007-11-05 Thread Jeff Pang
-Original Message- >From: sivasakthi <[EMAIL PROTECTED]> > > >while opening and reading that text file, is it possible to get the byte >position of "this is the sixth line" ?? > Yes. see perldoc -f tell -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMA

Get the byte position of previous line from last line in file

2007-11-05 Thread sivasakthi
Hi All, I have the text file as following, this first line this is the second line this the third line this is the fourth line this is the sixth line this is the seventh line while opening and reading that text file, is it possible to get the byte position of "this is the sixth line" ?? Tha

RE: CUt first and last line from a file (DATA)

2003-09-10 Thread Paul Kraus
econd lines though. However if they are not records the code above will have them skipped. -Original Message- From: LoneWolf [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 10, 2003 5:04 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: CUt first and last line from a

CUt first and last line from a file (DATA)

2003-09-10 Thread LoneWolf
GARNOR|09/10/03 GARNOR|141023|BUDDY|Y54321|[EMAIL PROTECTED]|Y|Y GARNOR|141033|BUDD|Y5432|[EMAIL PROTECTED]|Y|Y GARNOR|141043|BUD|Y5432|[EMAIL PROTECTED]|Y|Y GARNOR|141053|BU|Y54|[EMAIL PROTECTED]|Y|Y -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTE

RE: CUt first and last line from a file

2003-09-10 Thread Paul Kraus
Can you send a sample of the data that you are parsing? -Original Message- From: LoneWolf [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 10, 2003 4:42 PM To: [EMAIL PROTECTED] Subject: CUt first and last line from a file I'm parsing every file in a directory, cutting white

CUt first and last line from a file

2003-09-10 Thread LoneWolf
I'm parsing every file in a directory, cutting whitespace out (per a previous request) and so far it is working great, but I have come across a couple of things: 1. I either need to cut the first and last line of each file or 2. I need to skip the line if one of the fields is empty. I

Re: How to get 1st line, last line and no of lines in a file

2003-02-20 Thread Lance
gt; impressive hardware... > > > > dunno what to do in the DOS world, other than the 'expensive' file > > processing. > > > > PS, I really need to get back into 'nix. I can't believe I have forgotten > > such *simple* stuff... ugh. > > &

Re: How to get 1st line, last line and no of lines in a file

2003-02-20 Thread Gary Stainburn
TED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > > -Original Message- > > > From: Madhu Reddy [mailto:[EMAIL PROTECTED]] > > > Sent: Wednesday, February 19, 2003 1:25 PM > > > To: [EMAIL PROTECTED] > > > Subj

Re: How to get 1st line, last line and no of lines in a file

2003-02-20 Thread Lance
s:[EMAIL PROTECTED]... > > > > -Original Message- > > From: Madhu Reddy [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, February 19, 2003 1:25 PM > > To: [EMAIL PROTECTED] > > Subject: How to get 1st line, last line and no of lines in a file > > &

RE: How to get 1st line, last line and no of lines in a file

2003-02-19 Thread Paul
> > Subject: How to get 1st line, last line and no of lines in a file > > is there any perl functions available for that ? > > suppose, if file have millions of records, ok If it's a small file, try Tie::File by (I believe) Mark Jason Dominus. It's very cool.

Re: How to get 1st line, last line and no of lines in a file

2003-02-19 Thread R. Joseph Newton
Madhu Reddy wrote: > Hi, >How to get first line, last line and no of lines in > a file. > > is there any perl functions available for that ? > right now what i am doing is > > open file > while ( > { > $lines++; > } > close(FH) > > This ope

RE: How to get 1st line, last line and no of lines in a file

2003-02-18 Thread Toby Stuart
> -Original Message- > From: Madhu Reddy [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, February 19, 2003 1:25 PM > To: [EMAIL PROTECTED] > Subject: How to get 1st line, last line and no of lines in a file > > > Hi, >How to get first line, last line

How to get 1st line, last line and no of lines in a file

2003-02-18 Thread Madhu Reddy
Hi, How to get first line, last line and no of lines in a file. is there any perl functions available for that ? right now what i am doing is open file while ( { $lines++; } close(FH) This operation is expensive.. suppose, if file have millions of records, it will take more time I

RE: Last Line in Packages

2002-12-11 Thread Bob Showalter
> -Original Message- > From: NYIMI Jose (BMB) [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, December 11, 2002 1:00 PM > To: popeye _; [EMAIL PROTECTED] > Subject: RE: Last Line in Packages > > > See this archive : > > http://archive.develooper.com/begi

RE: Last Line in Packages

2002-12-11 Thread NYIMI Jose (BMB)
See this archive : http://archive.develooper.com/beginners%40perl.org/msg38109.html José. > -Original Message- > From: popeye _ [mailto:[EMAIL PROTECTED]] > Sent: Monday, December 09, 2002 11:47 PM > To: [EMAIL PROTECTED] > Subject: Last Line in Packages > > &g

Last Line in Packages

2002-12-11 Thread popeye _
Often, but not always, I see the last line in a perl module as 1; Is this to force the module to exit 'true', forcing it to compile? Thanks! Jeff _ Tired of spam? Get advanced junk mail protection with MS

Re: Grab last line like `tail'

2002-12-01 Thread Danijel Tasov
Harry Putnam wrote: > Is there a perl equivalent to the unix `tail' command? Where I could > grab the last line from a file without having to read the whole file? There is the module File::ReadBackwards; # perl -MCPAN -e 'install File::ReadBackwards' $ perldoc File::ReadB

Grab last line like `tail'

2002-12-01 Thread Harry Putnam
Is there a perl equivalent to the unix `tail' command? Where I could grab the last line from a file without having to read the whole file? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: oneliner to delete last line of file

2002-11-29 Thread John W. Krahn
Ramprasad A Padmanabhan wrote: > > Hello all Hello, > I am using redhat linux 7.2 > > I am required to delete the last line of a file. Now I am doing a > cumbersome thing like this > > perl -e '@_=<>;pop @_;print @_;' $FILE > $FILE.tmp > mv $FILE

Re: oneliner to delete last line of file

2002-11-29 Thread Sudarshan Raghavan
On Fri, 29 Nov 2002, Ramprasad A Padmanabhan wrote: > > Hello all > > I am using redhat linux 7.2 > > I am required to delete the last line of a file. Now I am doing a > cumbersome thing like this > > perl -e '@_=<>;pop @_;print @_;' $FILE > $FI

oneliner to delete last line of file

2002-11-29 Thread Ramprasad A Padmanabhan
Hello all I am using redhat linux 7.2 I am required to delete the last line of a file. Now I am doing a cumbersome thing like this perl -e '@_=<>;pop @_;print @_;' $FILE > $FILE.tmp mv $FILE.tmpl $FILE Cant I do it any better -- To unsubscribe, e-mail: [EMAIL PROTEC

Re: how to get the last line of a file

2002-10-11 Thread david
Alex Chen wrote: > hi, all > > i want to know how to get the last line of > a file .i know the func read has a paramenter offset but i don't know how > to use it.please help!!! > > thanks > alex chen try this: #!/usr/bin/perl -w; use s

Re: how to get the last line of a file

2002-10-11 Thread John W. Krahn
Alex Chen wrote: > > hi, all Hello, > i want to know how to get the last line of > a file .i know the func read has a paramenter offset but i don't know how to > use it.please help!!! 1) Install http://search.cpan.org/author/URI/File-ReadBackwards-0.98/ use File::R

RE: how to get the last line of a file

2002-10-11 Thread NYIMI Jose (BMB)
use Tie::File; tie @array, 'Tie::File', "file.txt" or die $!; my $last_line=$array[$#array]; José. > -Original Message- > From: alex chen [mailto:[EMAIL PROTECTED]] > Sent: Friday, October 11, 2002 8:57 AM > To: [EMAIL PROTECTED] > Subject:

Re: how to get the last line of a file

2002-10-11 Thread David Garamond
alex chen wrote: > hi, all > > i want to know how to get the last line of > a file .i know the func read has a paramenter offset but i don't know how to > use it.please help!!! the easy way (but inefficient): # read until the last line open F, "file.txt" or d

Re: how to get the last line of a file

2002-10-11 Thread Jean Padilla
alex chen a écrit : > > hi, all > > i want to know how to get the last line of > a file .i know the func read has a paramenter offset but i don't know how to > use it.please help!!! > > thanks > alex chen > > -- > To unsubscri

how to get the last line of a file

2002-10-11 Thread alex chen
hi, all i want to know how to get the last line of a file .i know the func read has a paramenter offset but i don't know how to use it.please help!!! thanks alex chen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Last line of file...

2001-12-18 Thread Michael R. Wolf
"James Kelty" <[EMAIL PROTECTED]> writes: > Well, I thought of that earlier, but I also thought that I > was not guaranteed that the order of an array was > unreliable, so I may not actually be getting the 'last' of > the file. True or untrue ? By definition: Arrays are ordered. Diamond

Re: Last line of file...

2001-12-18 Thread John W. Krahn
James Kelty wrote: > > Is there a document in perldoc that tells the best way to get the last line > of a file? Below is my usual code for reading a file. > > #!/usr/bin/perl -w > > $file = qq(/some/file/); > > open FILE, "$file" or die "Canno

RE: Last line of file...

2001-12-18 Thread Peter Cornelius
If you know the size of the last line you can use 'seek' to get there, but this operates on bytes, not chars. If the records are of a fixed size this would be the most efficient way to do it. use POSIX; #This gives us the SEEK_END constant seek (FH, -$recsize, SEEK_END) or die "

RE: Last line of file...

2001-12-18 Thread Peter Cornelius
You are probably thinking of associative arrays. They are declared with the '%' character in the lead and do not have any intelligible order. With a normal array the order is guaranteed. If your files aren't to big I've found this idiom useful when I just want the

Re: Last line of file...

2001-12-18 Thread Michael Fowler
On Tue, Dec 18, 2001 at 10:43:54AM -0800, James Kelty wrote: > Well, I thought of that earlier, but I also thought that I was not > guaranteed that the order of an array was unreliable, so I may not actually > be getting the 'last' of the file. True or untrue ? Arrays are ordered, they must be, t

Re: Last line of file...

2001-12-18 Thread Agustin Rivera
; Cc: "James Kelty" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, December 18, 2001 11:02 AM Subject: Re: Last line of file... > If the file is huge I wouldn't recommend doing so.. because it puts all > the file into your array > > I think you can go

Re: Last line of file...

2001-12-18 Thread Etienne Marcotte
If the file is huge I wouldn't recommend doing so.. because it puts all the file into your array I think you can go directly to the last line if you know exactly the length of the last line, am I wrong on this one? Like seeking to the end and reading backwards of n chars? Etienne Ag

RE: Last line of file...

2001-12-18 Thread James Kelty
Ok, thanks! -James -Original Message- From: Agustin Rivera [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 18, 2001 10:49 AM To: James Kelty; [EMAIL PROTECTED] Subject: Re: Last line of file... I've never had an instance where that didn't work. I use for $a(0..$#array

Re: Last line of file...

2001-12-18 Thread smoot
e done here. Something like this while loop fragment is a simple way to approach the problem: my $last_line = ""; while () { $last_line = $_; } $last_line will then hold the last line of the file with the trailing line terminator. You can chomp it off, if it is unneeded. -

Re: Last line of file...

2001-12-18 Thread Agustin Rivera
a" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, December 18, 2001 10:43 AM Subject: RE: Last line of file... > Well, I thought of that earlier, but I also thought that I was not > guaranteed that the order of an array was unreliable, so I may not actual

RE: Last line of file...

2001-12-18 Thread James Kelty
t: Tuesday, December 18, 2001 10:44 AM To: James Kelty; [EMAIL PROTECTED] Subject: Re: Last line of file... In that case, do this.. open(IN, "filename"); @file=; print "$file[$#file]\n"; Agustin Rivera Webmaster, Pollstar.com http://www.pollstar.com - Original Message ---

Re: Last line of file...

2001-12-18 Thread Agustin Rivera
ROTECTED]> Sent: Tuesday, December 18, 2001 10:27 AM Subject: RE: Last line of file... > Thank you, but I would like to programmatically do it from perl rather than > using shell commands. Make the whole script more portable. > > -James > > > -Original Message- >

RE: Last line of file...

2001-12-18 Thread McCollum, Frank
Sent: Tuesday, December 18, 2001 1:22 PM To: [EMAIL PROTECTED] Subject: Last line of file... Is there a document in perldoc that tells the best way to get the last line of a file? Below is my usual code for reading a file. #!/usr/bin/perl -w $file = qq(/some/file/); open FILE, "$fi

Re: Last line of file...

2001-12-18 Thread Agustin Rivera
mber 18, 2001 10:21 AM Subject: Last line of file... > Is there a document in perldoc that tells the best way to get the last line > of a file? Below is my usual code for reading a file. > > > #!/usr/bin/perl -w > > $file = qq(/some/file/); > > open FILE, "$file&q

Last line of file...

2001-12-18 Thread James Kelty
Is there a document in perldoc that tells the best way to get the last line of a file? Below is my usual code for reading a file. #!/usr/bin/perl -w $file = qq(/some/file/); open FILE, "$file" or die "Cannot open file: $!\n"; while() { do something with the line; } c

RE: Last line

2001-09-07 Thread Bob Showalter
> -Original Message- > From: Jorge Goncalvez [mailto:[EMAIL PROTECTED]] > Sent: Friday, September 07, 2001 6:10 AM > To: [EMAIL PROTECTED] > Subject: Re:Last line > > > Hi, how to parse the last line of a file. > > I have this code: > $pb->destroy

Re: last line

2001-07-27 Thread Walt Mankowski
COLLINEAU writes: > How can i do to delete the last line of a file ? >From perlfaq5... How do I change one line in a file/delete a line in a file/insert a line in the middle of a file/append to the beginning of a file? In the unique case of deleting lines at t

Re: last line

2001-07-27 Thread Greg Meckes
--- COLLINEAU Franck FTRD/DMI/TAM <[EMAIL PROTECTED]> wrote: > Hi! > > How can i do to delete the last line of a file ? > > Thanks > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > Try: #Get the dat

last line

2001-07-27 Thread COLLINEAU Franck FTRD/DMI/TAM
Hi! How can i do to delete the last line of a file ? Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]