hi,
i need to delete all blank lines from the text file
wrote following code. however, all the blank lines are not getting deleted.
please suggest
open FILE,+, 'C:\Users\bvcontrolbuild\Desktop\test.txt';
while (FILE)
{
chomp;
push (@lines, $_\n);
}
close
,
i need to delete all blank lines from the text file
wrote following code. however, all the blank lines are not getting
deleted. please suggest
open FILE,+, 'C:\Users\bvcontrolbuild\Desktop\test.txt';
while (FILE)
{
chomp;
push (@lines, $_\n);
}
close
Hi Irfan,
On Mon, 1 Oct 2012 01:34:51 -0700 (PDT)
Irfan Sayed irfan_sayed2...@yahoo.com wrote:
hi,
i need to delete all blank lines from the text file
How do you define a blank line? Is it an empty line? Is it a line that contains
only
whitespace?
In any case, here are a few comments
from text file
Hi Irfan,
On Mon, 1 Oct 2012 01:34:51 -0700 (PDT)
Irfan Sayed irfan_sayed2...@yahoo.com wrote:
hi,
i need to delete all blank lines from the text file
How do you define a blank line? Is it an empty line? Is it a line that contains
only
whitespace?
In any case, here
On Mon, Oct 1, 2012 at 3:34 AM, Irfan Sayed irfan_sayed2...@yahoo.com wrote:
hi,
i need to delete all blank lines from the text file
I usually just skip the blank lines when I read the data one line at a
time. Then you can print to a new file.
My example is below:
#!/usr/bin/perl
use 5.010
Thanks a lot Shlomi and Thomas.
I will try with these methods.
On Tue, Mar 23, 2010 at 7:13 PM, Shlomi Fish shlo...@iglu.org.il wrote:
Hi Sheela,
On Tuesday 23 Mar 2010 15:06:24 sheela b wrote:
Hi All,
How to delete last 10 lines of a file using Perl one liner?
I used
Hi All,
How to delete last 10 lines of a file using Perl one liner?
I used the following one liner to delete first 10 lines of a file,
perl -i.bak -ne 'print unless 1..10' test.txt
Regards
Sheela
sheela b sheela.b.2...@gmail.com asked:
How to delete last 10 lines of a file using Perl one liner?
I used the following one liner to delete first 10 lines of a file,
perl -i.bak -ne 'print unless 1..10' test.txt
OTTOH:
perl -i.bak -ne 'BEGIN { $b[9]= } print shift @b; push @b
Hi Sheela,
On Tuesday 23 Mar 2010 15:06:24 sheela b wrote:
Hi All,
How to delete last 10 lines of a file using Perl one liner?
I used the following one liner to delete first 10 lines of a file,
perl -i.bak -ne 'print unless 1..10' test.txt
If it doesn't have to be a one-liner, you
$ITUNES_FILE_PATH = /cygdrive/d/MyDocuments/My Music/iTunes;
my $ITUNES_LIBRARY_FILE_NAME = iTunes Music Library1.txt;
my $ITUNES_LIBRARY_FILE = $ITUNES_FILE_PATH/
$ITUNES_LIBRARY_FILE_NAME;
my $PREPEND_PLAYLIST_KEY = OEL: ;
print $ITUNES_LIBRARY_FILE\n;
tie my @lines, 'Tie::File', $ITUNES_LIBRARY_FILE_NAME
);
splice @charArray, 26, 0, $PREPEND_PLAYLIST_KEY;
print @charArray\n;
Nowhere do you modify $lines[$i] which means that you are not modifying
the file itself.
}
}
untie @lines;
#close $ITUNES_LIBRARY_FILE;
Please find the file I am trying to modify here:
/dict
On Jul 18, 6:16 am, [EMAIL PROTECTED] (Ayesha) wrote:
Hi all
I got started on Perl only today!
I have a text file in which I need to read a line and the line after
that. Like
line1 and line2
line2 and line3
line3 and line4
when I use while($line1 = MYFILE){
On 7/19/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
On Jul 18, 6:16 am, [EMAIL PROTECTED] (Ayesha) wrote:
Hi all
I got started on Perl only today!
I have a text file in which I need to read a line and the line after
that. Like
line1 and line2
line2 and line3
line3 and line4
when I
Chas Owens wrote:
On 7/19/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
On Jul 18, 6:16 am, [EMAIL PROTECTED] (Ayesha) wrote:
when I use while($line1 = MYFILE){
$line = MYFILE;
}
while ($line=FH)
{
print$line;
}
2. while
On 7/19/07, John W. Krahn [EMAIL PROTECTED] wrote:
Chas Owens wrote:
On 7/19/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
On Jul 18, 6:16 am, [EMAIL PROTECTED] (Ayesha) wrote:
when I use while($line1 = MYFILE){
$line = MYFILE;
}
while
What is a lexical file handle? I'm working my way through Ford's Perl
Programming for the Absolute Beginner (2007) and Lee's Beginning Perl
(2004), and they both use the FH style of file handle. Should I do
differently?
Thanks.
--Chris
Chas Owens wrote:
On 7/19/07, [EMAIL PROTECTED]
On 7/19/07, Ryan [EMAIL PROTECTED] wrote:
What is a lexical file handle? I'm working my way through Ford's Perl
Programming for the Absolute Beginner (2007) and Lee's Beginning Perl
(2004), and they both use the FH style of file handle. Should I do
differently?
snip
Yes, you should use
--- Ryan [EMAIL PROTECTED] wrote:
What is a lexical file handle? I'm working my way
through Ford's Perl
Programming for the Absolute Beginner (2007) and
Lee's Beginning Perl
(2004), and they both use the FH style of file
handle.
From perl 5.6 you can say,
open my $fh,test.txt or die
Hi all
I got started on Perl only today!
I have a text file in which I need to read a line and the line after
that. Like
line1 and line2
line2 and line3
line3 and line4
when I use while($line1 = MYFILE){
$line = MYFILE;
}
I get output
line1 and
On Wednesday 18 July 2007 06:16, Ayesha wrote:
Hi all
I got started on Perl only today!
I have a text file in which I need to read a line and the line after
that. Like
line1 and line2
line2 and line3
line3 and line4
when I use while($line1 = MYFILE){
$line =
--- Ayesha [EMAIL PROTECTED] wrote:
Hi all
I got started on Perl only today!
I have a text file in which I need to read a line
and the line after
that. Like
line1 and line2
line2 and line3
line3 and line4
when I use while($line1 = MYFILE){
$line =
learning, so I am not
sure why I need to do more?
Thanks!
jlc
-Original Message-
From: Gary Stainburn [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 18, 2007 10:15 AM
To: beginners@perl.org
Subject: Re: Extreme beginner question on reading lines from a file.
On Wednesday 18 July 2007 17
On Wednesday 18 July 2007 17:08, Joseph L. Casale wrote:
Is that true?
I use while loops and they cycle through each line without me keeping
track? jlc
Yeah, it's true. Why would you want to keep track?
(you can BTW, look at perldoc perlvar for $.)
in my code, the 1st line is written into
On 7/18/07, Joseph L. Casale [EMAIL PROTECTED] wrote:
Hrm,
I am confused then:)
I have this as a file I am using right now!
while (FILEIN) {
my @data = split;
next unless @data == 3;
next if grep (/[^0-9.-]/, @data);
printf FILEOUT X%s Y%s\n, $data[0], $data[1];
Chas Owens wrote:
On 7/18/07, Joseph L. Casale [EMAIL PROTECTED] wrote:
Hrm,
I am confused then:)
I have this as a file I am using right now!
while (FILEIN) {
my @data = split;
next unless @data == 3;
next if grep (/[^0-9.-]/, @data);
printf FILEOUT X%s Y%s\n,
.
@a1_s= split/\/, $_{$I];
@a2_s= split/\/,$_[$i+1];
I can't see what you're trying to do. It looks as if you're trying to
do something with the @_ array. Is that right? Or maybe you're hoping
that those expressions on the right will evaluate as consecutive lines
from the file?
Here's some untested
-Original Message-
From: Luba Pardo [mailto:[EMAIL PROTECTED]
Sent: Friday, October 13, 2006 6:27 PM
To: beginners@perl.org
Subject: consecutive lines in a file
Dear sir/madam:
I am trying to write a script to process to consecutive lines at a time and
compare elements of between two
On 10/13/2006 07:57 AM, Luba Pardo wrote:
Dear sir/madam:
I am trying to write a script to process to consecutive lines at a time and
compare elements of between two consecutive lines.
I don't understand this sentence.
I tried something like:
$i=0;
while (IN){
chomp;
@a1_s= split/\/,
to spamassassin pm to check the status
but the email file contains these lines which mess with spamassassins
filtering which I have to remove in order to get an accurate spam
score(using the pm not the daemon don't ask me why :-))
P I 19-10-2005 21:35:00 [EMAIL PROTECTED]
O T
Subject Spam-Status and then pass the
contents along to spamassassin pm to check the status but the email file
contains these lines which mess with spamassassins filtering which I
have to remove in order to get an accurate spam score(using the pm not
the daemon don't ask me why
Christopher Spears wrote:
Here is some code I am working on:
#!/bin/perl -w
use strict;
my $number_of_args = @ARGV;
open STDERR, ./caught_errors or die Can't create
caught_errors: $!;
if ($number_of_args == 0) {
print Not enough arguments!\n;
print Usage: ./cedit somefile.C++\n;
a specified range of lines from a file (like sed -n 24, 48p
filename)?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response
Ken Wolcott wrote:
A fishing pole question rather than a fish question :-)
What search string do I use on google or perldoc so that I know how to
display a specified range of lines from a file (like sed -n 24, 48p
filename)?
Zeus gave you the solution, but the background is explained in perldoc
A fishing pole question rather than a fish question :-)
What search string do I use on google or perldoc so that I know how to
display a specified range of lines from a file (like sed -n 24, 48p
filename)?
s2p no longer operates the way I used to use it back in perl 3x days :-)
man s2p really
Hi ,
I have a problem in deleting all the lines in a file and saving it .
Actually my log file keep appending all the messages for that i need to
clean it up i.e delete all lines in it save it . when i do this initially
file shows zero bytes , but as soon as the next message appends ,, file
sizes
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 31, 2004 6:50 AM
To: [EMAIL PROTECTED]
Subject: delete all lines in a file save it come out
Hi ,
I have a problem in deleting all the lines in a file and saving it .
Actually my log file keep
Hi ,
I have a problem in deleting all the lines in a file and saving it .
Actually my log file keep appending all the messages for that
i need to clean it up i.e delete all lines in it save it .
when i do this initially file shows zero bytes , but as soon
as the next message appends
On Aug 31, [EMAIL PROTECTED] said:
open(FILE, $logfile) or die Couldn't open $logfile : $!\n; # This
logfile keeps appending in a linux m/c
flock(FILE,2);
while (sysread FILE, $buffer, 4096) {
$lines += ($buffer =~ tr/\n//);
}
This makes
On Aug 31, [EMAIL PROTECTED] said:
Well if all you want to do is count the number of lines in the file then
zero out the file, the easiest way that I can think of would be to use a
couple of system calls like this.
No, there is no reason to make any system calls at all.
open FILE, $file
On Aug 31, Jim said:
open (FILE, +, $file) or die cannot open $file: $!;
I think you want + there, or else it will overwrite the contents of
the file and you won't be able to determine how many lines there were
originally.
flock (FILE, 2) or die cannot flock $file: $!;
For safety's sake, use
On Aug 31, Jim said:
open (FILE, +, $file) or die cannot open $file: $!;
I think you want + there, or else it will overwrite the
contents of the file and you won't be able to determine how
many lines there were originally.
Thanks. I was not sure what he was trying to do.
Hi,
thanks for all the suggestions. I originally tried to avoid slurping the whole file
into memory, but got stuck using the $. variable to address a line and the one
following it.
Thanks John and Gunnar for pointing me to the right direction, and thanks to Charles
for his extensive comments.
Jan Eden wrote:
I had the following task: Open a file, read it and merge all pairs
of lines containing a certain number of tabs. Example:
Blablabla
abc cab bca
123 453 756
Blablabla
Blablabla
Here, lines 2 and three should be merged, while the other lines
should remain untouched. Expected result:
Jan Eden wrote:
Hi,
Hello,
I had the following task: Open a file, read it and merge all pairs of lines containing
a certain number of tabs. Example:
Blablabla
abc cab bca
123 453 756
Blablabla
Blablabla
Here, lines 2 and three should be merged, while the other lines should remain
untouched.
Jan Eden [EMAIL PROTECTED] wrote:
: I had the following task: Open a file, read it and merge all
: pairs of lines containing a certain number of tabs. Example:
:
: Blablabla
: abc cab bca
: 123 453 756
: Blablabla
: Blablabla
:
: Here, lines 2 and three should be merged, while the other
: lines
Jan Eden wrote:
Hi,
Hello again,
I had the following task: Open a file, read it and merge all pairs of lines containing
a certain number of tabs. Example:
Blablabla
abc cab bca
123 453 756
Blablabla
Blablabla
Here, lines 2 and three should be merged, while the other lines should remain
I want to write a command line perl 'script' to delete one or more
lines from a file , by line number
for eg in sed I can do the same in two steps
cat FILENAME | sed -e '1,10d' FILENAME.TMP
mv FILENAME.TMP FILENAME
The above mechanism has a lot of pitfalls , like maintaining
On Mon, 2004-08-09 at 07:34, Ramprasad A Padmanabhan wrote:
I want to write a command line perl 'script' to delete one or more
lines from a file , by line number
Hi :-)
If I understand correctly, you want to delete lines X to Y from a file,
right?
perl -i -ne 'print unless 1..10' file
Sudhindra K S wrote:
Hi
Hello,
I am new to perl and getting confused with pattern matching.
How do i remove blank files from a file. For ex: i have a file as below
abc
xyz
def
123
Now i want to remove all blank lines and have an output as below
abc
xyz
def
123
How do i
Thanks
But the output is printed on the STDOUT. What if i want to get each of the lines
beginning with all: and put in a file or array? How do i do this?
Regards
Sudhindra
On Wed, 09 Jun 2004 John W. Krahn wrote :
Sudhindra K S wrote:
Hi
Hello,
I am new to perl and getting confused
Hi
I am getting this error message on using the command specified by you.
Unrecognized file test: -i at change.pl line 28.
Regards
Sudhindra
On Wed, 09 Jun 2004 John W. Krahn wrote :
Sudhindra K S wrote:
Hi
Hello,
I am new to perl and getting confused with pattern matching.
How
WC -Sx- Jones wrote:
zsdc wrote:
WC -Sx- Jones wrote:
Can we please leave the Perl Golf in the appropriate context or at
least make a warning in/at the start of the message that the post
may confuse beginners?
I didn't make any warning in my last post. I wrote an explaination
instead. I hope
John W. Krahn wrote:
Wc -Sx- Jones wrote:
Most employers (and a quiet a few IT managers) are not very Perl savvy
and would like you Perl people (read POD) to be more like COBOL people
(read BOOKS.)
Don't you mean we Perl people or are you inferring that you are not a
Perl person?
I apologize -
WC -Sx- Jones wrote:
R. Joseph Newton wrote:
Bryan Harris wrote:
perl -lpe '}{*_=*.}{' file
Ooh, an obfuscated verbose way of writing:
perl -lpe'}{$_=$.' file
Huh? Could someone explain this? The }{ makes no sense to me...
Well, as Momma used to say:
Just look the other
perl -lpe '}{*_=*.}{' file
Ooh, an obfuscated verbose way of writing:
perl -lpe'}{$_=$.' file
Huh? Could someone explain this? The }{ makes no sense to me...
- B
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
perl -lpe '}{*_=*.}{' file
Ooh, an obfuscated verbose way of writing:
perl -lpe'}{$_=$.' file
Huh? Could someone explain this? The }{ makes no sense to me...
- B
You're not the first. There was recently much discussion about this on
the Fun with Perl list, see the
On Feb 27, 2004, at 1:13 PM, Bryan Harris wrote:
perl -lpe '}{*_=*.}{' file
Ooh, an obfuscated verbose way of writing:
perl -lpe'}{$_=$.' file
Huh? Could someone explain this? The }{ makes no sense to me...
I thought the same thing, when I read it! I'm still not sure I get it,
but perlrun
Bryan Harris wrote:
perl -lpe '}{*_=*.}{' file
Ooh, an obfuscated verbose way of writing:
perl -lpe'}{$_=$.' file
Huh? Could someone explain this? The }{ makes no sense to me...
Well, as Momma used to say:
Just look the other way. Ignore it, and maybe it will go away...
I would
R. Joseph Newton wrote:
Huh? Could someone explain this? The }{ makes no sense to me...
Well, as Momma used to say:
Just look the other way. Ignore it, and maybe it will go away...
I would not be at all surprised if the code above works, and does *something*.
I just prefer to use code that
R. Joseph Newton wrote:
Bryan Harris wrote:
perl -lpe '}{*_=*.}{' file
Ooh, an obfuscated verbose way of writing:
perl -lpe'}{$_=$.' file
Huh? Could someone explain this? The }{ makes no sense to me...
Well, as Momma used to say:
Just look the other way. Ignore it, and maybe it will go
WC -Sx- Jones wrote:
Can we please leave the Perl Golf in the appropriate context or at least
make a warning in/at the start of the message that the post may confuse
beginners?
I didn't make any warning in my last post. I wrote an explaination
instead. I hope that's acceptable...
--
ZSDC
--
zsdc wrote:
WC -Sx- Jones wrote:
Can we please leave the Perl Golf in the appropriate context or at
least make a warning in/at the start of the message that the post may
confuse beginners?
I didn't make any warning in my last post. I wrote an explaination
instead. I hope that's
Wc -Sx- Jones wrote:
Most employers (and a quiet a few IT managers) are not very Perl savvy
and would like you Perl people (read POD) to be more like COBOL people
(read BOOKS.)
Don't you mean we Perl people or are you inferring that you are not a
Perl person?
Can we please leave the Perl
Jenda Krynicky [EMAIL PROTECTED] wrote:
:
: From: WC -Sx- Jones
:
: undef $/; # Slurp;
:
: foreach $target (@ARGV) {
:@lines = ();
:
:open (HTML_FILE, $target) or die owie;
:@lines = split(/\n/, HTML_FILE);
:
:print In $target - Seen: . ($#lines + 1) . lines...\n;
: }
Hi List.
Is there a way to determine the number of lines in a file without actually
iterating through the file and incrementing a file?
I found the following on perlmonks.org, it works great but this is command
line syntax
:
perl -lpe '}{*_=*.}{' file
How could I integrate
-Original Message-
From: Jason Normandin [mailto:[EMAIL PROTECTED]
Sent: Thursday, 26 February 2004 10:56 AM
To: Perl Beginners
Subject: Count the number of lines in a file without actually
iterating through the file
Hi List.
Is there a way to determine the number
Is there a way to determine the number of lines
in a file without actually iterating through the
file and incrementing a file?
No.
I found the following on perlmonks.org, it works
great but this is command line syntax
When you deparse that command (see below), you can see that all it does
Jason Normandin wrote:
Hi List.
Hello,
Is there a way to determine the number of lines in a file without actually
iterating through the file and incrementing a file?
I found the following on perlmonks.org, it works great but this is command
line syntax
perl -lpe '}{*_=*.}{' file
Ooh
[ what was all that? in-line top posting? please don't ]
Hanson, Rob wrote:
Is there a way to determine the number of lines
in a file without actually iterating through the
file and incrementing a file?
# No silver bullet; but shorter -
undef $/; # Slurp;
foreach $target (@ARGV) {
@lines
I'm trying to extend the Perl cookbook recipe on how to pick a random
line from a file:
#!/usr/bin/perl
rand($.) 1 ($line = $_) while ;
print $line;
for picking up to N random lines from a file:
start code--
#!/usr/bin/perl
die Usage: $0 N, where N is the number
On Wed, 2003-12-10 at 11:12, David Garamond wrote:
I'm trying to extend the Perl cookbook recipe on how to pick a random
line from a file:
#!/usr/bin/perl
rand($.) 1 ($line = $_) while ;
print $line;
for picking up to N random lines from a file:
start code
Kevin Old writes:
On Wed, 2003-12-10 at 11:12, David Garamond wrote:
I'm trying to extend the Perl cookbook recipe on how to pick a random
line from a file:
#!/usr/bin/perl
rand($.) 1 ($line = $_) while ;
print $line;
for picking up to N random lines from
[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 and no of lines in
a file.
is there any perl functions available for that ?
r
w to get 1st line, last line and no of lines in a file
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 (FH
{
$lines++;
}
[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
Hi,
How to get first line, last line and no of lin
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 (FH
{
$lines++;
}
close(FH)
This operation is expensive..
suppose, if file have millions
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.
For a big file, I'm not sure there's
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 (FH
{
$lines++;
}
close(FH)
This operation is expensive..
suppose, if file have millions of records,
it will take more time
-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 and no of lines in
a file
Sashidhar wrote:
I may have to change the length of the files. Is there no way, like
manipulating the inode entries to reflect any changes in the length.
Ofcourse, I realize that this is specific to the linux/unix env.
The problem is a limitation of the filing system itself. The starting
Hello,
I am dealing with text files of sizes 2 GB. I have to modify just the top 2 lines
of such files. Is there a way in Perl to modify just the first 'n' lines of the file
without having to process rest of the file as it involves a lot of IO and time.
Thanks,
Siva
Sashidhar wrote:
Hello,
Hello,
I am dealing with text files of sizes 2 GB. I have to modify just the top 2 lines
of such files. Is there a way in Perl to modify just the first 'n' lines of the file
without having to process rest of the file as it involves a lot of IO and time.
It depends
dealing with text files of sizes 2 GB. I have to modify just the top 2
lines
of such files. Is there a way in Perl to modify just the first 'n' lines of the
file
without having to process rest of the file as it involves a lot of IO and time.
It depends. If the modifications don't change
Sashidhar wrote:
--- John W. Krahn [EMAIL PROTECTED] wrote:
Sashidhar wrote:
I am dealing with text files of sizes 2 GB. I have to modify just the top 2
lines of such files. Is there a way in Perl to modify just the first 'n' lines
of the file without having to process rest
Marcelo wrote:
Hi everybody...
How I can take lines from a file like this ...
line1=A
line2
line3
line1=B
line2
line3
line1=A
line2
line3
I want to take the followin 2 lines to the line1 when line1=A and
write them to another file
I'm not clear exactly what your file looks
On Thu, 30 Jan 2003, Rob Dixon wrote:
Date: Thu, 30 Jan 2003 16:40:13 -
From: Rob Dixon [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: taking lines from a file
Marcelo wrote:
Hi everybody...
How I can take lines from a file like this ...
line1=A
line2
line3
line1
Rob Dixon wrote:
Marcelo wrote:
Hi everybody...
How I can take lines from a file like this ...
line1=A
line2
line3
line1=B
line2
line3
line1=A
line2
line3
I want to take the followin 2 lines to the line1 when line1=A and
write them to another file
I'm
[EMAIL PROTECTED] wrote:
Hello,
I have over 1000 files that I need to delete the first five lines of
text from. This needed to be done, like yesterday. I started writting
an Applescript to do this but ran into a bug with Folder Actions and
attached scripts that stopped my progress dead.
All files will be in the same directory. The files are Postscript. They all have
a proprietary header with comments above the %!PS line so they all fail to
print.
At 24/01/2003 14:48:47, Kipp, James [EMAIL PROTECTED] wrote:
Hello,
I have over 1000 files that I need to delete the first five
[EMAIL PROTECTED] wrote:
Subject: RE: NewbieQuestion Deleting the first 5 lines of a file
At 24/01/2003 15:29:27, Bob Showalter
[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
Hello,
I have over 1000 files that I need to delete the first five lines
of text from. This needed
At 24/01/2003 15:29:27, Bob Showalter [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
Hello,
I have over 1000 files that I need to delete the first five lines of
text from. This needed to be done, like yesterday. I started writting
an Applescript to do this but ran into a bug with
perl -i.bak -ne 'print if $.5; close ARGV if eof' *.txt
Bob
I have been trying to figure out a different solution then using the -i arg.
Is there a simple way to just open each file, delete the 5 lines in place
and close it(with no backup file), without getting into sysread, truncate
Kipp, James wrote:
perl -i.bak -ne 'print if $.5; close ARGV if eof' *.txt
Bob
I have been trying to figure out a different solution then using the
-i arg. Is there a simple way to just open each file, delete the 5
lines in place and close it(with no backup file), without getting
have been trying to figure out a different solution then using the
-i arg. Is there a simple way to just open each file, delete the 5
lines in place and close it(with no backup file), without getting
into sysread, truncate, etc...
Not really. What's the problem with using -i?
nothing
James Kipp wrote:
have been trying to figure out a different solution then using the
-i arg. Is there a simple way to just open each file, delete the 5
lines in place and close it(with no backup file), without getting
into sysread, truncate, etc...
Not really. What's the problem with using
[snip]
but we still have not changed the original file, have we :-)
There isn't a way to edit a text file anywhere except the end
without copying the data. Deleting from the beginning requires
that all data after the deletion are moved up to the start of the
file. You could do it within
Where can i find more info on seek(), perldoc does not tell me much. it only
list 3 parameters, where David uses 4 in this code? what do negative values
in the offset represent?
Thanks
#!/usr/bin/perl -w
use strict;
my @character;
my @lines;
open(FH,foo.txt) || die $!;
seek(FH,(-s
.--[ Kipp, James wrote (2002/10/31 at 09:28:23) ]--
|
| Where can i find more info on seek(), perldoc does not tell me much. it only
| list 3 parameters, where David uses 4 in this code? what do negative values
| in the offset represent?
|
| seek(FH,tell(FH)-2,0);
|
;wiles.org]
Sent: Thursday, October 31, 2002 9:38 AM
To: Kipp, James
Cc: [EMAIL PROTECTED]
Subject: Re: Question about seek, Was: Trailing 5 lines of a file
Actually there are only three. FH, tell(FH)-2, and 0. If
you use 2
for the WHENCE value you can use negative values
.--[ Kipp, James wrote (2002/10/31 at 09:53:10) ]--
|
| Thanks. I looked throught Programming perl but did not find much. Ok, I see
| i misread the statement and ther are only 3 params. Here is how I read this
| statment:
| seek(FH,(-s foo.txt)-2,0);
|
| seek back 2 bytes
1 - 100 of 164 matches
Mail list logo