[30452] in Perl-Users-Digest
Perl-Users Digest, Issue: 1695 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 6 14:09:47 2008
Date: Sun, 6 Jul 2008 11:09:11 -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, 6 Jul 2008 Volume: 11 Number: 1695
Today's topics:
Authen::Captcha - How do I make it display the image <news.freedom2surf.net>
Re: Authen::Captcha - How do I make it display the imag <spamtrap@dot-app.org>
Re: Authen::Captcha - How do I make it display the imag <news.freedom2surf.net>
Re: Authen::Captcha - How do I make it display the imag <news.freedom2surf.net>
Re: Authen::Captcha - How do I make it display the imag (Steven M. O'Neill)
Re: Authen::Captcha - How do I make it display the imag <spamtrap@dot-app.org>
Bot::BasicBot's forkit() creating zombies <marko@where.ever.invalid>
Re: Elisp Lesson on file processing (make downloadable <greymausg@mail.com>
Re: Generating fancy/pretty documents <bernie@fantasyfarm.com>
Re: Generating fancy/pretty documents <bernie@fantasyfarm.com>
How best to take a copy of a variable and edit it with <news@lawshouse.org>
Re: How best to take a copy of a variable and edit it w <daveb@addr.invalid>
Re: How best to take a copy of a variable and edit it w <tadmc@seesig.invalid>
Re: How best to take a copy of a variable and edit it w <news@lawshouse.org>
Re: Net::SMTP and Postfix mai considered spam by google <john1949@yahoo.com>
Want regex s/// to replace only nth occurrence jerrykrinock@gmail.com
Re: Want regex s/// to replace only nth occurrence <noreply@gunnar.cc>
Re: Want regex s/// to replace only nth occurrence <daveb@addr.invalid>
Re: Want regex s/// to replace only nth occurrence <wahab-mail@gmx.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 6 Jul 2008 15:33:40 +0100
From: <news.freedom2surf.net>
Subject: Authen::Captcha - How do I make it display the image
Message-Id: <eP2dnU2-gqZGSu3VRVnyggA@pipex.net>
Hi,
My PERL is VERU rusty. Not used in years and have to now implement a CAPTCHA
on an old project because of high levels of form SPAM.
This is my code so far:
***************
use strict;
use warnings;
use Authen::Captcha;
print "Content-type: text/html", "\n\n";
my $captcha = Authen::Captcha->new(
data_folder => '../public_html/captcha-data',
output_folder => '../public_html/captcha-output',
);
my $md5sum = $captcha->generate_code(5);
print "$md5sum.png";
*****************
I made both data and output folders world writeable for now.
What do I need to change to actually display the image?
Thanks in advance.
------------------------------
Date: Sun, 06 Jul 2008 12:57:43 -0400
From: Sherman Pendley <spamtrap@dot-app.org>
Subject: Re: Authen::Captcha - How do I make it display the image
Message-Id: <m1zlovrlvc.fsf@dot-app.org>
<news.freedom2surf.net> writes:
> Hi,
> My PERL is VERU rusty.
Quick tip: It's Perl, not PERL.
> Not used in years and have to now implement a
> CAPTCHA on an old project because of high levels of form SPAM.
>
> This is my code so far:
>
> ***************
> use strict;
> use warnings;
>
> use Authen::Captcha;
>
> print "Content-type: text/html", "\n\n";
>
> my $captcha = Authen::Captcha->new(
> data_folder => '../public_html/captcha-data',
> output_folder => '../public_html/captcha-output',
> );
>
> my $md5sum = $captcha->generate_code(5);
> print "$md5sum.png";
> *****************
> I made both data and output folders world writeable for now.
>
> What do I need to change to actually display the image?
Generate an HTML <img> element that references the "$md5sum.png" file
you just created. For instance:
print "<img src='/captcha-output/$md5sum.png'>";
You'll also need input elements that pass the md5sum and code that the
user entered:
print "<input type='hidden' name='md5sum' value='$md5sum'>";
print "<input name='code'>";
These will, of course, need to be in a form. In the app that handles
the form, you'll need to take these two inputs and call the
check_code() method to verify them.
sherm--
--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Sun, 6 Jul 2008 18:05:47 +0100
From: <news.freedom2surf.net>
Subject: Re: Authen::Captcha - How do I make it display the image
Message-Id: <GKOdnVKuqqPxZu3VnZ2dnUVZ8gOdnZ2d@pipex.net>
"Sherman Pendley" <spamtrap@dot-app.org> wrote in message
news:m1zlovrlvc.fsf@dot-app.org...
>
> Generate an HTML <img> element that references the "$md5sum.png" file
> you just created. For instance:
>
> print "<img src='/captcha-output/$md5sum.png'>";
>
> You'll also need input elements that pass the md5sum and code that the
> user entered:
>
> print "<input type='hidden' name='md5sum' value='$md5sum'>";
> print "<input name='code'>";
>
> These will, of course, need to be in a form. In the app that handles
> the form, you'll need to take these two inputs and call the
> check_code() method to verify them.
>
> sherm--
Great stuff. Worked a treat! Thank you.
------------------------------
Date: Sun, 6 Jul 2008 18:09:19 +0100
From: <news.freedom2surf.net>
Subject: Re: Authen::Captcha - How do I make it display the image
Message-Id: <ztydnZg3XNnfYe3VnZ2dneKdnZydnZ2d@pipex.net>
Ahhh, immediate new question.
Thinking back, perl scripts have to be in the cgi-bin folder. My form
originally was a HTML script wiht a form action that went to a CGI script
that generated output.
But now the first page needs to be in Perl to generate the CAPTCHA. This is
probably basic stuff but I'm so ingrained into PHP I'm not sure about how to
do this.
Do I need to locate my form in the cgi-bin?
Or does it not really matter?
Thanks again.
------------------------------
Date: Sun, 6 Jul 2008 17:20:31 +0000 (UTC)
From: steveo@panix.com (Steven M. O'Neill)
Subject: Re: Authen::Captcha - How do I make it display the image
Message-Id: <g4qusv$dae$1@reader1.panix.com>
<news.freedom2surf.net> wrote:
>
>Ahhh, immediate new question.
>Thinking back, perl scripts have to be in the cgi-bin folder. My form
>originally was a HTML script wiht a form action that went to a CGI script
>that generated output.
>
>But now the first page needs to be in Perl to generate the CAPTCHA. This is
>probably basic stuff but I'm so ingrained into PHP I'm not sure about how to
>do this.
>Do I need to locate my form in the cgi-bin?
>Or does it not really matter?
Depends on your web server and configuration.
--
Steven O'Neill steveo@panix.com
Brooklyn, NY http://www.panix.com/~steveo
------------------------------
Date: Sun, 06 Jul 2008 13:27:34 -0400
From: Sherman Pendley <spamtrap@dot-app.org>
Subject: Re: Authen::Captcha - How do I make it display the image
Message-Id: <m1prpqsz21.fsf@dot-app.org>
<news.freedom2surf.net> writes:
> Thinking back, perl scripts have to be in the cgi-bin folder.
On your server perhaps, but that's not a universal rule. Most servers
can be configured to treat any .pl file as a CGI. It's up to the
server admin, so ask him or her if you're unsure if your server is
configured that way or not.
> My form
> originally was a HTML script wiht a form action that went to a CGI
> script that generated output.
>
> But now the first page needs to be in Perl to generate the
> CAPTCHA. This is probably basic stuff but I'm so ingrained into PHP
> I'm not sure about how to do this.
What I would do is rename the first page to .shtml, and use a server-
side include to get the generated CAPTCHA form elements. Something
like this:
<!--#include virtual="/cgi-bin/generate_captcha.pl" -->
> Do I need to locate my form in the cgi-bin?
You can't put HTML files in /cgi-bin - *anything* in that directory
will be treated like a CGI, whether it really is or not.
sherm--
--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Sun, 06 Jul 2008 15:06:28 GMT
From: Marko Vihoma <marko@where.ever.invalid>
Subject: Bot::BasicBot's forkit() creating zombies
Message-Id: <Ub5ck.173$wh.130@read4.inet.fi>
Hello all.
First of all I'd like to tell you all that I'm a total Perl newbie, just
have read the excellent and fun "Learning Perl" and a bit of
"Programming Perl" in finnish...
I have created an IRC bot based on Bot::BasicBot, but when I use the
Bot::BasicBot's forkit() method to run for example a Yahoo! search in
the background (which I had created a subroutine for in my bot class),
it created a zombie perl process at each invocation (at least on OpenBSD
4.2 and OS X 10.4.11) and I have strict process limits for my bot's
user. For this reason I don't have forkit() in my bot
(http://personal.inet.fi/koti/marko.vihoma/src/LokkiBot.pl) anymore.
I believe forkit is using POE::Wheel::Run behind the curtains to do the
background job. Does anybody know how should I use forkit() to run a
subroutine without creating zombies? With standard fork() I should use
waitpid($pid) to wait for the processes completion, but I don't have
that option with Bot::BasicBot's forkit() as AFAIK it doesn't return the
PID of the forked process.
My code looked something like this before I stopped using forkit()
method in my code:
-- BEGIN code --
# Said is run every time somenone says something on a channel or in a
privmsg.
sub said {
my $self = shift;
my $message = shift;
my $reply = undef;
my $body = $message->{body};
my $channel = $message->{channel};
my $server = $self->{server};
my $who = $message->{who};
if ($message->{address}) {
if ($body =~ /^yahoo/) {
$body =~ s/^yahoo (.+)$/$1/;
$self->forkit(
run => \&yahoo, arguments => [$body], $who => $who,
channel => 'msg'
);
}
}
}
# &yahoo returns top five results from a Yahoo! search through Yahoo!
# search API.
sub yahoo {
shift;
my $query = shift;
my @content;
my $err = "En suanunna haettua :(\n";
print $err and return if (not $query);
my @res;
my $reply;
my $ua = LWP::UserAgent->new();
$ua->agent($agent);
my $response = $ua->get(
"http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=" .
"${yid}&query=${query}&results=${yahoo_results}"
);
if ($response->is_success) {
my $content = $response->content;
@content = split("\n", $content);
}
else {
print $err;
return;
}
my $n = 0;
for my $line (@content) {
print "Sori, mut hakulimitti on tullunna vastaan" .
":( Yritä myöhemmin uudestaan.\n" and return if
($line =~ /^<Error/);
if ($line =~ /<Result><Title>/) {
$line =~
s/^.+?<Title>(.+?)<\/Title>.+?<Url>(.+?)<\/Url>.*$/$1<$2>/;
$res[$n++] = $line;
}
}
if (@res) {
$reply = "1. $res[0]\n";
for my $n (1..4) {
$reply .= $n+1 . ". $res[$n]\n";
}
print $reply;
return;
}
else {
print $err;
return;
}
}
-- END code --
If anyone has any experience with Bot::BasicBot, I would be glad to hear
how to run forkit() without creating zombies and if this is a bug in
Bot::BasicBot.
"Parents were stuck and had to be killed" -- talk about zombies at
comp.unix.bsd.freebsd.misc ;)
--
"If I can't smoke and swear I'm fucked."
marko [dot] vihoma [at] pp1 [dot] inet [dot] fi
------------------------------
Date: 6 Jul 2008 10:34:31 GMT
From: greymaus <greymausg@mail.com>
Subject: Re: Elisp Lesson on file processing (make downloadable copy of a website)
Message-Id: <slrng7180r.7io.greymausg@maus.org>
On 2008-07-06, xahlee@gmail.com <xahlee@gmail.com> wrote:
> In this week i wrote a emacs program and tutorial that does archiving
> a website for offline reading.
> (See http://xahlee.org/emacs/make_download_copy.html )
>
wget --mirror <whatever> and a host of other utilities, instead of `cp',
which was ever intended for local use.
--
Greymaus
.
.
...
------------------------------
Date: Sun, 06 Jul 2008 07:10:46 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: Generating fancy/pretty documents
Message-Id: <f08174l3upvbhtlee0f4jtm18cjklr7a0i@library.airnews.net>
Joost Diepenmaat <joost@zeekat.nl> wrote:
} Bernie Cosell <bernie@fantasyfarm.com> writes:
}
} > procedure is a bit klunky and fragile. Is there some way to produce
} > "pretty" PDF or ODF document directly? I see there's a suite of modules
} > PDF::API2 -- it looks pretty complicated....anyone used that? PDF::Create
} > also seems complicated.
}
} PDF::API2 is complicated because PDF is complicated. It's not *that*
} complicated, though. It depends on what your source and output data
} are like.
I realize: that the PDF modules aren't *typesetting* modules but *PDF*
modules and you need to understand PDF and must use the modules to make
your doc. I've [hand]coded PostScript back in a bygone age and the PDF
calls seem pretty similar -- I guess I vaguely remember [again, from a
bygone age..:o)] that PDF was derived from EPS.
} If your data is mostly text and some illustrations & tables, you may
} want to use latex instead. Latex at least makes if almost trivial to
} generate a nice looking pdf/postscript document from straightforward
} source data (sort of like POD, only much, much more flexible and
} extensible) and it has superb support for references, indexes,
} table-of-contents etc,
LaTex would be a good alternative. I've used LaTex over the years (I wrote
a thesis using it back when you had to carve the LaTeX commands onto stone
tablets) and the problem [for me] was usually twofold: first was getting it
to run. I was always impressed and dismayed at the HUGE amount of crap
that came along with LaTeX [not to mention using its private font world
that I never got a good handle on]. Second was, if I'm remembering right,
that it was hard to get useable output from it [I think it generated PS and
then I needed to install GhostScript, another behemoth, to get that
converted to something more useful].
BUT: it is now a LOT of years later, all of that has matured I'm sure,
isn't as much of a mess as it used to be, and it isn't a "Perl" question at
all -- So thanks for the reminder. I'll go and check out LaTeX distros for
windows, etc [and see if I can find my LaTeX book -- it's on my shelf here
*somewhere* :o)].
} > Am I just being naive about this? As I say, in the past I've used troff
} > and HTML as an intermediate "layout" format and things like fonts, titles,
} > indenting, tables, simple drawing (e.g., putting a box around some text)
} > etc were all relatively easy. Is that kind of thing easy/reasonable to do
} > with one of the "direct to PDF" packages? ...
}
} My experience with HTML -> PDF translators is that it's too easy to
} generate some HTML that won't get translated correctly, and you can
} usually forget about generating references to sections with page
} numbers and things like that.
Just so. I can only say two things to this [on the mark] comment: first is
that for some of what I want to do that's likely to be OK. Note that since
I'll be generating the HTML *with*Perl*, I have a lot of control over not
generating things that HTMLDOC won't translate properly (NB: I *have* used
this approach in the past and it worked quite well.) Second, it is easy
to "proof" the output (indeed, in the past when I've gone this route, I
wrote my Perl stuff as CGI pgms, rather than standalone pgms, and it was
remarkably simple to get everything debugged with just a few mouse-clicks
in the browser). But you're right: even when everything was perfect, I
needed to [and did] play around with the HTML I generated to produce
something that HTMLDOC did the "right thing" with. And the best I can say
is that the PDFs were "OK" [basically, looking like unadorned text web
pages].
So thanks for the pointer: time to go re-learn LaTeX and see how it goes...
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Sun, 06 Jul 2008 07:10:48 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: Generating fancy/pretty documents
Message-Id: <do81745q1n7pivqkoah3ls8vmdtd1b5r0i@library.airnews.net>
Eric Pozharski <whynot@pozharski.name> wrote:
} Bernie Cosell <bernie@fantasyfarm.com> wrote:
} > Suggestions on how to produce "nice" text documents from Perl? Plain
} > text is easy, of course, but I need to be able to do fancier/formatted
} > stuff.
} I would slightly disagree with Joost Diepenmaat -- any interface is no
} more complicated than underlying structure. If you are familiar with
} a structure then no braindamage in an interface would stop you. If a
} structure is unknown, you would fail sooner or later. Even I would
} stress that as much simple an interface is as harder and sooner you will
} fail.
Perhaps, but consider LaTeX: you can go an awful long way with it *NEVER*
having to understand the awfulness of TeX.
} > Am I just being naive about this? As I say, in the past I've used
} > troff and HTML as an intermediate "layout" format and things like
} > fonts, titles, indenting, tables, simple drawing (e.g., putting a box
} > around some text) etc were all relatively easy. Is that kind of thing
} > easy/reasonable to do with one of the "direct to PDF" packages? In
} > looking at the organization and methods for the PDF modules, using
} > HTMLDOC (<http://www.htmldoc.org/>) starts looking more and more
} > attractive...
}
} Wait a moment. You have to make clear for yourself, either you want
} convert HTML to PDF or you want to have nice PDF. Those are slightly
} different beasts.
Yes, but the difference is subtle: what I want is "nice PDF", but I have
*control* over the HTML. *general* HTML->PDF conversion is very difficult
and surely does produce marginal PDF, but if you are generating the HTML
from Perl *specifically* to keep HTMLDOC happy [that is, using HTML as an
intermediate language, much like troff or LaTeX, rather than as a markup
language in its own right] then I think you have a better shot at helping
an app like HTMLDOC do a decent job.
} ... However it was no different from rendered HTML.
That's the thing, for sure. Even if you tune and tweak the HTML to
accommodate the converter, you're going to be left with a document that
looks like a printed web page. Alas.. :(
} =item LaTeX
}
} Hmm,.. Let's be honest, LaTeX isn't my favorite tool for making
} typesetting. It's my only tool for that.
Ah. Interesting point.
} ...I would disagree with Joost
} Diepenmaat again -- LaTeX isn't easy, it's fscking braindamage,
If you think LaTeX is bad, then try getting a copy of the TexBook and see
what the underlying machinery it's using is like! :o). Basically, LaTeX
and TeX are like the distinction between setting a document -man or -ms
macros versus raw troff.
}.... First of all,
} forget about B<PerlTeX>; ...
}
} I'm quite successful in making LaTeX-generators. Perl does all
} calculations, then passes to LaTeX some source and points to F<.sty>
} (style files are alike (not exactly) F<.pm>).
Interesting -- as I mentioned, I've _written_ docs using LaTeX but it
hadn't occurred to me to try using LaTeX as an intermediate language for
producing docs from a program. Now that I think about it, I'd guess it
would be fairly easy -- I don't remember a lot of LaTeX [gotta do a bunch
of reviewing :o)] but for *simple* docs it is mostly running text with
occasional "dot commands" to indicate headers, footers, etc.
} If you are still not afraid (and you are?), (looking at yours headers)
} consider MikTeX -- if my guess is right it's something alike ActivePerl
} but from LaTeX world.
Ah, cool. Not sure what my headers betray [I guess other than I'd be
looking for a Windows LaTeX distro] but I'll go and poke around. As I
mentioned in the reply to Joost, I have installed TeX/itsfunnyfonts/LaTeX
on Unix systems over the years and it was an awful mess [and a quite large
pile of it], and maybe the worst part was its idiosyncratic font system
that wouldn't play with anything else's fonts [and so required lots more
screwing around to properly render it... hammering on dvi2ps..UGH! :o)].
But it has *GOT* to be easier these days [in fact, I'd bet that some of
those LaTeX distros do a fairly good job of hiding the TeX underbelly :o)]
} =item openoffice.org
}
} (not tested, any feedback is appreciated). There're at least 2
} distributions about OO.org on CPAN. B<OpenOffice::OOBuilder> seems not
} ready -- it declares that it works only with spreadsheets.
} B<OpenOffice::OODoc> seems to be much better.
Wow.. An interesting approach. Just checking the OODoc and OODoc::Intro
PODs has it looking like an interesting alternative to LaTex. Time for
more reading...tnx!
/B\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Sun, 06 Jul 2008 18:44:14 +0100
From: Henry Law <news@lawshouse.org>
Subject: How best to take a copy of a variable and edit it with s///?
Message-Id: <1215366322.305.0@proxy01.news.clara.net>
I frequently have the need to take copy of a variable and edit it (for
printing or some such). I code it like this:
my $ugly_variable = some_function(); # Or read from a file maybe
my $nice_variable = $ugly_variable; # Take a copy ...
$nice_variable =~ s/nasty/nice/g; # ... and then make it look nice
Of course that works very well. But it doesn't look perlish, and it
takes two statements. I'm looking for some one-shot construction, along
the lines of this
my $nice_variable = ($ugly_variable =~ s/nasty/nice/g);
... but if course that doesn't do what I want: $nice_variable ends up as
the number of substitutions done by s///. But is there a neater, more
succinct (but not hard to maintain) way of doing what I want? I'm sure
I saw something that looked like my wrong example above, but it must
have been different in some subtle way.
Of course I Googled for an answer to this; it's not that I found
nothing, more that I couldn't structure a query that returned anything
useful.
--
Henry Law Manchester, England
------------------------------
Date: Sun, 06 Jul 2008 19:58:29 +0200
From: Dave B <daveb@addr.invalid>
Subject: Re: How best to take a copy of a variable and edit it with s///?
Message-Id: <g4r10a$tf2$1@registered.motzarella.org>
Henry Law wrote:
> I frequently have the need to take copy of a variable and edit it (for
> printing or some such). I code it like this:
>
> my $ugly_variable = some_function(); # Or read from a file maybe
> my $nice_variable = $ugly_variable; # Take a copy ...
> $nice_variable =~ s/nasty/nice/g; # ... and then make it look nice
>
> Of course that works very well. But it doesn't look perlish, and it
> takes two statements. I'm looking for some one-shot construction, along
> the lines of this
>
> my $nice_variable = ($ugly_variable =~ s/nasty/nice/g);
>
> ... but if course that doesn't do what I want: $nice_variable ends up as
> the number of substitutions done by s///. But is there a neater, more
> succinct (but not hard to maintain) way of doing what I want? I'm sure
> I saw something that looked like my wrong example above, but it must
> have been different in some subtle way.
>
> Of course I Googled for an answer to this; it's not that I found
> nothing, more that I couldn't structure a query that returned anything
> useful.
Since assignment returns a valid lvalue, you have to do this:
($nice_variable=$ugly_variable) =~ s/nasty/nice/g
--
D.
------------------------------
Date: Sun, 6 Jul 2008 13:53:31 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: How best to take a copy of a variable and edit it with s///?
Message-Id: <slrng7255b.23k.tadmc@tadmc30.sbcglobal.net>
Henry Law <news@lawshouse.org> wrote:
> I frequently have the need to take copy of a variable and edit it (for
> printing or some such). I code it like this:
>
> my $ugly_variable = some_function(); # Or read from a file maybe
> my $nice_variable = $ugly_variable; # Take a copy ...
> $nice_variable =~ s/nasty/nice/g; # ... and then make it look nice
>
> Of course that works very well. But it doesn't look perlish, and it
> takes two statements. I'm looking for some one-shot construction, along
> the lines of this
>
> my $nice_variable = ($ugly_variable =~ s/nasty/nice/g);
You have the parenthesis in the wrong place:
(my $nice_variable = $ugly_variable) =~ s/nasty/nice/g;
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Sun, 06 Jul 2008 19:01:58 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: How best to take a copy of a variable and edit it with s///?
Message-Id: <1215367317.30853.0@proxy02.news.clara.net>
Dave B wrote:
> Henry Law wrote:
>
>> I frequently have the need to take copy of a variable and edit it (for
>> printing or some such). I code it like this:
>>
>> my $ugly_variable = some_function(); # Or read from a file maybe
>> my $nice_variable = $ugly_variable; # Take a copy ...
>> $nice_variable =~ s/nasty/nice/g; # ... and then make it look nice
> Since assignment returns a valid lvalue, you have to do this:
> ($nice_variable=$ugly_variable) =~ s/nasty/nice/g
>
Of course! It's so obvious now. Thank you.
--
Henry Law Manchester, England
------------------------------
Date: Sun, 6 Jul 2008 16:17:56 +0100
From: "John" <john1949@yahoo.com>
Subject: Re: Net::SMTP and Postfix mai considered spam by googlemail
Message-Id: <g4qnn0$g13$1@news.albasani.net>
"Bill H" <bill@ts1000.us> wrote in message
news:eaaf90f1-8789-40aa-b4e9-392b1f3b96bc@25g2000hsx.googlegroups.com...
On Jul 5, 3:44 pm, "John" <john1...@yahoo.com> wrote:
> "-linux_lad" <j...@linuxNOSPAMlad.org> wrote in message
>
> news:W8adnc4FFsuNWfLVnZ2dnUVZ_szinZ2d@giganews.com...
>
>
>
>
>
> > John wrote:
> >> Hi
>
> >> I am looking at Net:SMTP and keyed in the following code as a test:
>
> >> use Net::SMTP;
> >> my $smtp=Net::SMTP->new
> >> ("www.example.com",Hello=>'www.example.com',TimeOut=>60,Debug=>1);
> >> $smtp->mail("john\@example.com");
> >> $smtp->recipient("one.two\@googlemail.com");
> >> $smtp->auth('joe','soap');
> >> $smtp->data;
> >> $smtp->datasend("From: john\@example.com\n");
> >> $smtp->datasend("To: one.two\@googlemail.com\n");
>
> > Assuming the code you posted is what you actually ran:
>
> > One possible explanation for the issue you're having is that you are
> > forging the domain name "example.com". Spammers usually forge the return
> > address to make it harder to catch them. Practically everyone these days
> > treats email with bogus return addresses as spam or scores it
> > accordingly.
> > Try putting your real domain in the return address. When the SMTP server
> > does a reverse lookup to validate that the email came from the domain
> > it's
> > purported to be from, it won't be scored so highly.
>
> > --
> > -linux_lad
>
> Hi
> I replaced the true adress with example.com
> My guess the problem is in the header but I cannot see it.
> Regards
> John- Hide quoted text -
>
> - Show quoted text -
I have had this issue before with AOL (and occasionally Yahoo) calling
perl generated (or more accurately, sendmail generated) mail spam. If
your site is on a shared server, and the domain name you are using is
not the domain name of the server, then your sending address and the
address it is from will not match and be considered spam. Or, if the
domain name for the server does not have a proper reverse lookup then
perl gerenated mail can be considered spam.
Using your example.com domain name, if the shared server's domain name
is admin.example.com and the website that is running the perl code is
www.somename.com then your website will not match up with the server
domain name.
If you running this on your own machine and sending out through your
ISP I think this could apply also, since the IP it is coming from does
not match the domain name IP in the email.
Bill H
PS - I could be totally wrong here - this has just been my experience.
Hi
Now this is interesting. We have our own server (co-located in a data
centre).
I have done a reverse DNS look up on our IP address. I thought I would get
123.456.789.012 giving www.example.com but I get
123-456-789-012.datacentre.com as the hostname.
So the hostname I keyed into the box when I put on Debian is not the true
hostname?
To confuse matters, we have four virtual sites on the box.
Any ideas?
Regards
John
------------------------------
Date: Sun, 6 Jul 2008 06:17:51 -0700 (PDT)
From: jerrykrinock@gmail.com
Subject: Want regex s/// to replace only nth occurrence
Message-Id: <d86a4a58-052b-4e22-889d-adcc4317effc@34g2000hsh.googlegroups.com>
my $s = "The sneaky cat sneaked sneakily." ;
I would like a simple s/// statement which would replace only the $nth
occurrence of "sneak". ($n is a variable). Can't find the answer.
Is this possible?
Thanks,
Jerry Krinock
------------------------------
Date: Sun, 06 Jul 2008 15:46:37 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Want regex s/// to replace only nth occurrence
Message-Id: <6dc0pvF1o9q1U1@mid.individual.net>
jerrykrinock@gmail.com wrote:
> my $s = "The sneaky cat sneaked sneakily." ;
>
> I would like a simple s/// statement which would replace only the $nth
> occurrence of "sneak". ($n is a variable).
my $repl = 'xyz';
my $n = 2;
my $i;
$s =~ s/(sneak)/ ++$i == $n ? $repl : $1 /eg;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 06 Jul 2008 15:58:50 +0200
From: Dave B <daveb@addr.invalid>
Subject: Re: Want regex s/// to replace only nth occurrence
Message-Id: <g4qiur$on2$1@registered.motzarella.org>
jerrykrinock@gmail.com wrote:
> my $s = "The sneaky cat sneaked sneakily." ;
>
> I would like a simple s/// statement which would replace only the $nth
> occurrence of "sneak". ($n is a variable). Can't find the answer.
> Is this possible?
With sed it's trivial. With Perl, I'd do this:
my $x=0;my $n=3;
while($s=~/sneak/g) {
if (++$x==$n) {
$s=~s/sneak\G/replacement/;
last;
}
}
print "$s\n";
Outputs:
The sneaky cat sneaked replacementily.
I'm a Perl beginner, so there are more idiomatic ways of expressing that, I
guess.
--
D.
------------------------------
Date: Sun, 06 Jul 2008 17:28:48 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Want regex s/// to replace only nth occurrence
Message-Id: <g4qoef$9k0$1@mlucom4.urz.uni-halle.de>
jerrykrinock@gmail.com wrote:
> my $s = "The sneaky cat sneaked sneakily." ;
>
> I would like a simple s/// statement which would replace only the $nth
> occurrence of "sneak". ($n is a variable). Can't find the answer.
> Is this possible?
It's possible if you use a code assertion (??{...}) to count down
and the atomic group (>...) to prevent backtracking:
my $s = "The sneaky cat sneaked sneakily." ;
our $nth = 3;
$s =~ s/((?>sneak(??{--$nth?'(?!)':''})))/angr/;
print $s;
Regards
M.
------------------------------
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 V11 Issue 1695
***************************************