[23761] in Perl-Users-Digest
Perl-Users Digest, Issue: 5965 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 20 18:05:40 2003
Date: Sat, 20 Dec 2003 15:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 20 Dec 2003 Volume: 10 Number: 5965
Today's topics:
Re: Add Files to Zip File <mikeflan@earthlink.net>
Re: Horrendous memory leak with TCP/IP Socket client, n <kalinaubears@iinet.net.au>
Re: how do I send emails as html? rs@plusw.de
Re: how do I send emails as html? <noreply@gunnar.cc>
Re: how do I send emails as html? <jwillmore@remove.adelphia.net>
Ordering arrays? <gary@tgpmakers.com>
Re: PAR error <linh@chello.no>
Re: Please critique this short script that scans a log <jwngaa@att.net>
Re: Please critique this short script that scans a log <wdr@world.std.com>
Re: Please critique this short script that scans a log <uri@stemsystems.com>
Re: recursive closures? <tassilo.parseval@rwth-aachen.de>
Re: redirect without meta <flavell@ph.gla.ac.uk>
Re: redirect without meta <jwillmore@remove.adelphia.net>
Re: redirect without meta <noreply@gunnar.cc>
replacing two EOL chars by one (Xah Lee)
Re: replacing two EOL chars by one <ptmcg@austin.rr.com>
Re: replacing two EOL chars by one <noreply@gunnar.cc>
Re: replacing two EOL chars by one <gnari@simnet.is>
Re: replacing two EOL chars by one <billk@cts.com>
Re: replacing two EOL chars by one <rjain@nyct.net>
Re: replacing two EOL chars by one <jurgenex@hotmail.com>
Re: replacing two EOL chars by one (Jay Tilton)
Re: replacing two EOL chars by one <1usa@llenroc.ude>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 20 Dec 2003 19:30:19 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Add Files to Zip File
Message-Id: <3FE4A412.1B3D9069@earthlink.net>
Anno Siegel wrote:
> Why are you introducing $name? You are using $_ in the code, except
> in one place. And the regex match is entirely useless. What is is
> for?
>
> snip
>
> You are still writing the whole archive back to disk after adding each
> member. Do it once, after find() has finished.
>
I have removed out $name, since it was not needed. This
is to zip up downloaded newsgroup files.
The files I am trying to zip are like this: 3461.
They have no extension. So I'm saying pass up any
files that do have an extension (don't zip them).
The script below works fine. Of course it doesn't
append the files to the existing zip file that already
contains zipped up files - it overwrites the file.
Probably all I need to do now is unzip the existing
file, and then add all the files back into the zip file.
I'll post how it goes after I try that.
Mike
use strict;
use warnings;
use File::Find;
use File::Copy();
use Archive::Zip;
my $zipfile = '2003 - 4th Q.zip';
my ($group, $file, $zip, @delfile);
chdir 'C:/Perl/00MikeF/news.west.earthlink.net';
open SUBSCRIBE, "<subscribed2.txt" or die "$0: open subscribed2.txt: $!";
while ($group = <SUBSCRIBE>) {
chomp $group;
my $dir = 'C:/Perl/00MikeF/news.west.earthlink.net/'.$group.'/Old';
chdir $dir;
$zip = new Archive::Zip;
find sub {
return if -d;
return if /Io\.sys/;
return if /Msdos\.sys/;
return if /.*\.zip/i;
$zip->addFile($_);
} => $dir;
$zip->writeToFileNamed($zipfile);
}
close SUBSCRIBE;
print "All done.\n";
__END__
------------------------------
Date: Sun, 21 Dec 2003 09:45:33 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Horrendous memory leak with TCP/IP Socket client, new to 5.8.0?
Message-Id: <3fe4d1e2$0$1735$5a62ac22@freenews.iinet.net.au>
Tim Shoppa wrote:
>
> #!/usr/bin/perl
> use strict;
> use Socket;
>
> my $internet_addr = inet_aton('localhost') or die "Failed to aton:
> $!";
> my $paddr = sockaddr_in(7001, $internet_addr) or die "failed to get
> paddr: $!";
>
> while(1) {
> socket(Server,PF_INET, SOCK_STREAM, getprotobyname('tcp')) or die
> "Socket failed: $!";
> connect (Server,$paddr) or die "Couldn't connect to remote port:
> $!";
> undef $/; #Slurp all the data
> my $bigline = <Server>;
> close(Server);
> }
>
> The server is ridiculously simplistic: connect to it and it sends you
> some data, then hangs up. The server works fine without a memory leak
> so I'm not showing it here.
>
Can't replicate the problem on Win2k. Your code seems fine.
Is the server script also doing a close() ? (Didn't seem to matter on
Win2k.)
I also have linux, but didn't try your script on that platform as I
don't know how to check for memory leaks on linux .... I couldn't find
its "Task Manager" :-)
How do you know that it's the client and not the server that's leaking
memory ?
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Sat, 20 Dec 2003 20:11:28 +0100
From: rs@plusw.de
Subject: Re: how do I send emails as html?
Message-Id: <bs26t0$p62$02$1@news.t-online.com>
Julia Briggs wrote:
> What headers/data do I have to add to output sent emails as HTML?
>
> Any advice or examples?
see MIME::Lite
------------------------------
Date: Sat, 20 Dec 2003 21:09:46 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how do I send emails as html?
Message-Id: <bs2ade$90d5t$1@ID-184292.news.uni-berlin.de>
Julia Briggs wrote:
> What headers/data do I have to add to output sent emails as HTML?
Somebody gave you a pointer.
I'm just noticing that your question is considered to be off topic
here, so you can expect at least five posts that point out that fact.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 20 Dec 2003 22:07:09 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: how do I send emails as html?
Message-Id: <20031220170710.31cf79c6.jwillmore@remove.adelphia.net>
On 20 Dec 2003 10:47:57 -0800
julia4_me@yahoo.com (Julia Briggs) wrote:
> What headers/data do I have to add to output sent emails as HTML?
>
> Any advice or examples?
Inline or as an attachment?
If you want to send inline, use the MIME::Lite::HTML module
If attachment, use the MIME::Lite module.
If you post what Perl code you have so far, maybe we can help.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
"Hello," he lied. -- Don Carpenter quoting a Hollywood agent
------------------------------
Date: Wed, 17 Dec 2003 21:26:16 +0000
From: Gary Mayor <gary@tgpmakers.com>
Subject: Ordering arrays?
Message-Id: <brqhgo$gc8$1@newsg4.svr.pol.co.uk>
Hi,
I'm trying to get an array into order i've got this array,
$number[1] = "5";
$number[2] = "7";
$number[3] = "4";
$number[4] = "8";
$number[5] = "7";
i'm trying to get it into another array it looks like this,
$number2[1] = "8";
$number2[2] = "7";
$number2[3] = "7";
$number2[4] = "5";
$number2[5] = "4";
So far i've got some code like this,
for($i=1;$i<=$count;$i++) {
for($ii=1;$ii<=$count;$ii++) {
if ($number[$ii]>=$highest[$i]) {
$number2 = $number[$i];
print "\n$number2[$i]";
}
}
}
I've tried the pseudo but could figure out the logic. This is the first
time i've had to do ordering of this sort so i'm a bit stuck at which
way to go next. I've checked out cpan but couldn't find anything that
looked like it would do what i wanted.
Has anyone got any ideas please.
Thanks
Gary
------------------------------
Date: Wed, 17 Dec 2003 20:44:31 +0100
From: ngoc <linh@chello.no>
Subject: Re: PAR error
Message-Id: <1w2Eb.6345$n31.107135@news2.e.nsc.no>
Ben Morrow wrote:
> ngoc <linh@chello.no> wrote:
>
>>Error:
>>Fetching 'PAR-0.76_98-sun-solaris-5.6.1.par from ftp.cpan.org...Bad file
>>number
>>Fetching failed:
>>No compiler found, won't generate 'cript/parl'
>>
>>I do 'which gcc' it can locate to my new gcc. So gcc is there. What is
>>problem?
>
>
> Type
> $ perl -MConfig -le'print $Config{cc}'
> and see if *that* compiler exists. If it doesn't then you could
> rebuild perl (and all your modules: see CPAN's autobundle facility)
> with gcc.
>
> Alternatively, the only thing you lose by not having parl is the
> ability to create completely stand-alone executables: for everything
> else, par.pl is a perfectly acceptable alternative.
>
> Ben
>
Hi
Yes. It exists the output of command you suggest is
/program/gcc/bin/SUNSV/gcc -static-libgcc
Ngoc
------------------------------
Date: Wed, 17 Dec 2003 13:51:20 -0600
From: J.W. <jwngaa@att.net>
Subject: Re: Please critique this short script that scans a log file
Message-Id: <ihc1uvclisls52e29sqrjdh57glnse9lts@4ax.com>
>> Notes:
>> -- purposely didn't use Date::Calc (or any other non-standard
>> module)
>
>Why not use "non-standard" modules? Date::Parse is pretty handy for
>something like this and cuts out much of the work.
I buildng a "toolkit" of straightforward scripts to analyze logs etc.
I have to be able to run the Perl scripts on machines I don't have the
authority to install extra Perl modules. Yes, I can install modules
in my own private local directory but there are some cases where I
can't even do that (no ftp access to the box.) Also, if the script is
completely "self-contained", I can just email the script to a user
with short and simple instructions to just "run it". If I use
modules, that email gets more complicated with "well, before you run
this Perl script, go to CPAN, download, make, etc." I guess I could
attach the .pm file in the email but it's still quite a bit of work.
If anyone has any good ideas to get around these issues, I'd love to
hear them.
>No need to declare everything up front; this isn't C. :-) If you
>haven't already read it, Mark-Jason Dominus' article "Coping with
>Scoping" is a good read: http://perl.plover.com/FAQs/Namespaces.html.
I'll read this article.
>
>You could have declared the hash and initialized it in the same
>statement if you wanted. If you used Date::Parse you wouldn't need
>it, though.
>
>[snip rest of program]
>
>With Date::Parse it can be much shorter and -- more importantly --
>easier to read.
I wish Date::Parse, Date::Calc, etc. were included as part of Perl
standard distribution!
------------------------------
Date: Sat, 20 Dec 2003 15:28:49 -0500
From: Bill Ricker N1VUX <wdr@world.std.com>
To: Uri Guttman <uri@stemsystems.com>
Subject: Re: Please critique this short script that scans a log file
Message-Id: <3FE4B101.A9DC9795@world.std.com>
> last unlexx /foo/ ;
Does unlexx push tokens back on the input stream?
;-)
Bill
------------------------------
Date: Wed, 17 Dec 2003 20:41:06 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Please critique this short script that scans a log file
Message-Id: <x7n09rgot9.fsf@mail.sysarch.com>
>>>>> "JW" == J W <jwngaa@att.net> writes:
> On Wed, 17 Dec 2003 20:23:28 +0100, Matija Papec <perl@my-header.org>
> wrote:
>>> if (/^RC\s+:\s+(\d+)/) { # Return Code
>>
>> Since every line can match only once(?), you can use elsif's here to avoid
>> unnecessary matches.
> You are correct in use "elsif". This was a lapse in logic on my part.
> This improves the performance of the script.
even better is just to call next once you have matched a line:
if( /foo/ ) {
process foo line ;
next ;
}
if( /bar/ ) {
process bar line ;
next ;
}
this is clean looking (no if/else tree) and still efficient (no testing
all possible line types each time around).
and depending on the actual file format and its size, slurping it and
matching/grabbing against the whole file can be the fastest
approach. see my recent article on slurping on perl.com or read it
inside the File::Slurp distribution (which is updated).
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 17 Dec 2003 20:32:43 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: recursive closures?
Message-Id: <brqehb$6bi$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Ben Morrow:
> tassilo.parseval@post.rwth-aachen.de wrote:
>> Also sprach Anno Siegel:
>>
>> > Brian McCauley <nobull@mail.com> wrote in comp.lang.perl.misc:
>> >> Now, of course, it is an annoying miss-feature that local() can't be
>> >> applied to lexical variables so if you want to use local() you are for
>> >> forced to use package variables. ...
>> >
><snip>
>> > I agree that the inability to use local() with lexicals is sometimes
>> > annoying. It wouldn't be good style to use it all the time, but
>> > occasionally the dynamic restoration behavior of local() is just what
>> > the doctor ordered.
>>
>> Actually there is a nice solution available for the given problem. our()
>> has very similar scoping rules to my(). As long as the self-referential
>> closure isn't meant to span over several packages, it should work as
>> desired because now we can in fact localize.
>
> No, because this variable is now accessible as $Package::var from
> anywhere in the dynamic scope of the local statement, which opens you
> up to strange-action-at-a-distance effects again.
Only in theory. I've never mistakenly written $Package::var when I
didn't mean it. And that's why strictures will grant you access to
global variables as long as they are package-qualified.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sat, 20 Dec 2003 19:38:34 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: redirect without meta
Message-Id: <Pine.LNX.4.53.0312201932020.18767@ppepc56.ph.gla.ac.uk>
On Sat, 20 Dec 2003, Gunnar Hjalmarsson wrote:
> > I'd say perlfaq9 considers it to be off-topic,
>
> I'd say that the pure existence of perlfaq9 indicates that CGI is not
> obviously off-topic. :)
Well, I don't want to prolong this discussion past its sell-by date,
but - even noting the smiley - I think this needs a comment.
FAQs are meant to address questions that are frequently asked. If
certain off-topic questions are frequently asked, it's entirely
appropriate for the FAQ to deal with them briefly, by showing where
they would get better advice. The mere fact that they are mentioned
in the FAQ in this way, is no justification for claiming them to be
on-topic in the corresponding group - quite the opposite, in fact.
------------------------------
Date: Sat, 20 Dec 2003 21:59:45 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: redirect without meta
Message-Id: <20031220165945.1d94009f.jwillmore@remove.adelphia.net>
On Sat, 20 Dec 2003 15:59:14 +0100
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Robin wrote:
> > I've been trying to redirect to an html page in a cgi script...how
> > would one do this wihout using a META tag in the script...?
> ... and James Willmore replied:
> > post this to
> > comp.infosystems.www.authoring.cgi
>
> I get so tired. As you may have noticed, I chose to simply answer
> the question that was asked. (OP thanked me privately.) Suppose it
> took about as much time as each of the replies above.
>
> Was the question obviously off topic here? Personally I don't think
> so. OP asked about how to solve a particular detail in a program
> written in Perl. Yes, it was a CGI problem rather than a Perl
> language problem, but so what? People who write Perl programs often
> encounter problems that are not strictly Perl programming language
> matters, and I often see questions about system interaction, emails,
> database communication etc. politely answered here.
>
> Why this attitude when it comes to CGI?
Sorry you feel that way. I thought the response was on the mark given
what the OP posted.
I don't feel one one or another about CGI scripts, but you are more
than welcomed to your opinion.
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Cleaning your house while your kids are still growing is like
shoveling the walk before it stops snowing. -- Phyllis Diller
------------------------------
Date: Sat, 20 Dec 2003 23:53:19 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: redirect without meta
Message-Id: <bs2k27$8iqcr$1@ID-184292.news.uni-berlin.de>
James Willmore wrote:
> Gunnar Hjalmarsson wrote:
>> Was the question obviously off topic here? Personally I don't
>> think so. OP asked about how to solve a particular detail in a
>> program written in Perl. Yes, it was a CGI problem rather than a
>> Perl language problem, but so what? People who write Perl
>> programs often encounter problems that are not strictly Perl
>> programming language matters, and I often see questions about
>> system interaction, emails, database communication etc. politely
>> answered here.
>>
>> Why this attitude when it comes to CGI?
>
> Sorry you feel that way. I thought the response was on the mark
> given what the OP posted.
There was nothing wrong with your response; you pointed OP to ciwac
where the question would have been more on topic than here.
I noticed that 8 minutes after you last posted in this thread, you
gave useful advice and offered further help in this group in response
to this question: "What headers/data do I have to add to output sent
emails as HTML?"
So yes, I do feel that way. :(
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 20 Dec 2003 12:04:04 -0800
From: xah@xahlee.org (Xah Lee)
Subject: replacing two EOL chars by one
Message-Id: <7fe97cc4.0312201204.7accda32@posting.google.com>
i have a bunch of java files that has spaced-out formatting that i
want to get rid of. I want to replace two end of line characters by
one end of line characters. The files in question is unix, and i'm
also working under unix, so i did:
perl -pi'*~' -e "s@\n\n@\n@g" *.java
but this to no avail.
after many minutes of checking and rechecking and lots of trial and
error with frustration, i realized that the fucking perl to my
expectations again cannot do this simple fucking thing. Nor can the
unix utility tr. Fucking stupid perl couldn't do a simple task of
replacing strings.
let me just take this opportunity to explain one shit from the
thousands from perldoc.
The following is a excerpt from perlre:
m Treat string as multiple lines. That is, change "^" and "$" from
matching the start or end of the string to matching the start or
end
of any line anywhere within the string.
s Treat string as single line. That is, change "." to match any
character whatsoever, even a newline, which normally it would not
match.
Note the first sentences of the two, which are logical opposites, but
in fact they are sinister and not opposite at all. Fucking stupid perl
documentation and Larry Wall moron who is i believe incapable of
writing clearly and logically in English masquerading as humor.
Now may i ask those who wallow in unix and perl: How do you do this?
(if the answer is to write a more elaborate program in perl that
explicitly open files and tread lines, please don't bother answering.
Unix util answer also welcome. (this message is cross posted to python
and scheme and ruby groups because i want them to know the
incompetence and sham aspects of perl. (or my opinions thereof.)))
Thanks.
Xah
xah@xahlee.org
http://xahlee.org/PageTwo_dir/more.html
------------------------------
Date: Sat, 20 Dec 2003 20:41:02 GMT
From: "Paul McGuire" <ptmcg@austin.rr.com>
Subject: Re: replacing two EOL chars by one
Message-Id: <yt2Fb.239044$do1.177693@twister.austin.rr.com>
Is this language really necessary? I'm sure I've used these words myself,
but they're certainly not appropriate in a public discussion.
I do not know the answer to your question, it really seems more like a
regexp question, rather than a problem with Perl. I hope someone who knows
the answer can respond, hopefully in more civil language.
------------------------------
Date: Sat, 20 Dec 2003 21:57:21 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: replacing two EOL chars by one
Message-Id: <bs2d7a$8uee9$1@ID-184292.news.uni-berlin.de>
Paul McGuire wrote:
> I hope someone who knows the answer can respond, hopefully in more
> civil language.
I'm sure that quite a few people know the answer, but most of them
have probably killfiled or decided to ignore him.
I hope that nobody provides an answer.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 20 Dec 2003 20:45:56 -0000
From: "Ragnar Hafstað" <gnari@simnet.is>
Subject: Re: replacing two EOL chars by one
Message-Id: <bs2cdu$759$1@news.simnet.is>
"Xah Lee" <xah@xahlee.org> wrote in message
news:7fe97cc4.0312201204.7accda32@posting.google.com...
> i have a bunch of java files that has spaced-out formatting that i
> want to get rid of. I want to replace two end of line characters by
> one end of line characters. The files in question is unix, and i'm
> also working under unix, so i did:
>
> perl -pi'*~' -e "s@\n\n@\n@g" *.java
>
> but this to no avail.
>
snipped long rant about perldocs
the problem is not your understanding of regular expressions,
but rather that you are forgetting what -p does
you are applying the -e commands to each line of input in turn before
printing it. no line of the input contained \n\n as then they would not
have been ONE line.
now, to do what you want, try:
perl -0 -pi'*~' -e 's@\n\n@\n@g' *.java
------------------------------
Date: Sat, 20 Dec 2003 21:06:12 GMT
From: "Bill Kelly" <billk@cts.com>
Subject: Re: replacing two EOL chars by one
Message-Id: <8R2Fb.23477$nG3.12519@twister.socal.rr.com>
"Xah Lee" <xah@xahlee.org> wrote:
> i have a bunch of java files that has spaced-out formatting that i
> want to get rid of. I want to replace two end of line characters by
> one end of line characters. The files in question is unix, and i'm
> also working under unix, so i did:
>
> perl -pi'*~' -e "s@\n\n@\n@g" *.java
>
> but this to no avail.
Here are two Ruby solutions, both of which have Perl equivalents:
ruby -i~ -e '$/=nil; puts gets.gsub(/\n\n/,"\n")' *.java
ruby -i~ -e '$/="\n\n"; while(gets)do puts chop end' *.java
You may also want to check out http://astyle.sourceforge.net/
which is a free source code beautifier for C/C++/Java.
> after many minutes of checking and rechecking and lots of trial and
> error with frustration, i realized that the fucking perl to my
> expectations again cannot do this simple fucking thing. Nor can the
> unix utility tr. Fucking stupid perl couldn't do a simple task of
> replacing strings.
>
> let me just take this opportunity to explain one shit from the
> thousands from perldoc. [...]
http://www.wavlist.com/movies/135/str-francis.wav
"Lighten up, Francis."
Regards,
Bill
------------------------------
Date: Sat, 20 Dec 2003 16:16:23 -0500
From: Rahul Jain <rjain@nyct.net>
Subject: Re: replacing two EOL chars by one
Message-Id: <8765gbqjfc.fsf@nyct.net>
Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
> Paul McGuire wrote:
>> I hope someone who knows the answer can respond, hopefully in more
>> civil language.
>
> I'm sure that quite a few people know the answer, but most of them
> have probably killfiled or decided to ignore him.
>
> I hope that nobody provides an answer.
And it's crossposted to numerous groups that have nothing to do with
perl.
--
Rahul Jain
rjain@nyct.net
Professional Software Developer, Amateur Quantum Mechanicist
------------------------------
Date: Sat, 20 Dec 2003 21:18:41 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: replacing two EOL chars by one
Message-Id: <R03Fb.16875$jG4.10934@nwrddc02.gnilink.net>
Xah Lee wrote:
> i have a bunch of java files that has spaced-out formatting that i
> want to get rid of. I want to replace two end of line characters by
> one end of line characters. The files in question is unix, and i'm
> also working under unix, so i did:
>
> perl -pi'*~' -e "s@\n\n@\n@g" *.java
>
> but this to no avail.
>
> after many minutes of checking and rechecking and lots of trial and
> error with frustration, i realized that the fucking perl to my
> expectations again cannot do this simple fucking thing. Nor can the
> unix utility tr. Fucking stupid perl couldn't do a simple task of
> replacing strings.
>
> let me just take this opportunity to explain one shit from the
> thousands from perldoc.
[rest of rant snipped]
Five seconds of thinking might have spared you from embarassing yourself
like that (and is certainly more effective than 5 paragraphs of swearing).
You are reading the file line by line. And with each line you are looking
for two consecutive newlines.
Now, how can a single line contain two newlines?
jue
------------------------------
Date: Sat, 20 Dec 2003 21:36:48 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: replacing two EOL chars by one
Message-Id: <3fe4bd0e.68951468@news.erols.com>
xah@xahlee.org (Xah Lee) wrote:
: i have a bunch of java files that has spaced-out formatting that i
: want to get rid of. I want to replace two end of line characters by
: one end of line characters. The files in question is unix, and i'm
: also working under unix, so i did:
:
: perl -pi'*~' -e "s@\n\n@\n@g" *.java
:
: but this to no avail.
Of course it's not.
Perl's -p switch processes one line at a time. A line cannot have more
than one newline character.
Perl's "paragraph" reading might be useful to you, where any number of
consecutive newline characters mark the end of a record. See "$/" in
perlvar for details.
perl -i'*~' -lpe "BEGIN{$/=''}" *.java
: after many minutes of checking and rechecking and lots of trial and
: error with frustration, i realized that the fucking perl to my
: expectations again cannot do this simple fucking thing.
Complete nonsense. Don't blame your own incompetence on Perl.
: Fucking stupid perl
: documentation and Larry Wall moron who is i believe incapable of
: writing clearly and logically in English masquerading as humor.
If you feel you can explaint it more clearly, quit bellyaching about it and
submit a documentation patch.
Preferrably one that is less petulant and profane than your article.
Frustration is no excuse for incivility.
------------------------------
Date: 20 Dec 2003 22:04:48 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: replacing two EOL chars by one
Message-Id: <Xns9457ADBFDE323asu1cornelledu@132.236.56.8>
xah@xahlee.org (Xah Lee) wrote in news:7fe97cc4.0312201204.7accda32
@posting.google.com:
> (this message is cross posted to python and scheme and ruby groups
> because i want them to know the incompetence and sham aspects of perl.
> (or my opinions thereof.)))
What makes you think anybody anywhere cares what you think on any topic?
> Thanks.
You are not welcome at all.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5965
***************************************