[25128] in Perl-Users-Digest
Perl-Users Digest, Issue: 7378 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 8 14:10:29 2004
Date: Mon, 8 Nov 2004 11:10:10 -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 Mon, 8 Nov 2004 Volume: 10 Number: 7378
Today's topics:
references to OTHER objects <nospam@nospam.com>
Re: references to OTHER objects <mritty@gmail.com>
Re: references to OTHER objects <spamtrap@dot-app.org>
Re: references to OTHER objects <a@ry.ca>
Re: references to OTHER objects <nospam@nospam.com>
Re: references to OTHER objects <1usa@llenroc.ude.invalid>
Re: references to OTHER objects <nospam@nospam.com>
Re: references to OTHER objects <nospam@nospam.com>
Re: references to OTHER objects <mritty@gmail.com>
Re: references to OTHER objects <notvalid@email.com>
Re: references to OTHER objects <nospam@nospam.com>
Re: references to OTHER objects <nospam@nospam.com>
Re: references to OTHER objects <1usa@llenroc.ude.invalid>
Re: references to OTHER objects <1usa@llenroc.ude.invalid>
Re: references to OTHER objects <nospam@nospam.com>
Re: references to OTHER objects <spamtrap@dot-app.org>
Re: references to OTHER objects <mritty@gmail.com>
Re: Regex for all word "boundaries" (was: FAQ 6.17: Why <comdog@panix.com>
Re: remove unwanted parts from strings <bdu@iastate.edu>
Re: Spam-free Mailto.pl or similar prog? <madra@rua.net>
Re: why not print $A[0] (Mark Galecki)
Re: why not print $A[0] ctcgag@hotmail.com
Re: why not print $A[0] <mritty@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 8 Nov 2004 10:35:36 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: references to OTHER objects
Message-Id: <1099928201.117388@nntp.acecape.com>
Hi all,
I hope I have my terminology down right. I've finally gotten down how use
reference for scalar's, arrays, and arrays of arrays.
Of course now I would like to pass into a subroutine a reference for an
object, Mail::Header. Now I couldn't find anythign in perldoc related to
references and objcts, so of course I tried the syntax as if it were just a
scalar (* below), and of course it works. And it seems to make sense that
it shoudl work this way. Afterall, it seems to me that an object is merely
a scalar reference to a complex structure/object, but still too new to me to
be sure.
And we all know just cause it works doesn't make that the right way, and it
can always come and bite you in the a** later. So if anybody knows of the
proper perldoc keywords, or links, would appreciate it.
As always, thanks ahead,
daniel
my $IMhead = $IMobj->head();
CleanTags(\$IMhead, \@tags);
sub CleanTags
{
my ($ref, $array_ref) = @_;
my $tag;
foreach $tag (@$array_ref)
{
if($tag =~ /received/i)
{
$$ref->delete("Received");
------------------------------
Date: Mon, 08 Nov 2004 15:53:20 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: references to OTHER objects
Message-Id: <QDMjd.1211$Tz3.589@trndny08>
"daniel kaplan" <nospam@nospam.com> wrote in message
news:1099928201.117388@nntp.acecape.com...
> Hi all,
>
> I hope I have my terminology down right. I've finally gotten down how
use
> reference for scalar's, arrays, and arrays of arrays.
>
> Of course now I would like to pass into a subroutine a reference for
an
> object, Mail::Header.
Are you sure you want to do that? An object is already a reference.
When you pass an object to a subroutine, you are by definition passing a
reference, and therefore already using pass-by-reference. What benefit
are you seeing out of passing a reference to a reference?
> Now I couldn't find anythign in perldoc related to
> references and objcts, so of course I tried the syntax as if it were
just a
> scalar (* below), and of course it works. And it seems to make sense
that
> it shoudl work this way. Afterall, it seems to me that an object is
merely
> a scalar reference to a complex structure/object, but still too new to
me to
> be sure.
Correct. An object is a reference (usually to a hash, but it could be a
reference to an array or even to a scalar) that has been blessed into a
particular class. And all references are by definition scalars.
> And we all know just cause it works doesn't make that the right way,
and it
> can always come and bite you in the a** later. So if anybody knows of
the
> proper perldoc keywords, or links, would appreciate it.
The syntax you posted (which I've snipped) is correct, but I still
question your reason for believing you need to pass a reference to the
object, rather than just pass the object itself.
Paul Lalli
------------------------------
Date: Mon, 08 Nov 2004 11:02:05 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: references to OTHER objects
Message-Id: <JuqdncZ9z7XjBRLcRVn-ig@adelphia.com>
daniel kaplan wrote:
> Now I couldn't find anythign in perldoc related to
> references and objcts
I showed you where to find *seven* relevant tutorials in the "casting
question" tutorial above. Why haven't your read them?
> Afterall, it seems to me that an object is merely
> a scalar reference to a complex structure/object
It seems to me that this is explained in the docs you haven't read.
> And we all know just cause it works doesn't make that the right way
I can definitely agree with that, at least. ;-)
> So if anybody knows of the
> proper perldoc keywords, or links, would appreciate it.
I told you about *seven* relevant perldocs, in the "casting question"
thread above. Read it, I don't feel the need to repeat myself simply
because you threw a tantrum and ignored me the first time.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Mon, 8 Nov 2004 10:04:28 -0600
From: Ryan Thompson <a@ry.ca>
Subject: Re: references to OTHER objects
Message-Id: <20041108100008.S20279@coyote>
daniel kaplan wrote to :
> Hi all,
>
> I hope I have my terminology down right. I've finally gotten down how use
> reference for scalar's, arrays, and arrays of arrays.
>
> Of course now I would like to pass into a subroutine a reference for an
> object, Mail::Header. Now I couldn't find anythign in perldoc related to
> references and objcts,
The first subheading in the "perlobj" page reads:
An Object is Simply a Reference
So, why pass a reference to a reference? Just pass $obj.
> So if anybody knows of the proper perldoc keywords, or links, would
> appreciate it.
I recommend reading perlref, perlboot, perlobj, and perltoot, in about
that order. I'd consider those to be the "required reading" for doing
anything half serious with objects in Perl.
- Ryan
--
Ryan Thompson <ryan@sasknow.com>
SaskNow Technologies - http://www.sasknow.com
901-1st Avenue North - Saskatoon, SK - S7K 1Y4
Tel: 306-664-3600 Fax: 306-244-7037 Saskatoon
Toll-Free: 877-727-5669 (877-SASKNOW) North America
------------------------------
Date: Mon, 8 Nov 2004 11:17:22 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: references to OTHER objects
Message-Id: <1099930708.336145@nntp.acecape.com>
"Ryan Thompson" <a@ry.ca> wrote in message
news:20041108100008.S20279@coyote...
thanks to all for the linx
------------------------------
Date: 8 Nov 2004 16:45:36 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: references to OTHER objects
Message-Id: <Xns959B77A11C39Easu1cornelledu@132.236.56.8>
"daniel kaplan" <nospam@nospam.com> wrote in news:1099930708.336145
@nntp.acecape.com:
> "Ryan Thompson" <a@ry.ca> wrote in message
> news:20041108100008.S20279@coyote...
>
>
> thanks to all for the linx
Which you have been pointed to many times before.
Oh well.
Sinan.
------------------------------
Date: Mon, 8 Nov 2004 11:55:05 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: references to OTHER objects
Message-Id: <1099932971.619608@nntp.acecape.com>
"Sherm Pendley" <spamtrap@dot-app.org> wrote in message
news:JuqdncZ9z7XjBRLcRVn-ig@adelphia.com...
> daniel kaplan wrote:
actually this is to ALL:
> I showed you where to find *seven* relevant tutorials in the "casting
> question" tutorial above. Why haven't your read them?
ok, have gone through those, and the one title that really just said
(although not one of my books had this):
"An Object is Simply a Reference" (which brings me to a serious question
about perldoc, all the way below***)
So, and just restating cause I like to make sure I am getting down the
syntax of Perl right (especially with referenciong). My first scenario
worked because I passed a reference to a reference, and was refererncing
that correctly....Sorry, I hate that word reference, in C land, my original
code work because i was passing a pointer to a pointer and casting it
properly, correct?
and yes, I changed it so I just pass the reference...itself now
thanks again all.
*** i typed every variation of object & reference that i could think
of....into perldoc BEFORE posting here, i used -q, i didn't, i used quotes,
i didn't...surely there must be a better way to do a search? or is it that
perldoc ONLY covers the FAQs 1-9, and not the tutorials? and then is there
a better way to search the tut's? i know perldoc see's the tut's cause
perldoc perlboot finds it...but when searching for something and just have
keywords, it isn't the easiest to use. so please don't think i DON'T go
through perldoc before posting. even if i was just evil and enjoyed the
back and forth bickering (which i am not, and i don't) at least give me
credit that i am just too lazy to do all that typing...as i said, had i
found the section , "An Object is Simply a Reference" ...i can tarnslate
that to , just pass the pointer, that would have been it, no post, end of
story...
ok, that was long winded way of saying is there a better way to search? for
instance, i think it's easier to go to faq.perl.org and since it shows all
headlines for all FAQs (1-9) on one page, a string search usually find me
the answer...(imagine how many posts i would have had otherwise)...so does
anyone know of a site where i can do the same with the tut's?
whew....
thanks again
------------------------------
Date: Mon, 8 Nov 2004 11:57:16 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: references to OTHER objects
Message-Id: <1099933102.679748@nntp.acecape.com>
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
news:Xns959B77A11C39Easu1cornelledu@132.236.56.8...
> Which you have been pointed to many times before.
hey sinan,
of course i have gone through them, and they don't all instantly settle in
my head, so a better form searching woudl be helpful, especially if i could
search on "object" and "reference"
anyway, please read the post i JUST made regarding this
------------------------------
Date: Mon, 08 Nov 2004 17:06:44 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: references to OTHER objects
Message-Id: <EINjd.1$lY1.0@trndny04>
"daniel kaplan" <nospam@nospam.com> wrote in message
news:1099932971.619608@nntp.acecape.com...
> *** i typed every variation of object & reference that i could think
> of....into perldoc BEFORE posting here, i used -q, i didn't, i used
quotes,
> i didn't...surely there must be a better way to do a search? or is it
that
> perldoc ONLY covers the FAQs 1-9, and not the tutorials? and then is
there
> a better way to search the tut's? i know perldoc see's the tut's
cause
> perldoc perlboot finds it...but when searching for something and just
have
> keywords, it isn't the easiest to use. so please don't think i DON'T
go
> through perldoc before posting. even if i was just evil and enjoyed
the
> back and forth bickering (which i am not, and i don't) at least give
me
> credit that i am just too lazy to do all that typing...as i said, had
i
> found the section , "An Object is Simply a Reference" ...i can
tarnslate
> that to , just pass the pointer, that would have been it, no post, end
of
> story...
>
> ok, that was long winded way of saying is there a better way to
search? for
> instance, i think it's easier to go to faq.perl.org and since it shows
all
> headlines for all FAQs (1-9) on one page, a string search usually find
me
> the answer...(imagine how many posts i would have had otherwise)...so
does
> anyone know of a site where i can do the same with the tut's?
I am almost *positive* you've been shown this before (though I'm not
going back through the archives to verify), but the Perldoc does have a
Table of Contents readily available:
perldoc perltoc
That will show you every available perldoc section, along with a
description of what it covers. I don't especially understand why this
isn't sufficient for your purposes.
To answer a question you embedded in there, the -q option to perldoc
does indeed only query the text of the questions in the FAQ, and does
not cover any other perldoc source.
Paul Lalli
------------------------------
Date: Mon, 08 Nov 2004 17:24:06 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: references to OTHER objects
Message-Id: <WYNjd.6314$zx1.3866@newssvr13.news.prodigy.com>
daniel kaplan wrote:
> of course i have gone through them, and they don't all instantly settle in
> my head, so a better form searching woudl be helpful, especially if i could
> search on "object" and "reference"
Of course. But, what everyone is trying to say is:
The next time you have a question, go check out
the relevant docs one more time *before* posting.
I understand that perldoc can be sometimes lacking (I'm sure patches are
welcome if you ever want to rectify the problem instead of constantly
complaining), but that does not mean you should give up just because you
could not figure out the correct perldoc section to read. When I was
learning Perl, I used 'grep' much more than perldoc until I was
comfortable with what each section discussed.
I am on the verge of killfiling you since almost all your questions so
far are easily answered by browsing the docs. The docs have been written
for a reason. Please use them, and stop wasting everyone else's time
unnecessarily.
Nothing personal.
--Ala
------------------------------
Date: Mon, 8 Nov 2004 12:30:18 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: references to OTHER objects
Message-Id: <1099935081.809950@nntp.acecape.com>
"Paul Lalli" <mritty@gmail.com> wrote in message
news:EINjd.1$lY1.0@trndny04...
> I am almost *positive* you've been shown this before (though I'm not
> going back through the archives to verify), but the Perldoc does have a
> Table of Contents readily available:
> perldoc perltoc
you may have , but surely you can't think that that is anytype of solution,
do you? that prints out over 217k of data...after ten minutes of holding
down the spacebar, it still isn't done spitting out the contents? how could
one do a reasonable search within that?!?!?!?! i think someone gave me a
suggestion of a grep type solution for PC...will look that up to see if i
can use that....i just piped out the results of perldoc perltoc to a file,
but it's not in any readable format that's easy to read (otherwise would
just save that and search for my keywords in there)
> To answer a question you embedded in there, the -q option to perldoc
> does indeed only query the text of the questions in the FAQ, and does
yeah., the -q this is just the other way i try....i don't just perldoc my
question, then come here....
i try wiht a -q, without, quotes, then i go to faq.perl.org, text search
there, browse my books, then come here....
thanks
------------------------------
Date: Mon, 8 Nov 2004 12:40:35 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: references to OTHER objects
Message-Id: <1099935698.687240@nntp.acecape.com>
"Ala Qumsieh" <notvalid@email.com> wrote in message
news:WYNjd.6314$zx1.3866@newssvr13.news.prodigy.com...
> daniel kaplan wrote:
> The next time you have a question, go check out
> the relevant docs one more time *before* posting.
please don't think i don't try, but it's the searchign where i lose.
> I understand that perldoc can be sometimes lacking (I'm sure patches are
> welcome if you ever want to rectify the problem instead of constantly
> complaining),
i think i am the last one anyone would want to do this, but i did make a
suggestion, in a sort of round about way...i found perldoc hard to use, and
can easily search FAQs 1-9 at faq.perl.org because questions show up at once
and with a text search, bang, you find what you're looking for...is it
possible to get something like that up for the perltoc ? am sure it would
elimnate more than half the questions from lots of people..
> learning Perl, I used 'grep' much more than perldoc until I was
i will start to look for a grep for pc....FIND seems to be quite lacking
where as grep is not
> I am on the verge of killfiling you since almost all your questions so
> far are easily answered by browsing the docs. The docs have been written
> for a reason. Please use them, and stop wasting everyone else's time
> unnecessarily.
hey i understand, but you did say yourself, that the "that perldoc can be
sometimes lacking", surely there is some type of solution. as i said, woudl
much rather read than type back ad forth...besides, saving the link to your
FOUND answer in the docs is the best form of refernce i could find
but it boils down to being able to find the keywords
>
> Nothing personal.
the wway you word it, not in the slightest way did i take it
------------------------------
Date: 8 Nov 2004 17:48:28 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: references to OTHER objects
Message-Id: <Xns959B8249EBB89asu1cornelledu@132.236.56.8>
"daniel kaplan" <nospam@nospam.com> wrote in
news:1099933102.679748@nntp.acecape.com:
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
> news:Xns959B77A11C39Easu1cornelledu@132.236.56.8...
>
>> Which you have been pointed to many times before.
>
> hey sinan,
>
> of course i have gone through them, and they don't all instantly
> settle in my head, so a better form searching woudl be helpful,
Feel free to write one.
The fact that no one has bothered too much to try and write a super duper
perldoc search engine is because everyone has a 'best' way of searching
for the documentation.
> especially if i could search on "object" and "reference"
>
> anyway, please read the post i JUST made regarding this
In the mean time, I will remind you once again, that nice, HTML formatted
documentation is accessible through the ActiveState Perl program group in
the Windows start menu. While not searchable, it does allow you to view
the table of contents and jump back and forth between topics.
I don't know how many times I mentioned this.
I fully expect you to be running 640x480 and 16 colors so, please, before
you come back and say the standard docs are not visible, I'll recommend
scrolling down a little in the TOC frame to the section titled "Perl Core
Documentation". Horror of horrors, if you used a browser such as Firefox,
you could easily have a whole bunch of those documents open all at the
same time, and even bookmark them so that you could recreate your
documentation workspace at the click of a button later.
You might have noticed I am no longer replying to you but just reveling
in the joy of Firefox. Of course, I still occasionally use the command
line but that is becoming rarer and rarer since Firefox has one of the
nicest "find on the page as you type" features.
See, I have never been too comfortable with the command line grep utility
'cause I have a bad memory and by the time I have figured out the right
options ... well, it's too late.
On the other hand, say if I find out I need to remember what I need to
redefine a built-in, I open the perlfaq7 HTML page in Firefox (it's just
a CTRL-click from the TOC), then do CTRL-F and start typing b u i ... by
the time I have typed the 'i' the focus has been moved to
How do I redefine a builtin function, operator, or method?
and I can press enter to view the answer.
I could go on and on but I am going to stop here. The point is, all the
documentation is under the tip of your fingers. If you do not like one
method of searching the documentation, there are many others. Heck, you
could even use Start -> Search -> Find Files containing text which is a
primitive grep.
But above it all, you should have read the table of contents and the FAQ
at least once by now. That way, you would have known roughly where to
look and thus would have had a better chance of actually locating the
documentation.
Insisting that other people read the docs for you ain't gonna go over
well.
Back to Firefox for me ...
Sinan.
------------------------------
Date: 8 Nov 2004 17:54:14 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: references to OTHER objects
Message-Id: <Xns959B8344396ECasu1cornelledu@132.236.56.8>
"daniel kaplan" <nospam@nospam.com> wrote in
news:1099935698.687240@nntp.acecape.com:
> "Ala Qumsieh" <notvalid@email.com> wrote in message
> news:WYNjd.6314$zx1.3866@newssvr13.news.prodigy.com...
>> daniel kaplan wrote:
>
>> The next time you have a question, go check out
>> the relevant docs one more time *before* posting.
>
> please don't think i don't try, but it's the searchign where i lose.
And in quite a few other places.
>
>> I understand that perldoc can be sometimes lacking (I'm sure patches
>> are welcome if you ever want to rectify the problem instead of
>> constantly complaining),
>
> i think i am the last one anyone would want to do this, but i did make
> a suggestion, in a sort of round about way...i found perldoc hard to
> use, and can easily search FAQs 1-9 at faq.perl.org because questions
> show up at once and with a text search, bang, you find what you're
> looking for...is it possible to get something like that up for the
> perltoc ? am sure it would elimnate more than half the questions from
> lots of people..
OK ... How hard is it to go:
Start -> Search -> For Files or Folders
Search for files or folders named: *.html
Containing text: How can I pass/return
Look in: C:\Perl
Then click the "Search Now" button?
The search will return perltoc.html, perlfaq.html (which you can ignore
because they are not specific enough) and perlfaq7 (which is where you
should look).
It is expected that before you start programming you know the facilities
made available to you by the OS you yourself have chosen.
> but it boils down to being able to find the keywords
No it doesn't.
Sinan.
------------------------------
Date: Mon, 8 Nov 2004 12:58:09 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: references to OTHER objects
Message-Id: <1099936753.308064@nntp.acecape.com>
"Ala Qumsieh" <notvalid@email.com> wrote in message
news:WYNjd.6314$zx1.3866@newssvr13.news.prodigy.com...
> I understand that perldoc can be sometimes lacking (I'm sure patches are
> welcome if you ever want to rectify the problem instead of constantly
> complaining), but that does not mean you should give up just because you
> could not figure out the correct perldoc section to read. When I was
> learning Perl, I used 'grep' much more than perldoc until I was
> comfortable with what each section discussed.
you know what ala? you are right, let me put my money where my mouth
is....will write something to better work with perltoc...it'll be for me,
since the only thing i have confidence in write in currently is C....but if
it will help me navigate the dox quicker and easier, why not? and besides,
i can't be the only perl newbie running off of a windows machine. one day
someone else in my very own scenario may be able to use it....i hate throw
away code...
thanks,
daniel
------------------------------
Date: Mon, 08 Nov 2004 13:10:14 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: references to OTHER objects
Message-Id: <dOKdnVDRSqwVKxLcRVn-hQ@adelphia.com>
daniel kaplan wrote:
> So, and just restating cause I like to make sure I am getting down the
> syntax of Perl right (especially with referenciong). My first scenario
> worked because I passed a reference to a reference, and was refererncing
> that correctly
Exactly. You took a reference to an object - i.e. a reference to a
reference - and dereferenced that twice, by using both $$ and ->.
Because an object is already a reference, there's no need to take an
additional reference to it. You could simply pass it like so:
CleanTags($IMhead, \@tags);
And then in your code, you'd dereference it with:
$ref->delete('...');
> ....Sorry, I hate that word reference, in C land, my original
> code work because i was passing a pointer to a pointer and casting it
> properly, correct?
See my earlier post (the [OT] one in the "casting question" thread)
about casting vs. dereferencing - in C it's common to type cast a void*
that points to a struct, so that you can dereference it to get at the
struct elements.
But it's important to understand that even in C, the cast and the deref
are separate operations. You can type cast non-pointer types, and if a
pointer is already of the correct type you can dereference it without
type casting. The two things are frequently used together, but they are
*not* the same thing.
What you're doing here is just dereferencing a pointer (aka reference).
> i didn't...surely there must be a better way to do a search? or is it that
> perldoc ONLY covers the FAQs 1-9, and not the tutorials?
From "perldoc perldoc":
-q perlfaq-search-regexp
The -q option takes a regular expression as an argument. It will
search the question headings in perlfaq[1-9] and print the
entries matching the regular expression.
"perldoc perldoc" is a little too recursive to be obvious, so I won't
yell at you for not reading it. ;-)
> and then is there a better way to search the tut's?
I don't know of any, although I don't think a full-text search of the
tutorials would be as useful as the one provided for FAQ questions anyway.
Unlike the FAQs, the tutorials are aren't intended to be read piecemeal
- you really should work through the tuts from beginning to end. They're
all listed in "perldoc perl", with a brief description of each.
> please don't think i DON'T go through perldoc before posting.
The very first tutorial listed in "perldoc perl" is titled "Perl
references short introduction", and "Perl OO tutorial for beginners" is
just a few lines down from that.
Honestly now - when you tell us you can't find the tutorials that are
listed near the top the *first* page of the Perl docs, what else are we
supposed to think?
> headlines for all FAQs (1-9) on one page
"perldoc perlfaq" has that too - although the hyperlinks in the web
version are admittedly damned handy.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Mon, 08 Nov 2004 18:45:53 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: references to OTHER objects
Message-Id: <B9Pjd.2$eG4.0@trndny08>
"daniel kaplan" <nospam@nospam.com> wrote in message
news:1099935081.809950@nntp.acecape.com...
> "Paul Lalli" <mritty@gmail.com> wrote in message
> news:EINjd.1$lY1.0@trndny04...
>
> > I am almost *positive* you've been shown this before (though I'm not
> > going back through the archives to verify), but the Perldoc does
have a
> > Table of Contents readily available:
> > perldoc perltoc
>
> you may have , but surely you can't think that that is anytype of
solution,
> do you? that prints out over 217k of data...after ten minutes of
holding
> down the spacebar, it still isn't done spitting out the contents? how
could
> one do a reasonable search within that?!?!?!?!
Does your version of `more` not support searching, or do you just not
know how to use it? When I run perldoc, the results are piped to
`more`. Within `more`, pressing / followed by a regexp to search for
takes me directly to the first match. Does this not work for you for
some reason?
> yeah., the -q this is just the other way i try....i don't just perldoc
my
> question, then come here....
>
> i try wiht a -q, without, quotes, then i go to faq.perl.org, text
search
> there, browse my books, then come here....
You seem to be obessed with just the FAQ. The FAQ is a minor part of
the entire Perldoc. I suggest becoming familiar with the rest of it.
Paul Lalli
------------------------------
Date: Mon, 08 Nov 2004 11:47:45 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Regex for all word "boundaries" (was: FAQ 6.17: Why don't word-boundary searches with "\b" work for me?)
Message-Id: <081120041147454243%comdog@panix.com>
In article <slrncon2vb.go2.tadmc@magna.augustmail.com>, Tad McClellan
<tadmc@augustmail.com> wrote:
> Jeff Boes <jboes@qtm.net> wrote:
> > At some point in time, PerlFAQ Server <comdog@panix.com> wrote:
> >>6.17: Why don't word-boundary searches with "\b" work for me?
> > I.e., I need to find the points at which the string transits from being "In
> > a
> > word" to being "Not in a word" and vice-versa; this includes the point just
> > before the first word-like character -- which may or may not be the first
> > character of the string -- and the point just after the last word-like
> > character
> > -- again, could be the last character, or maybe not.
> \b\w+\b
Also consider that \w+ is Perl's version of word characters, which
may be different from your own. For instance, contractions (e.g.
"don't", "can't") might be one word to you but two to perl.
Between the two \b, put whatever character class you think make
up a word. :)
--
brian d foy, comdog@panix.com
Subscribe to The Perl Review: http://www.theperlreview.com
------------------------------
Date: Mon, 08 Nov 2004 08:31:42 -0600
From: bingster <bdu@iastate.edu>
Subject: Re: remove unwanted parts from strings
Message-Id: <2v9eafF2jcrhhU1@uni-berlin.de>
Many thanks to all who replied. I've not been programming for a while.
With Lars lucid explanation, I started remembering a lot. Yeah, '*.'
was my typo. With this problem resovled, I can move on now.
Bing
Lars Eighner wrote:
> In our last episode,
> <2v294bF2g7uuhU1@uni-berlin.de>,
> the lovely and talented bingster
> broadcast on comp.lang.perl.misc:
>
>
>>Hello,
>
>
>>If there is a string like this:
>
>
>>$test = 'a bc (B, M, D),d e (B, M),lfm (D)'
>
>
>>how can I remove all the '(*.)' parts to make it something like:
>
>
>>'a bc,d e,lfm'
>
>
>>I tried:
>
>
>>$test =~ s/\(*.\)//g;
>
>
> This doesn't do what you think. I think you have got *. where you
> meant .*, but even correcting that won't do what you think.
>
> As you have written it above, you are looking to match zero or more
> (s followed by any single character, followed by ). This will remove
> the (D) at the end of your string and all the )s with the character
> that precedes them.
>
>
>>But the result is 'a bc (B, M, ,d e (B, ,lfm '.
>
>
> Exactly.
>
> Now I don't know whether when you wrote *. it was a typo for .* or
> whether you are really confused about what * and . mean. But let's
> try it the other way, in case it was a typo.
>
> You may have meant:
>
> $test =~ s/\(.*\)//g;
>
> which says match on ( followed by zero or more of any character
> followed by ).
>
> But the result in this case would be 'a bc '. You see REGULAR
> EXPRESSIONS ARE GREEDY (write this in stone), which means they
> will match the biggest string they can. And the biggest match
> here begins with the first ( and ends with the last ). But that
> is not what you want. You want to match the first ( and everything
> up to and including the first ), and then you want to match the
> second ( and everything up to and including the second ) and so
> forth.
>
> So try this:
>
> $test =~ s/\([^)]*\)//g;
>
> This says, match a ( followed by zero or more characters that
> are not ) and then a ). Notice that you do not escape the ) in
> the square brackets because ) is not special in square brackets
> - the characters that are special in square brackets are -]\^$
> .
>
> This gives you:
>
> a bc ,d e ,lfm
>
> which isn't quite what you want because you want the leading space
> with (s out too, if there is one, but it is a step in thr right direction.
>
> In order to remove that white space character if there is one, this
> will work (you may want to adjust it if you have more than one white
> space character or if you really only want to remove space characters
> and not any white space character):
>
> $test =~ s/\s?\([^)]*\)//g;
>
> This gives you:
>
> a bc,d e,lfm
>
> which is exactly what you asked for:
>
>
>>$test = 'a bc,d e,lfm'
>
>
> I believe there are other ways to make regular expressions less
> greedy, and perhaps some of them are better, but this makes sense
> to me.
>
------------------------------
Date: Mon, 08 Nov 2004 17:16:02 GMT
From: "Madra Rua" <madra@rua.net>
Subject: Re: Spam-free Mailto.pl or similar prog?
Message-Id: <mRNjd.21161$KJ6.15151@newsread1.news.pas.earthlink.net>
Thanks Gunnar.
The attachment was OE's work. I pasted a web page into it, not knowing that
it would apppear as an attachment, as well as in text form.
I also wasn't aware that this NG was progging only.
Thank you very much for your hjelp ;-)
Enjoy your week :-)
MR
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:2v8pa2F2i0ibfU1@uni-berlin.de...
> Madra Rua wrote:
> > My old mailto.pl script will not work on iPower's web hosting site. I
> > searched for a replacement and found the interesting web site below.
> > Does anyone know what the latest situation is and do they have a
> > complete mailto.pl with redirection.
>
> Note that questions about ready-to-go scripts are off topic in this
> group, which is for discussing Perl programming.
>
> Anyway, the Perl module CGI::ContactForm
> (http://www.gunnar.cc/contactform/readme.html) was written with the
> spammers' harvesters in mind, is platform independent, and should serve
> your needs.
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 8 Nov 2004 10:22:52 -0800
From: mark_galeck_spam_magnet@yahoo.com (Mark Galecki)
Subject: Re: why not print $A[0]
Message-Id: <50064a21.0411081022.515838ff@posting.google.com>
OK, I am sorry about the apparent lack of context. I purposely
omitted some details which I thought were irrelevant, to not waste
your time. I guess I overdid it.
So what I can understand from the responses, is that I have to do
print {$A[0]} "foo\n";
or
$a = $A[0]; print $a "foo\n";
but not
print $A[0] "foo\n";
because of the way the Perl parser works. OK I can accept that.
But please, can someone point me to where this is written down in the
Camel book? (I really tried to find it there ). Or is it?
Thank you
Mark
------------------------------
Date: 08 Nov 2004 18:38:47 GMT
From: ctcgag@hotmail.com
Subject: Re: why not print $A[0]
Message-Id: <20041108133847.620$bC@newsreader.com>
Stuart Moore <stjm2@cam.ac.uk> wrote:
> Gunnar Hjalmarsson wrote:
>
> > This works fine:
> >
> > my @A;
> > open $A[0], '> file';
> > print { $A[0] } "foo\n";
> > close $A[0];
> >
> > You just need to take care of the ambiguity.
> >
>
> OOI, how is
>
> print $a[0] "foo\n";
>
> any more ambiguous than
>
> print $a "foo\n";
In your case it is obvious what is intended, but it may not always
be:
print $a [0],{1}
Does this print two stringified references to filehandle $a, or one
stringified reference to file handle $a[0]?
I guess parser programmers decided there was too much of a limit to their
ability to decern what you meant in this context, so required explicitness.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 08 Nov 2004 19:02:02 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: why not print $A[0]
Message-Id: <KoPjd.77$Bj2.48@trndny01>
<ctcgag@hotmail.com> wrote in message
news:20041108133847.620$bC@newsreader.com...
> Stuart Moore <stjm2@cam.ac.uk> wrote:
> > OOI, how is
> >
> > print $a[0] "foo\n";
> >
> > any more ambiguous than
> >
> > print $a "foo\n";
>
> In your case it is obvious what is intended, but it may not always
> be:
> print $a [0],{1}
>
> Does this print two stringified references to filehandle $a, or one
> stringified reference to file handle $a[0]?
It can't be the second one, since a comma is illegal after the
filehandle in a print function. The ambiguity is whether it prints the
two refs to $a or the ref {1} and the element $a[0] to STDOUT.
(fwiw, perl resolves this to the second option I listed).
Paul Lalli
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7378
***************************************