[12839] in Perl-Users-Digest
Perl-Users Digest, Issue: 249 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 25 04:07:22 1999
Date: Sun, 25 Jul 1999 01:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 25 Jul 1999 Volume: 9 Number: 249
Today's topics:
Re: Best Perl book? (David H. Adler)
Re: directory sizes (Tad McClellan)
Re: Extracting plain text from email <rexcell@btinternet.com>
Re: Extracting plain text from email (Anno Siegel)
Re: Extracting plain text from email <rexcell@btinternet.com>
Re: Extracting plain text from email (Anno Siegel)
Re: fetching zip files <swiftkid@bigfoot.com>
Re: Finding duplicate elements in an array? (Tad McClellan)
Re: Geekspeak Programming Contest <relzing@redeemer.on.ca>
Re: index.cgi script help <mike@customautotrim.com>
Re: John F. Kennedy, Jr (Juho Cederstrom)
Re: output of print map ( { unless (/^#/) {} } ("#") ); (Tad McClellan)
output to screen and log file simultaneously? (GEMINI)
Re: Outputting text as entered by user <swiftkid@bigfoot.com>
Re: program runtime problem.. (Tad McClellan)
Re: program runtime problem.. <mfcho7@ie.cuhk.edu.hk>
Re: Reading Data from a file to a variable? (Tad McClellan)
Re: Regex Problem - I think (Anno Siegel)
Re: regexp help (Tad McClellan)
Re: Replacing and Stripping HTML <swiftkid@bigfoot.com>
Re: Variables in Regx? (Argouarch)
Re: Variables in Regx? (Tad McClellan)
Re: Which group is appropriate? <jbc@shell2.la.best.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Jul 1999 07:11:54 GMT
From: dha@panix7.panix.com (David H. Adler)
Subject: Re: Best Perl book?
Message-Id: <slrn7ple5q.ap5.dha@panix7.panix.com>
In article <7ndbdj$r9v$1@plonk.apk.net>, Jody Fedor wrote:
>
>Unigni wrote in message ...
>>I have a little programming experience, and want to start learning Perl,
>>probably for CGI use on the Web... Can anybody suggest what would be the
>>best book(s) to get?
>
>
>I use mostly O'Reilly books:
>
>Programming Perl (Camel Book) - Wall, Christiansen & Schwartz
>Perl Cookbook (Ram Book) - Christiansen & Torkington
>Learning Perl (Llama Book) - Schwartz & Christiansen
>Mastering Regular Expressions (Owl Book) - Friedl
>Advanced Perl Programming (Panther Book) - Srinivasan
O'Reilly certainly is the best source for perl info in book form.
Larry Wall, the creator of perl, is employed by them to, as I
understand it, be, well, Larry. :-)
3 additional points:
A) If you will be using perl on a Windows system, you might keep in
mind that Learning Perl (mentioned above) also comes in a version
for Win32 systems.
2) One book not by O'Reilly comes to mind as a good bet - Effective
Perl Programming by Hall and Schwartz, published by
Addison-Wesley.
iii) A listing of perl books with ratings is available at the perl home
page: http://www.perl.com/pub/language/critiques/index.html
best, dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Just Install Perl. - Chris Nandor
------------------------------
Date: Sat, 24 Jul 1999 20:30:02 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: directory sizes
Message-Id: <aqldn7.87f.ln@magna.metronet.com>
Brian Pontz (pontz@channel1.com) wrote:
: Does anyone know how to get a total directory size including all the
: subdirectories? I thought about using
: system("du -c /path/to/directory/");
: But I cant get this to work correctly
: system("du -c /usr/home/$name/www/ | grep total | cut -f1 -dt")
^^^^^^
If you could be troubled to read about system() in the perlfunc.pod
file that comes with perl, it will tell you how to capture the
output from external commands.
: $total=<STDOUT>;
You are reading _input_ from an _output_ filehandle.
That ain't gonna work.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 25 Jul 1999 07:47:38 +0100
From: "Roger" <rexcell@btinternet.com>
Subject: Re: Extracting plain text from email
Message-Id: <7nebu1$d5o$1@neptunium.btinternet.com>
hmmmm
well CPAN would be a good answer but as the shell i am hosting the script
does not
allow me root acess it is a problem to install any new modules.
So i am assuming that there is a way to do this without the use of a module.
Also to explain myself the reason i dont just want to bounce the email is, I
am trying to run a mailing list
and it will look very messy with all the headers and the html source code,
splattered all over the place.
so thats my reasoning behind the question.
As for typo's dont we all do that ?
Thank you all for your time
Roger
Christoph Wernli <cw@dwc.ch> wrote in message
news:379A4ED9.708CBD52@dwc.ch...
> Tom Christiansen wrote:
> >
> > :How can you get the plain text version of an email out of all the
headers
> > :and if it been sent in html format loose all the formating below the
main
> > :body of the message.
> >
> > What is "loose"? Did you mean to write "lose"? Why didn't you?
> > After reading it a dozen times in one day, it gets to you.
> >
> > Some of us autobounce all HTML or binary mailings sight unseen.
> > It's better that way. If more people would do that, there'd be less
> > crap in our mailboxes.
>
> If you don't feel like saving the world right now, check out
>
http://theory.uwinnipeg.ca/scripts/CPAN/authors/id/ERYQ/MIME-Lite-1.135.tar.
gz,
>
http://theory.uwinnipeg.ca/scripts/CPAN/authors/id/GAAS/HTML-Tree-0.51.tar.g
z and
http://theory.uwinnipeg.ca/scripts/CPAN/authors/id/GBARR/MailTools-1.13.tar.
gz
>
> -w
------------------------------
Date: 25 Jul 1999 07:06:19 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Extracting plain text from email
Message-Id: <7ned1b$4ut$1@lublin.zrz.tu-berlin.de>
Roger <rexcell@btinternet.com> wrote in comp.lang.perl.misc:
>hmmmm
>
>well CPAN would be a good answer but as the shell i am hosting the script
>does not
>allow me root acess it is a problem to install any new modules.
The shell doesn't allow you root access? Well, it could be one of
those restricted shells, I guess, but I'll bet there are more things
that don't allow you root access. Such as not knowing the password,
one would hope.
>So i am assuming that there is a way to do this without the use of a module.
You don't need root access to install a module. Make your own perl5lib
directory or whatever, install to your hearts content, setenv PERL5LIB
accordingly, and off you go.
Oh, and please place your replies *after* the sufficiently tailored
text you quote. This is good usenet custom, and it is for a reason.
[Sheesh, I'm getting tired of adding this to every other followup.
clpm is worse than many newsgroups in this respect.]
Anno
------------------------------
Date: Sun, 25 Jul 1999 08:20:41 +0100
From: "Roger" <rexcell@btinternet.com>
Subject: Re: Extracting plain text from email
Message-Id: <7neds2$s9r$1@uranium.btinternet.com>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:7ned1b$4ut$1@lublin.zrz.tu-berlin.de...
> Roger <rexcell@btinternet.com> wrote in comp.lang.perl.misc:
> >hmmmm
> >
> >well CPAN would be a good answer but as the shell i am hosting the script
> >does not
> >allow me root acess it is a problem to install any new modules.
>
> The shell doesn't allow you root access? Well, it could be one of
> those restricted shells, I guess, but I'll bet there are more things
> that don't allow you root access. Such as not knowing the password,
> one would hope
just a plain shell i have my own linux box here but as it dont have perm
connection
this program would be usless runing from here.
.
>
> >So i am assuming that there is a way to do this without the use of a
module.
>
> You don't need root access to install a module. Make your own perl5lib
> directory or whatever, install to your hearts content, setenv PERL5LIB
> accordingly, and off you go.
>
ok after reading this i did here this someware.
and i have tried
do i need a copy of perl on my own account ?
sorry for being stupid but i am new as i bet u guessed
> Oh, and please place your replies *after* the sufficiently tailored
> text you quote. This is good usenet custom, and it is for a reason.
I am sorry u mean like this
I am also new to news groups mabey a good way to get help as long as i dont
upset every one.
>
> [Sheesh, I'm getting tired of adding this to every other followup.
> clpm is worse than many newsgroups in this respect.]
>
> Anno
------------------------------
Date: 25 Jul 1999 07:56:35 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Extracting plain text from email
Message-Id: <7nefvj$52p$1@lublin.zrz.tu-berlin.de>
Roger <rexcell@btinternet.com> wrote in comp.lang.perl.misc:
>Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in message
[snip]
>> You don't need root access to install a module. Make your own perl5lib
>> directory or whatever, install to your hearts content, setenv PERL5LIB
>> accordingly, and off you go.
>>
>ok after reading this i did here this someware.
>and i have tried
Huh?
>do i need a copy of perl on my own account ?
>sorry for being stupid but i am new as i bet u guessed
No, you don't need your own copy of perl. I think it's best if you
first read the faq about "How do I keep my own module/library directory?".
perldoc -q library will take you there.
>> Oh, and please place your replies *after* the sufficiently tailored
>> text you quote. This is good usenet custom, and it is for a reason.
>
>I am sorry u mean like this
>I am also new to news groups mabey a good way to get help as long as i dont
>upset every one.
Nah, you did fine this time. Sorry to sound grumpy, but some things
get to you when you see them over and over again.
Good luck.
Anno
------------------------------
Date: Sun, 25 Jul 1999 11:29:01 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: fetching zip files
Message-Id: <7nfe67$j992@news.cyber.net.pk>
: >: #$file = $ARGV[0];
: >: #print "Content-length: ",(stat("registered/$file"))[7],"\n";
: >: #print "Content-type: application/x-zip-compressed\n\n";
: >: #print `cat registered/$file`;
: >
: >'cat' doesn't read binary data... i guess.
: >
: >binmode STDOUT;
: >
: >open BLAH , 'registered/$file';
: >binmode BLAH;
: >print <BLAH>
: >close BLAH;
: >
: ><snip>
: >
: >
: Forgive me please but what should the BLAH's be ?
Just a file handle!
------------------------------
Date: Sat, 24 Jul 1999 17:54:28 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Finding duplicate elements in an array?
Message-Id: <kmcdn7.87f.ln@magna.metronet.com>
Joe Kline (Joe.Kline@sdrc.com) wrote:
: Pfash1 wrote:
: > How do I check an array of undetermined size to see if there are duplicate
^^^^^^^^^
^^^^^^^^^
: > elements contained in it?
: <SNIP>
: >Do you have an idea about this? I have sweated over this one and can't >find
: >anything in my books that works.
: First off, get _The Perl Cookbook_ it has this in it.
*That* would be Second off.
_First_ off would be the files on your own hard disk. They
come with perl.
Since it is data, you can do word searches on it, you are not
at the mercy of the indexer, as you are with a book:
perl -ne 'print "$ARGV: $_" if /duplicate/' perlfaq[1-9].pod
perlfaq3.pod: these issues. For example, as of 5.004, duplicate hash keys are
perlfaq4.pod: uniq(1)'s behavior of removing only adjacent duplicates. It's less
perlfaq6.pod: For example, this program detects duplicate words, even when they span
perlfaq6.pod: C<\b>, see the example of matching duplicate words over multiple
perlfaq8.pod: duplicate of STDOUT:
That leads to Perl FAQ, part 4:
"How can I extract just the unique elements of an array?"
: my %elements
: foreach (@arrayone)
: {
: $elements{$_}++;
: }
Yep, that's pretty much how the FAQ answer does it, using
grep instead of foreach for the looping.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 25 Jul 1999 02:03:32 -0400
From: "Chocolate Moose" <relzing@redeemer.on.ca>
Subject: Re: Geekspeak Programming Contest
Message-Id: <7ne9f8$el$1@goblin.uunet.ca>
Matt Curtin wrote in message ...
>>>>> On Fri, 23 Jul 1999 14:33:29 -0700, lr@hpl.hp.com (Larry Rosler) said:
>> Jan 1, 2001 = Jan 1, 2000
Larry> I don't get that.
I believe it is a reference to the millennium, which The Masses seem
to think begins with 2000 despite the fact that it won't begin until
2000 has come to an end.
This is something I don't get. Isn't this analogous to saying that our life
doesn't begin until we are one? Or is it meant to imply(or implied by the
fact), that when, if AD or ACE was a living being, it was one at its birth.
Anyways, a new millenium begins, and a new millenium begins for every
infinitessimal ammount of time that passes. The only _real_ significance of
the "new millenium" is in the "millenium bug" and it's repurcussions if
there really are going to be any. (Two cents from someone who just visited
comp.lang.perl.misc for the first time today and more than likely has echoed
sentiments of previous posts). Moose out.
--
Matt Curtin cmcurtin@interhack.net http://www.interhack.net/people/cmcurtin/
------------------------------
Date: Sun, 25 Jul 1999 00:24:36 -0700
From: Mike <mike@customautotrim.com>
Subject: Re: index.cgi script help
Message-Id: <379ABBB4.D4D45BC7@customautotrim.com>
Abigail,
Your so smart that your stupid. Kind of like drinking yourself straight (I'm sure
your real familiar with that analogy). I asked a question to those who may want to
help. I even got some possible solutions from some helpful people (not you), who
took there time out to help. You on the other hand- maybe after a bad day, decided
to pick apart my post line by line like my old english teacher. Were you just
venting or are you always a bitch?
Here's a spot on quote from you:
^^ I don't even understand why this is a problem.
I absolutely agree.
Do me a favor. Print out this post, roll it up "real tight" so it's nice and pointy,
and then sit on it.
Thanks everyone else for your replies and emails.
mb
Abigail wrote:
> Mike (mike@customautotrim.com) wrote on MMCLI September MCMXCIII in
> <URL:news:37967D43.B87E5059@customautotrim.com>:
> ^^
> ^^ I am on a server that uses an index.cgi file that redirects all requests
> ^^ for my main domain (http://customautotrim.com) to
>
> That makes sense. Never shy away from starting up an extra process if
> all it takes is a configuration line in a web server. People might think
> your site is fast!
>
> ^^ http://customautotrim.com/index.html with this command:
> ^^
> ^^ if($url eq "") {$url="http://www.customautotrim.com/index.html"}
> ^^
> ^^ I want it to be
> ^^ if($url eq "") {$url="http://www.customautotrim.com/"}
>
> And what is your problem? How to type it in? If you did it once in
> the newsgroup, why not in the program?
>
> ^^ The problem is that the index.html always shows up in the address bar.
>
> And that is a *Perl* problem because of? I don't even understand why this
> is a problem. If you don't want index.html to be shown up, by all means,
> don't forward people to a document with index.html in the name!
>
> ^^ My host says I can't change the script like that, and there is not a
> ^^ scipt anywhere that I can use to achieve my goal.
>
> Well, if the host says so... you are the guest, you play be the hosts
> rules. But what does your system administrator say?
>
> ^^ Does anyone know of a fix for this, or know where I can get help?
>
> I'd suggest talking to your system administrator. But him or her a case
> of beer, and approach him/her when (s)he isn't busy, or isn't about to
> leave for home.
>
> Abigail
> --
> perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
>
> -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
> http://www.newsfeeds.com The Largest Usenet Servers in the World!
> ------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sun, 25 Jul 1999 08:28:20 +0300
From: cederstrom@kolumbus.REMOVE_THIS.fi (Juho Cederstrom)
Subject: Re: John F. Kennedy, Jr
Message-Id: <slrn7pl83k.183.cederstrom@vortex.cede.net>
On 24 Jul 99 19:34:10 GMT,
hakn@ecn.ab.ca <hakn@ecn.ab.ca> wrote:
> I'll never understand Americans.
You should try Understand::Americans module from CPAN.
> John F. Kennedy wanted to be buried at
> sea. He arranged his funeral that way and they pull him out, dry him off,
> burn him and toss his ashes back in the same spot.
Did they use Perl for this?
--
#!/usr/bin/perl -wT -- Please take a look at my mail address when replying
use CGI;print &J,&A,&P,&H,"\n";sub J{return new CGI('x=J%75%73t%20')->param
('x')}sub A{$_='cndoetfhgehr ';s/\w(\w)/$1/g;return "A".$_}sub P{$_='B3RJ '
;tr/J3RB/lerP/;return$_}sub H{$_="Ibdlfs";s/(.)/chr(ord($1)-1)/eg;return$_}
------------------------------
Date: Sat, 24 Jul 1999 17:41:27 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: output of print map ( { unless (/^#/) {} } ("#") );
Message-Id: <7ubdn7.87f.ln@magna.metronet.com>
Michael Wang (mwang@tech.cicg.ml.com) wrote:
: Tad McClellan <tadmc@metronet.com> wrote:
: > Since you stealth-Cc'ed me, I will not.
: > Stealth Cc'ing makes folks feel mad, not helpful.
: Tad, I understand your feeling and I apologize for what trn4 didn't
: do what I thought it ought do. I will make a suggestion to the trn
: author, unless you have better suggestions. Thank you.
: PS: there could be be indication in the header which your email reader
: decides to hide.
PPS: the presence/absense of the Newsgroups header does *not*
(reliably) indicate that it was also posted. That's why
everybody puts those little [announcements] in the *body*
of the followup and the email message. Please do that.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Jul 1999 07:44:31 GMT
From: dennis@info4.csie.nctu.edu.tw (GEMINI)
Subject: output to screen and log file simultaneously?
Message-Id: <7nef8v$ck$1@netnews.csie.NCTU.edu.tw>
I use print,warn, and die to output message to
screen in my program. I wish to save these message (including that
generated by warn and die)
to a log file at the same time. Is there any way to do so
by not changing the structure of program. Don't suggest me to
use a subroutine that print to stdout, and print to file, then call
subroutine to output message.
thanks.
------------------------------
Date: Sun, 25 Jul 1999 11:37:10 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Outputting text as entered by user
Message-Id: <7nfelg$j993@news.cyber.net.pk>
: I would like to output the text entered by a user in a form as entered
: (as opposed to a single line). i.e i want the formatting to remain the
: same as entered by the user, when i output it back to the user. But i
: dont want to use <BR> after each line since it breaks html code. Please
help.
: Should i use a special seperator??
use CGI ':standard';
print pre ( param ( 'yourtextarea' ) );
------------------------------
Date: Sat, 24 Jul 1999 18:02:23 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: program runtime problem..
Message-Id: <f5ddn7.87f.ln@magna.metronet.com>
cho man fai (mfcho7@ie.cuhk.edu.hk) wrote:
: I recently write a program to tail -f the sendmail log file. I assume
: the program can be started and run forever to find out any spammer if
: they send emails with a number of mails within a period of time. The
: program, however, works only for around the first day only but not
: afterwards.
: I suspect it is owing to the associative arrays growing and excced the
: limit (memory? or what?) to hold the sender and relay address.
^^^^^^
So you have surely already done
perldoc -q memory
And seen this from part 3:
"How can I make my Perl program take less memory?"
You should also see Perl FAQ, part 3:
"How can I free an array or hash so my program shrinks?"
: Is there
: any limit for that in perl?
Perl can happily take all you have.
Which can be a problem, as you know :-)
: The array grows in the program and it is
: unavoidable. I did try to clear the array periodically, say every hour,
: but failed. May you tell me the way to clear the assiciative array or
: any workarounds you may think of?
You should have checked the Perl FAQs before posting to the
Perl newsgroup.
news.announce.newusers newsgroup has some articles that
explain how to get the most from Usenet. You should read them.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Jul 1999 07:17:27 GMT
From: cho man fai <mfcho7@ie.cuhk.edu.hk>
Subject: Re: program runtime problem..
Message-Id: <7nedm7$l1a$1@eng-ser1.erg.cuhk.edu.hk>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
: cho man fai <mfcho7@ie.cuhk.edu.hk> wrote in comp.lang.perl.misc:
: >Dear all,
: >
: >I recently write a program to tail -f the sendmail log file. I assume
: >the program can be started and run forever to find out any spammer if
: >they send emails with a number of mails within a period of time. The
: >program, however, works only for around the first day only but not
: >afterwards.
: I doubt that's a good way to detect spammers. They're very good
: at "elegant variation" of their purported From-addresses. But
: that's beside the point.
This is not the best way but a way to detect spamming automatically. The
script check with emails in a sender as well as relay basis. Thus, if
the sender use a variable sender email address, I may still detect it by
their relay.. You are right however that it is not a perfect way to
stop spamming, but this is all I think we can do at this moment. Do
others have some good idea in tackling spams? Please kindly share with
us.. :)
: >I suspect it is owing to the associative arrays growing and excced the
: >limit (memory? or what?) to hold the sender and relay address. Is there
: >any limit for that in perl? The array grows in the program and it is
: >unavoidable. I did try to clear the array periodically, say every hour,
: >but failed. May you tell me the way to clear the assiciative array or
: >any workarounds you may think of?
: Generally speaking, you'd undef %assoc_array. Since you don't show
: any code it's hard to say if that would free the memory or not.
: But wouldn't that defeat your purpose anyway? You may want to
: tie() the array to one of the available databases. That way
: you will ultimately run out of disk space, which will take a little
: longer.
Then, let me try to undef the associative array. Will the memory be free
up after I undef the array, say everyday or every 12 hours?
Thanks. :)
Cho Man Fai
------------------------------
Date: Sat, 24 Jul 1999 20:13:58 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Reading Data from a file to a variable?
Message-Id: <6skdn7.87f.ln@magna.metronet.com>
Scot Gardner (Scot@Cyber-Shopper.com) wrote:
: I have a script that contains the following
: %prices = (
: 'item1','25.99',
: 'item2','21.99',
: 'item3','29.99',
: );
I don't know what reason there might be for converting those
numbers into strings.
If you can leave them be, then this is much "nicer" way:
my %prices = (
item1 => 25.99,
item2 => 21.99,
item3 => 29.99
);
: I want to have this list in a seperate delimited data file, lets say
^^^^^^^^^
delimited with what?
what you have shown ( 'item1','25.99', ) is delimited by
single quotes, is that what you mean?
It would be much easier for us to tell you how to read in
the data if you told us what the data looked like.
Or if you control what format the data will be in.
I will do it with 2 space-separated fields:
-------------------------
#!/usr/bin/perl -w
use strict;
my %prices;
while (<DATA>) {
my($key, $value) = split;
$prices{$key} = $value;
}
print "$_ ==> $prices{$_}\n" foreach sort keys %prices;
__DATA__
item1 25.99
item2 21.99
item3 29.99
-------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Jul 1999 07:37:18 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regex Problem - I think
Message-Id: <7neere$513$1@lublin.zrz.tu-berlin.de>
r j huntington <wolph@merlin.albany.net> wrote in comp.lang.perl.misc:
>Jordan Hiller (hiller@email.com) wrote:
>: How about this:
>: # UNTESTED
>:
>: $string =~ s#/.*##;
>
>Hi, thanks, Jordan, but I get:
>
>"Can't modify division in scalar assignment..."
You're getting *what*? Not with Jordan's substitution. It works
just fine.
>However, I think I see where you're going with this and I
>will try some things.
Just try it the way it is.
> Am I correct that the .* means
>"and everything following" ??? Thanks again, Ralph
Well yes, sorta. "." matches any character except newline (normally,
there are ways to make it match newline too). "*" means zero or
more occurrences of the preceding entity, "." in this case. This
operator is greedy, as the parlance is, that is it prefers more
over zero, the more the merrier in fact. So together they mean
(almost) what you think they mean.
Anno
------------------------------
Date: Sat, 24 Jul 1999 20:05:46 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: regexp help
Message-Id: <qckdn7.87f.ln@magna.metronet.com>
satishc@my-deja.com wrote:
: I would like to create a regular expression that matches the first of
: the following entries in a log file:
: blank (new line)
: some text of varying length
: some text of varying length
: some text of varying length
: some text of varying length
: depending on the entry another line of text
: blank (new line)
"paragraph mode" reads input in "chunks" that are separated
by one or more blank lines.
{ local $/ = ''; # empty string means "paragraph mode"
while (<>) {
chomp;
print "$_\n-----------------------\n";
}
}
: However it returns the entire set of records not just the first one.
: Could someone please help me figure out what I'm doing wrong?
: I'd also like to be able to have a user parse by an entry on the second
: line of a record,
I don't know what "parse an entry" means.
I will assume "match an entry" instead.
: but have the entire entry returned, not just the
: second line.
Change the print to:
print "$_-----\n" if /^.*\n.*$pattern/;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 25 Jul 1999 11:23:32 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Replacing and Stripping HTML
Message-Id: <7nfdrf$j991@news.cyber.net.pk>
: Here is what I am trying to do:
:
: 1. Open a file (which I know how to do)
nice!
: 2. Replace every occurance of </FONT> in that file with |
see, s///
: 3. Strip remaining HTML from the file
look at HTML::Parser
: 4. Replace contents of file with new results.
perldoc -f open
------------------------------
Date: Sat, 24 Jul 1999 23:24:16 -0800
From: argouarc@idiom.com (Argouarch)
Subject: Re: Variables in Regx?
Message-Id: <argouarc-2407992324160001@argouarc.dial.idiom.com>
In article <slrn7pkn0p.43e.abigail@alexandra.delanet.com>,
abigail@delanet.com wrote:
> Uhm, he said: "I want to bold every instance of the defined word in each
> definition". The keyword here being "every". I think the split is useful
> and the /g necessary. You are right about the regex metacharacters, but
> I was assuming the data was such that it wouldn't have those characters.
> If there might be regex metacharacters, a leading \Q would fix that.
>
> ** while (<FILE>) {
> ** s|([^:]+):|<b>$1</b>:|;
> ** print OUTFILE;
> ** }
>
> That would bold the keyword. That wouldn't bold the keyword in the
> definition.
Abigail, Your are exactly right, the stuff above did not work because I
want to bold every instance of the keyword on a line excepted the first
one, which is used by the binary search. I mean, I dont want all the lines
starting by <b>! and the first key is uc anyway. I don't want to do a
substitution on the first instance but I need it either remembered or as
variable..
So I am stuck again.
to be sure, a line is like this:
KEY: blah blah blah key, blah blah blah key blah..
Philippe
------------------------------
Date: Sat, 24 Jul 1999 20:26:12 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Variables in Regx?
Message-Id: <4jldn7.87f.ln@magna.metronet.com>
Argouarch (argouarc@idiom.com) wrote:
: Here's the problem, I have a dictionary flat file with 30 000 lines, I
: want to bold every instance of the defined word in each definition so my
: regular expresion has to change for each line (sure dont want to do this
: by hand, and was'nt PERL designed just for this crap :=)?.
: I also want the html tags inserted in the file itself so I wrote a simple
: utility script to change the file.
: I tried this:
: Open...
^
^ syntax error
: While (<FILE>){
^
^ syntax error
: ($key,$translation)=split(/:/);
: s/(${$key})/<b>$1<\/b>/g;
s#\b($key)\b#<b>$1</b>#g; # might need to throw in a \Q there too
or, if you want to exclude bolding the defined word "column":
$translation =~ s#\b($key)\b#<b>$1</b>#g;
$_ = "$key:$translation"; # put them back together
: }
: would not work... although I am forcing dereferencing of $key
[snip]
: Am I missing something here?
I don't see that references are needed for this.
Am I missing something here? :-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Jul 1999 07:29:20 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: Which group is appropriate?
Message-Id: <379abcd0$0$210@nntp1.ba.best.com>
Abigail <abigail@delanet.com> wrote:
> Kevin Kinnell (kejoki@netdoor.com) wrote on MMCLIV September MCMXCIII in
> <URL:news:379A7B23.237A5761@netdoor.com>:
> ** Is there a group where Perl novices--who don't have all of
> ** the faqs memorized and are just exploring how to get things
> ** done--should be posting so that they may figure things out
> ** together instead of pestering the experts and exposing them-
> ** selves to the inevitable ridicule that attends learning how
> ** to fit into a new culture?
> No, there isn't. This is Usenet. Usenet is not the place to ask the same
> questions over and over again.
Actually, that's *exactly* what Usenet is, and c.l.p.m. illustrates
that fact about as well as any group I've seen. Wishing for it to be
otherwise does not make it so, regardless of the "shouldness" of that
position.
> And think about it. Perl can be pretty complex at some times. You really
> think that figuring out stuff with a bunch of newbies will give you
> better or faster answers than reading the FAQ?
Not faster answers, no. But "better" is a subjective measurement,
subject to individual variations in sort criteria. It seems pretty
clear that the original author would appreciate a group where newbie
questions (like Perl babytalk) enjoyed some degree of official
sanction. Personally, I would too. Somewhere where beginners could
engage in beginner-level discussions without having to worry about
being zinged for missing something in the documentation. Even his
original article here, which I thought was a model of appropriateness,
from the good subject line, to the provision of necessary information,
to the careful and specific formulation of the question, and even the
respectful tone it displayed towards the group's experts, got him the
patented Abigail brush-back, with a hard fastball up under the chin.
There will, of course, always be inappropriate behavior here, and there
will be those who believe their are justified in responding negatively
as a means of correction. But I have come to the opinion that there
really are two distinct groups of users here (or at least, a continuum
with swollen lobes at either end). On the one hand are the professional
programmers who created this group, and believe, rightly, that they
should be allowed to determine its future. On the other hand are a
whole bunch of us Web carpetbaggers, amateurs who never took a computer
science class and, for better or worse, will probably never wind up
coding full-time.
A group specifically for beginners could help ease some of the cultural
clashes, I believe. I've heard many of the standard arguments against
it, but I really think it would be worth a try.
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V9 Issue 249
*************************************