[21735] in Perl-Users-Digest
Perl-Users Digest, Issue: 3939 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 9 11:07:49 2002
Date: Wed, 9 Oct 2002 08:05:09 -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 Wed, 9 Oct 2002 Volume: 10 Number: 3939
Today's topics:
Re: Freeware/shareware perl IDE <REMOVEsdnCAPS@comcast.net>
Re: Freeware/shareware perl IDE <N.Hirani@hgmp.mrc.ac.uk>
Re: Help me understand *foo = \... <david.bouman@xo.nl>
Re: I only need one row from mysql news@roaima.freeserve.co.uk
Re: I only need one row from mysql <bernie@nospam.bernieberg.com>
Re: ithreads, perl 5.8 and shared objects <derek@wedgetail.com>
Re: ithreads, perl 5.8 and shared objects <derek@wedgetail.com>
newbie with datatype prob (safari)
Re: newbie with datatype prob (Helgi Briem)
Re: newbie with datatype prob (Tad McClellan)
NEWBIE: Accessing FORM input with PERLSCRIPT <tennant2NOSPAM@theforge.demon.co.uk>
NEWBIE: Perl into either Access or MS-SQL <cschoute@liacs.nl>
Re: NEWBIE: Perl into either Access or MS-SQL <cpryce@pryce.net>
Re: Not so simple RE problem... <dd@4pro.net>
Re: Not so simple RE problem... (Helgi Briem)
Re: Not so simple RE problem... <dd@4pro.net>
Re: Not so simple RE problem... (Anno Siegel)
Please help me with my Redirection script. (drc15)
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tad McClellan)
Re: sendmail and perl <saketrungta@hotmail.com>
Re: udp (Heinrich Mislik)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 09 Oct 2002 05:53:14 CDT
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Freeware/shareware perl IDE
Message-Id: <Xns92A245F35291Esdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
[posted and mailed]
Naran Hirani <N.Hirani@hgmp.mrc.ac.uk> wrote in news:3DA33C71.FE650EC3
@hgmp.mrc.ac.uk:
> Hi,
>
> I'm looking for a nice freeware/shareware perl IDE that runs on a Sun
> Solaris platform.
> Does such a thing exist?
> if so does any body have any recommendations, please.
I use emacs for an editor and ptkdb for a debugger. I find the combination
to be a great one, and I don't know if I'd be as happy with a packaged
tool.
Do a web search on ptkdb to find where to download it.
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPaQKXmPeouIeTNHoEQLVgQCgnb1uitdNRavdMvIGTXVY/Crp8uoAoJ+c
WHPbU7/aOlCH+BmQWiKdWeDS
=v7p7
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 09 Oct 2002 12:04:02 +0100
From: Naran Hirani <N.Hirani@hgmp.mrc.ac.uk>
Subject: Re: Freeware/shareware perl IDE
Message-Id: <3DA40D22.2994F91C@hgmp.mrc.ac.uk>
Newbie wrote:.....
>
> I used to be crazy about IDEs too, but I find x/emacs just as good.
I agree I use X/emacs my self. But this is more to help newbies to perl
than myself.
N.
------------------------------
Date: Wed, 09 Oct 2002 15:08:49 +0200
From: David Bouman <david.bouman@xo.nl>
Subject: Re: Help me understand *foo = \...
Message-Id: <3DA42A61.3CFD538F@xo.nl>
Benjamin Goldberg wrote:
> When you assign an arrayref to a typeglob, it replaces the appropriate
> slot of the typeglob with that arrayref. In other words, suppose you
> did:
> my $x = \@xyz; my $y = [1, 2, 3];
> print $x, $y, \@xyz, "\n";
> *xyz = $x;
> print $x, $y, \@xyz, "\n";
> You'll get something like:
> ARRAY(0xdeadbeef)ARRAY(0x12345678)ARRAY(0xdeadbeef)
> ARRAY(0xdeadbeef)ARRAY(0x12345678)ARRAY(0x12345678)
Euh, if you expect those results shouldn't you have done:
*xyz = $y;
instead ?
--
David.
------------------------------
Date: Wed, 9 Oct 2002 10:41:26 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: I only need one row from mysql
Message-Id: <6kt0oa.br.ln@moldev.cmagroup.co.uk>
I wrote:
: Generally, I'd recommend avoiding "*" in a query.
Jeff Zucker <jeff@vpservices.com> wrote:
> I think saying it should be avoided in general is going too far.
> For example, if I simply want to dump out the resultset to an HTML
> table, I want it to reflect the current schema, not some version of
> the schema that is hard-coded into the query itself.
There is always a counter example to the general case. I agree there are
times when "*" is useful - almost entirely when you're either building
dynamic queries and processing the corresponding dynamic result set or
dumping debug style information - but I'd argue not in most cases.
: If you know what you want, ask for it explicitly. If you don't know what
: you want then how will your program cope when the schema gets changed?
> By using fetchrow_hashref() and friends to refer to the columns by
> name rather than by order. If the schema changes to rename the columns,
> this would break, but so would a hard-coded query.
My point precisely. However, if you use "*" your program will also fail
when someone inserts new columns or removes unwanted ones - and in this
case your program may not even notice and you'll get subtle errors as a
consequence. By avoiding the use of "*", you'll either get exactly what
you want, or the program will fail (gracefully).
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: Wed, 09 Oct 2002 09:14:12 -0500
From: bernie <bernie@nospam.bernieberg.com>
To: bernie <bernie@nospam.bernieberg.com>
Subject: Re: I only need one row from mysql
Message-Id: <3DA439B4.3010303@nospam.bernieberg.com>
Thanks everyone. I listened to you sugestions and got it working!
Thanks for all of the other pointers also.
--
bernie
www.bernieberg.com
------------------------------
Date: Mon, 07 Oct 2002 09:14:06 +1000
From: Derek Thomson <derek@wedgetail.com>
Subject: Re: ithreads, perl 5.8 and shared objects
Message-Id: <3da0c3df$0$23172$afc38c87@news.optusnet.com.au>
Bart Schuller wrote:
> In article <3d9f83c3$0$23169$afc38c87@news.optusnet.com.au>,
> Derek Thomson <derek@wedgetail.com> wrote:
>
>>Bart Schuller wrote:
>>
>>>restriction. Have a look at the Thread-related modules in
>>>http://search.cpan.org/author/ELIZABETH/
>>
>>I want ithreads, 'cause I really like the design, like I said. And this
>
>
> Those modules are explicitly written for ithreads. The naming convention
> that got adopted was such that only the main Thread module is now called
> "threads". Add-on modules are still in the Thread:: namespace.
> threads::shared is the exception to this rule.
Ah, I didn't realize that.
>
> Looking over those modules, I'm actually not sure if any of them solves
> the bless() problem, but they are worth checking out regardless.
>
No, I couldn't find anything either.
>
>>would break my desire to allow my ORB to work with no other modules,
>>aside from those that come with the Perl distro.
>
>
> I'll never understand such desires. For people with those kinds of
> problems, your module will be just as third-party as all the other
> useful modules that you deny yourself the use of.
Unfortunately, I have to live in the real world :( Who's going to
configure, build, install, and support all these third party modules?
Can I get the project admins to agree to do it? Assuming the tools are
available to do all that in the *first* place. There's a huge
difference, politically and technically, between installing one module
that is totally written in Perl, and works out-of-the-box, and having to
build anything from C.
Think about your average Windows user, for example. Will they even
*have* a C compiler?
And, like I said, I just don't like the Exceptions module!
>
>
>>>I assume you've looked at my (quite dead by now, alas) COPE?
>>
>>Yes. I didn't like some things about it, like the reliance on the
>>Exceptions module. I needed a "pure" Perl solution. Has it been tested
>>with other ORBs, BTW?
>
>
> I answered the Exception bit over in the other thread. I was as someone
> else remarked because nothing else existed at the time, including
> die($object).
Ah, yes, I thought it was rather cool that that worked. I had the
distinct advantage of starting later ;)
>
>
>>Why is it dead, BTW?
>
>
> Well, you could call it "resting". I haven't played with it in years. I
> wrote it but never used it. Luckily, others did use it and kept it alive
> for some time. You'd have to ask on the list to hear whether anyone
> still uses and/or develops it.
>
I will!
--
Derek Thomson.
------------------------------
Date: Tue, 08 Oct 2002 02:37:45 GMT
From: Derek Thomson <derek@wedgetail.com>
Subject: Re: ithreads, perl 5.8 and shared objects
Message-Id: <3DA244F8.80908@wedgetail.com>
The following message is a courtesy copy of an article
that has been posted to comp.lang.perl.moderated,comp.lang.perl.misc as
well.
Uri Guttman wrote:
>
>>>>>>"DT" == Derek Thomson <derek@wedgetail.com> writes:
>>>>>
>
> DT> This is a very important question, as if we cannot share objects
> DT> between threads in Perl, then threading in Perl is, for everything
> DT> except toy examples, broken and I will have to be advising people
> DT> considering Perl for multithreaded applications that Perl is still
> DT> *not* thread capable.
>
> i irc'ed with the threads guru and i think i have figured out your
> sharing problem.
Great!!
>
> DT> Can't call method "id" on unblessed reference at s.pl line 23.
>
> DT> our %Assoc : shared;
>
> that is shared but its elements may not be shared. you have to explicitly
> share the hash elements if they are complex items like objects.
I thought sharing traversed down one level of reference? Maybe I'm
misreading the doco.
>
> DT> %Assoc=();
>
> DT> MAIN:
> DT> {
> DT> for (my $i=0;$i<10;$i++) {
> DT> my $f=new Foo($i);
> DT> share($f);
>
> this is the problem. you are sharing the reference and not the
> referent. the referent is the actual object (the hash). $f is only a
> reference to it. you bless referents through a reference, the
> reference itself is not blessed.
Like I said, I thought sharing propagated down one level.
>
> DT> sub new {
> DT> my $proto=shift;
> DT> my $id=shift;
>
> DT> my $class=ref($proto) || $proto;
>
> DT> my $self = {
> DT> ID => $id,
> DT> };
>
> DT> bless($self,$class);
>
> try this: <untested>
>
> my %self = (
> ID => $id
> ) ;
>
> share %self ;
>
> bless(\$self,$class);
>
> return \$self;
Do you mean:
share %self;
bless(\%self,$class);
return \%self;
?
That doesn't work. I get:
Can't call method "id" on unblessed reference at threads line XX.
This also breaks the "bless first, then share" rule. Ah, well, thanks
for trying! Can the threads guru be brought into this discussion? It
seems like we could end this very quickly!
>
> also he mentioned that the DESTROY method will be called in EACH thread
> when this object goes out of scope. so you have to be careful with
> managing shared objects. one idea i proposed and he seconded was to keep
> a hash of al shared objects (you are doing that) so you can globally
> manage the object's scope and control when you want to destroy it.
This sounds bad, but I'll look into your solution if I ever get shared
objects working at all :(
--
D
------------------------------
Date: 9 Oct 2002 06:09:54 -0700
From: safa5952@mail.usyd.edu.au (safari)
Subject: newbie with datatype prob
Message-Id: <1a518d50.0210090509.79dcc6d9@posting.google.com>
Hello,
I'm attempting my first perl code and thought everything was going
sweetly until this error popped up, when running my script on the
command line.
Use of uninitialized value in numeric ge (>=) at ./sending.pl line 17.
Content-type: text/html
Use of uninitialized value in concatenation (.) or string at
./sending.pl line 201.
(line 17 is the if(($CustomerID>= 1000002)...
line 201 is print SENDMAIL <<"EOF";)
(The browser gives an ugly-looking "internal error" message and the
apache log gives:
[Wed Oct 9 22:31:47 2002] [error] [client 127.0.0.1] Premature end of
script headers: /home/safari/public_html/sending.pl
The script is pretty simple... getting variables(8 number integer,
starting with a zero as the first number) from a form, storing them as
variables, then comparing against two other numbers. (Hoping i'm
making sense :)
and the code:
*************************************************
#!/usr/bin/perl -w
use CGI qw/:standard/;
my $CustomerID;
$CustomerID = param('CustomerID');
#checks against CustomerID value and sends email to relevant address
if (($CustomerID >= 1000002) && ($CustomerID <= 1950000)){
$form_recipient1 = "email_addie_1\@wherever.org.au"
}
elsif (($CustomerID >= 2901671) && ($CustomerID <= 2930000)){
$form_recipient1 = "email_addie_2\@wherever.org.au"
}
*******************************
then further down, I'm doing the standard SENDMAIL stuff. That seems
to work okay. I think it's just complaining about the testing
$CustomerID against the 7-digit number. It seemed to work alright
before, with me omitting the leading 0. An example of $CustomerID are
01234567 and 04682498
So grateful for any help.
kind regards,
Safari
------------------------------
Date: Wed, 09 Oct 2002 13:37:21 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: newbie with datatype prob
Message-Id: <3da43043.37890343@news.cis.dfn.de>
On 9 Oct 2002 06:09:54 -0700, safa5952@mail.usyd.edu.au
(safari) wrote:
>I'm attempting my first perl code and thought everything was going
>sweetly until this error popped up, when running my script on the
>command line.
Good, idea, test on command line first. Life would
indeed be sweet if more CGI script kiddies did that.
>Use of uninitialized value in numeric ge (>=) at ./sending.pl line 17.
>Content-type: text/html
>
>Use of uninitialized value in concatenation (.) or string at
>./sending.pl line 201.
<SNIP>
Why do this in 2 lines?
>my $CustomerID;
>$CustomerID = param('CustomerID');
my $CustomerID = param('CustomerID');
Add a line here that checks for $CustomerID
so that you don't continue with it empty:
die "No customer id\n"; if not $CustomerID;
[untested] but should solve your uninitalised problem.
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Wed, 9 Oct 2002 09:07:57 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie with datatype prob
Message-Id: <slrnaq8e1t.2ee.tadmc@magna.augustmail.com>
safari <safa5952@mail.usyd.edu.au> wrote:
> this error popped up, when running my script on the
> command line.
Testing CGI programs on the command line is good, good, good. :-)
> Use of uninitialized value in numeric ge (>=) at ./sending.pl line 17.
> Content-type: text/html
>
> Use of uninitialized value in concatenation (.) or string at
> ./sending.pl line 201.
All of the messages that perl might issue are documented in
the perldiag.pod std doc. You should look up any messages
that you are getting in perldiag.
> (line 17 is the if(($CustomerID>= 1000002)...
When perl says "uninitialized value", think "I used undef when
I probably didn't mean to".
$CustomerID got a value of undef somehow or another.
> line 201 is print SENDMAIL <<"EOF";)
One of the variables interpolated into your here-doc (probably
$CustomerID again) got a value of undef somehow.
> #!/usr/bin/perl -w
Warnings are good too.
Add "use strict;" for even more goodness.
> $CustomerID = param('CustomerID');
Are you certain that you have a form parameter with that exact
name, and that it was given a value?
Did you type in (or redirect) a value for it when testing
at the command line?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 09 Oct 2002 11:18:50 +0100
From: Tennant <tennant2NOSPAM@theforge.demon.co.uk>
To: comp.lang.perl.misc
Subject: NEWBIE: Accessing FORM input with PERLSCRIPT
Message-Id: <nju7qug64oh0g7nhr3j2uphegpqqsn1faf@4ax.com>
Sorry if this is a stupid question, but having trawled through all the
FAQs I can find I don't seem to be able to find the answer to what I
would have thought is a simple question.
I am using Client-Side PERLSCRIPT (this is a demo which needs to run
on a standalone laptop), which has a form which collects various
information from the user and then outputs this to a text file for
future processing. However I cannot find out how I access the Forms
input field from my script?
I've reproduced an edited version of my HTML page below (Form and
output have been simplified for ease of understanding).
<HTML>
<BODY>
<H1>Customer Specific Brochure<br>
Demonstration</H1>
<form method="POST" name="MyForm">
<p>
Name: <input type="text" name="name" size="40"
maxlength="40"><BR>
Company: <input type="text" name="company" size="40"
maxlength="40"><BR>
<input type="button" name="Create" value="Create File">
<script language="PerlScript">
sub Create_onClick
{
$window->document->write("Building your file...please
wait<br><br>");
open(COVERSCRIPT, ">" . "C:/temp/Process.txt");
print COVERSCRIPT "# Options\n";
print COVERSCRIPT;
print COVERSCRIPT "Begin_Options\n";
print COVERSCRIPT;
print COVERSCRIPT "Version ( 2
)\n";
print COVERSCRIPT "TopMargin (
12 )\n";
print COVERSCRIPT "BottomMargin (
12 )\n";
print COVERSCRIPT "LeftMargin ( 8
)\n";
print COVERSCRIPT "RightMargin ( 8
)\n";
print COVERSCRIPT;
print COVERSCRIPT "End_Options\n";
print COVERSCRIPT;
print COVERSCRIPT;
print COVERSCRIPT "# -- Stamp Item --\n";
print COVERSCRIPT;
print COVERSCRIPT "Begin_Message\n";
print COVERSCRIPT;
print COVERSCRIPT "Name
(CoverStamp)\n";
print COVERSCRIPT "Text
(Prepared for%n";
# Next line needs to pass the "name" field from the form;
print COVERSCRIPT "Name here";
print COVERSCRIPT "%n";
# Next line needs to pass the "company" field from the form;
print COVERSCRIPT "Company here";
print COVERSCRIPT "\n\n";
print COVERSCRIPT;
print COVERSCRIPT "# End of Stamp File\n";
print COVERSCRIPT;
close (COVERSCRIPT);
$window->document->write("Script file completed...please see
C:/temp/Process.txt<BR><BR>");
}
sub Create_onclick
{
Create_onClick
}
</script>
</p>
</form>
<HR>
</body>
</HTML>
Many thanks for any help you can give.
Tennant
------------------------------
Date: Wed, 9 Oct 2002 13:59:57 +0200
From: Christian C Schouten <cschoute@liacs.nl>
Subject: NEWBIE: Perl into either Access or MS-SQL
Message-Id: <Pine.LNX.4.05.10210091355010.16032-100000@krypton.wi.leidenuniv.nl>
Hi,
I need to be writing a small perl script that will be a survey on our
intranet, a small web form, really.
The data should, if possible, end up in a database that can be either MS
Access or MS SQL Server. As a last resort, I could set up Oracle in my own
home dir, but rather do it with the public Access or SQL Server.
Now, how do I go about this. Does perl enter into Access at all, or is
this a no go? What should I use in the perl script?
Who can help this poor little newbie?
BR,
Chris
--
#define me "Christian C. Schouten <cschoute@liacs.nl>"
------------------------------
Date: Wed, 09 Oct 2002 08:16:36 -0500
From: cp <cpryce@pryce.net>
Subject: Re: NEWBIE: Perl into either Access or MS-SQL
Message-Id: <B9C99664.FE6B%cpryce@pryce.net>
in article
Pine.LNX.4.05.10210091355010.16032-100000@krypton.wi.leidenuniv.nl,
Christian C Schouten at cschoute@liacs.nl wrote on 10/9/02 6:59 AM:
> I need to be writing a small perl script that will be a survey on our
> intranet, a small web form, really.
> The data should, if possible, end up in a database that can be either MS
> Access or MS SQL Server. As a last resort, I could set up Oracle in my own
> home dir, but rather do it with the public Access or SQL Server.
I'm guessing your own home dir is on a Linux/Unix server and the MS SQL or
Access database is not?
As an alternative to Oracle, you can also install MySQL for free.
>
> Now, how do I go about this. Does perl enter into Access at all, or is
> this a no go? What should I use in the perl script?
Yes. If your intranet Web server is on the same PC server as the Access or
MS SQL installation, you can use Perl, the DBI module and DBD::ODBC or
Win32::ODBC to connect them directly. If not, this FAQ provides some ways to
connect:
http://tlowery.hypermart.net/perl_dbi_dbd_faq.html
Search the DBI mailing list for more alternatives. Try:
http://groups.google.com/groups?hl=en&lr=&ie=ISO-8859-1&q=connect+ms+sql
When it's up, there are more answers on the FAQ page at:
http://xmlproj.dyndns.org/dbi/faq.html
It wasn't up this am, however.
cp
------------------------------
Date: Wed, 9 Oct 2002 07:22:20 -0400
From: "Domizio Demichelis" <dd@4pro.net>
Subject: Re: Not so simple RE problem...
Message-Id: <ao13i6$htn7m$1@ID-159100.news.dfncis.de>
> Are you trying to parse HTML or XML? Because that's what it looks like
> you're doing, and that wheel has already been invented. There are modules
> that will do it much more efficiently and bug-free than any program you or
> I could write.
I know, thank you for your advice. I'm trying to parse a non standard simple
sintax based on labels and block (open and close tags).
--
-.. --- -- .. --.. .. ---
-.. . -- .. -.-. .... . .-.. .. ...
------------------------------
Date: Wed, 09 Oct 2002 11:36:45 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Not so simple RE problem...
Message-Id: <3da41465.30755203@news.cis.dfn.de>
On Wed, 9 Oct 2002 07:22:20 -0400, "Domizio Demichelis"
<dd@4pro.net> wrote:
>> Are you trying to parse HTML or XML? Because that's what it looks like
>> you're doing, and that wheel has already been invented. There are modules
>> that will do it much more efficiently and bug-free than any program you or
>> I could write.
>
>I know, thank you for your advice. I'm trying to parse a non standard simple
>sintax based on labels and block (open and close tags).
In that case, you would do well to read the FAQ
entry:
perldoc -q nesting
also known as: "How do I find matching/nesting anything?"
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Wed, 9 Oct 2002 07:39:31 -0400
From: "Domizio Demichelis" <dd@4pro.net>
Subject: Re: Not so simple RE problem...
Message-Id: <ao14ic$icktl$1@ID-159100.news.dfncis.de>
> In that case, you would do well to read the FAQ
> entry:
> perldoc -q nesting
> also known as: "How do I find matching/nesting anything?"
TANK YOU a lot. This is a very interesting faq.
--
-.. --- -- .. --.. .. ---
-.. . -- .. -.-. .... . .-.. .. ...
"Helgi Briem" <helgi@decode.is> wrote in message
news:3da41465.30755203@news.cis.dfn.de...
> On Wed, 9 Oct 2002 07:22:20 -0400, "Domizio Demichelis"
> <dd@4pro.net> wrote:
>
> >> Are you trying to parse HTML or XML? Because that's what it looks like
> >> you're doing, and that wheel has already been invented. There are
modules
> >> that will do it much more efficiently and bug-free than any program you
or
> >> I could write.
> >
> >I know, thank you for your advice. I'm trying to parse a non standard
simple
> >sintax based on labels and block (open and close tags).
>
> In that case, you would do well to read the FAQ
> entry:
> perldoc -q nesting
> also known as: "How do I find matching/nesting anything?"
>
> --
> Regards, Helgi Briem
> helgi AT decode DOT is
>
> A: Top posting
> Q: What is the most irritating thing on Usenet?
> - "Gordon" on apihna
------------------------------
Date: 9 Oct 2002 12:18:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Not so simple RE problem...
Message-Id: <ao16pu$fk3$1@mamenchi.zrz.TU-Berlin.DE>
According to Domizio Demichelis <dd@4pro.net>:
> I have a problem that I thought was simple to solve, until I tried :-)
>
> I have this string:
>
> $string = << '__EOS__';
> aaa {a} bbb {a} ccc {a} XXX {b} XXX {/a} ddd
> aaa {b} bbb {b} ccc {a} XXX {/a} ddd
> aaa {a}{/a} bbb {a} ccc {a} ddd
> __EOS__
>
> I need to replace the "{a}.*?{/a}" and the "{a}" (without the end {/a})
> with a "#", so - after the search and replace operation - the $string should
> contain this:
>
> "aaa # bbb # ccc # ddd
> aaa {b} bbb {b} ccc # ddd
> aaa # bbb # ccc # ddd"
>
> Note: $string could contain everything (.+) (and not just the \w that I put
> in the example to make it simpler to understand), the lines are not well
> organized as they appear in the example, and... I should use the content
> between {a} and {/a}. ( as in qr|{a}(.*?){/a}| )
A single regex is certainly not the right approach here. Even if
it can be done, it is nothing you want to maintain.
Eric(?) has already advised you to use a parser if there is one
for the language you're working on.
If there isn't, use a parser-like approach. Scan the string forward
for each opening delimiter "{a}". If found, look ahead for the next
opening or closing delimiter "{a}" or "{/a}". If it is another opening
delimiter, the original one is a singleton and must be replaced by
itself. If it is a closing delimiter "{\a}", extend the match to
include it and the intervening text and replace that. Resume scanning
after the replaced text.
The following code assumes the string in $_. It uses the interplay of
global matching and the pos() function. See "perldoc -f pos" for that.
It also uses the @- and @+ arrays, described in perlvar. As is common
in Perl, pos() keeps track of the parser's progress.
while ( /\{a\}/g ) {
my ( $from, $to) = ( $-[ 0], $+[ 0]);
$to = $+[ 0] if m!\{(/?)a\}!g and $1 eq '/';
substr( $_, $from, $to - $from) = '#';
pos = $from + length '#'; # resume after replacement
}
Anno
------------------------------
Date: 9 Oct 2002 05:03:10 -0700
From: danielrc15@hotmail.com (drc15)
Subject: Please help me with my Redirection script.
Message-Id: <1cb6e00b.0210090403.1b0187a5@posting.google.com>
Please help me with my Redirection script.
I am using the following redirection script, (quite a popular one).
#!/usr/bin/perl
require 'ctime.pl';
use CGI;
$q = new CGI;
#
# DEFAULT VARIABLES SECTION
#
$log = 1; # 1 log, 0 no log
$logfile = 'redir.log';
$delay = 20; # delay in seconds. $delay=0, $output=0 work well
together.
$output = 1; # 1 output, 0 no output
#
# END OF DEFAULT VARIABLES
#
# get the parameters from the form or url
$url = $q->param('url');
$title = $q->param('title');
# if $url is blank then set equal to root of current server
if ($url eq "") {
$url = 'http://'.$q->server_name().'/';
}
# if $title is blank then set equal to $url
if ($title eq "") {
$title = $url;
}
# print html header
header();
# if output requested, print body
if ($output) { body(); }
# print html footer
footer();
# if logging requested, add a log entry
if ($log) { addlog(); }
exit(0);
# the http-equiv line in the header actually does the redirect
sub header {
print $q->header;
print <<EOT;
<html>
<head>
<title>Redirect to $title</title>
<meta http-equiv="refresh" content="$delay; url=$url">
</head>
<body bgcolor="#ffffff">
EOT
}
sub body {
print <<EOT;
<h2 align=center>One moment please...</h2>
<p align=center><a href="$url">$title</a></p>
<h3 align=center>Thanks for visiting! Please come again.</h3>
EOT
}
sub footer {
print <<EOT;
</body>
</html>
EOT
}
sub addlog {
# get localtime()
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
# make all numbers in the date two digits
if ($sec < 10) { $sec = "0$sec"; }
if ($min < 10) { $min = "0$min"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($mon++ < 10) { $mon = "0$mon"; }
if ($mday < 10) { $mday = "0$mday"; }
# get remote host dns name or ip address
$host = $q->remote_host();
# get ctime() and chop off trailing newline
chop($time = ctime(time));
# open the logfile for appending
open(o,">>$logfile");
# each print() below is an alternative log format. only one
should
# ever be uncommented.
# print o "$host\t$mon/$mday/$year\t$hour:$min:$sec\t$url\n";
print o "$host\t$time\t$url\n";
# close the logfile
close(o);
}
I am calling the script in the following way:
<a href="www.myurl.com/cgi-bin/redirect.pl?url=http://www.myurl2.com/b.asp?A=1234&I=1899">LINK</a>
My main problem is that the '&' ampersand gets cutoff so the page
redirects to:
http://www.myurl2.com/b.asp?A=1234
instead of
http://www.myurl2.com/b.asp?A=1234&I=1899
I thought the '&' would get turned into '%26' on the url line, but it
does not but,
if you do this manually the redirection works.
Any thoughts would be appreciative.
------------------------------
Date: Tue, 8 Oct 2002 21:50:01 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.2 $)
Message-Id: <slrnaq76ap.4k1.tadmc@magna.augustmail.com>
Tom Beer <tom.beer@btfinancialgroup.spamfilter.com> wrote:
> tadmc@augustmail.com wrote in message
><5LOcnT6UYuup5D6gXTWcpQ@News.GigaNews.Com>...
>
>> Social faux pas to avoid
>> - Sending a "stealth" Cc copy
>
> What is a "stealth" cc copy
A "stealth Cc" is when you both email and post a reply without
indicating _in the body_ that you are doing so.
:-)
> and why should I avoid it?
Because the recipient may end up answering twice (email and news)
when once (news) would do.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 9 Oct 2002 12:24:19 +0100
From: "Saket Rungta" <saketrungta@hotmail.com>
Subject: Re: sendmail and perl
Message-Id: <ao13nq$13qg$1@sp15at20.hursley.ibm.com>
Thank you very much John, Richard and pkent.
I was permissions and/or relative path problem....
--
Thanks,
Saket
Saket Rungta1/UK/IBM@IBMGB (Office)
saket@bcs.org.uk (Personal)
"Saket Rungta" <saketrungta@hotmail.com> wrote in message
news:ans7fr$pia$1@sp15at20.hursley.ibm.com...
>
> I am trying to run a perl script whenever a user receives mail.
>
> I modified /etc/aliases as follows:
>
> # few comment lines in start have been removed..
>
> # Alias for mailer daemon
> MAILER-DAEMON:root
>
> # Following alias is required by the new mail protocol, RFC 822
> postmaster:root
>
> # Aliases to handle mail to msgs and news
> nobody: /dev/null
> jbench: |/tmp/append.pl
>
> --
> Then do sendmail -bi
>
> --
> /tmp/append.pl is as follows:
>
> #! /usr/bin/perl -w
>
> open (O, ">>append.out");
> print O "append.pl has been just executed...\n";
>
> while (<STDIN>) {
> print O;
> }
>
> close O;
>
> --
>
> Nothing seems to happen to append.out. Even though manual invocation of
> script appends the file. If mail is not redirected to perl script, the
> jbench user gets mail. Any suggestions?
> Perl 5.6.0 on AIX 5.1L
>
> --
> Thanks,
> Saket
>
> Saket Rungta1/UK/IBM@IBMGB (Office)
> saket@bcs.org.uk (Personal)
>
>
>
------------------------------
Date: 09 Oct 2002 13:05:05 GMT
From: Heinrich.Mislik@univie.ac.at (Heinrich Mislik)
Subject: Re: udp
Message-Id: <3da4297e$0$21434$3b214f66@aconews.univie.ac.at>
In article <9899055d.0210080609.64d3f90b@posting.google.com>, deita@inbox.lv says...
>executing theese two apps within interval 5 sec both applications exchanges
>messages successfuly. execing them with a little larger timeout, the first one
>does not send messages to the second.
I think, you just don't see correct results, because your programs consumes the whole availabe CPU. Try changing:
> if ($sel->can_read(0))
to
> if ($sel->can_read())
meaning to wait, until data is available. I tried this and it seems to do, what you expect.
--
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 3939
***************************************