, "<","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
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
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
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
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
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
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
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
[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
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
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
> "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
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
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
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
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
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
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:
>
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
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
"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/
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
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
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
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
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"
-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
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
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
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
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
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
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.
> >
&
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
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
> >
&
> > 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.
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
> -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
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
> -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
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
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
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
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]
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
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
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
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
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
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:
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
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
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]
"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
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
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 "
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
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
;
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
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
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
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.
-
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
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 ---
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-
>
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
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
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
> -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
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
--- 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
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]
72 matches
Mail list logo