[19280] in Perl-Users-Digest
Perl-Users Digest, Issue: 1475 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 9 09:10:36 2001
Date: Thu, 9 Aug 2001 06:10:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <997362617-v10-i1475@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 9 Aug 2001 Volume: 10 Number: 1475
Today's topics:
Re: perldoc is like Greek to a beginner?? <bart.lateur@skynet.be>
Re: perldoc is like Greek to a beginner?? <somewhere@in.paradise.net>
Re: Reaping zombies in Win32 Perl CGIs <bart.lateur@skynet.be>
Re: Regular Expression <iltzu@sci.invalid>
Re: replacing hex characters within a string with their (Helgi Briem)
Sub that defaults to use $_ in callers context (Yves Orton)
Term::Complete package / Windows2000 <philippe.perrin@sxb.bsf.alcatel.fr>
Re: Tk MainWindow options??? (Rob Seegel)
Re: Uppercasing extended characters <ilya@martynov.org>
Why? <paul@net366.com>
Re: Why? <bart.lateur@skynet.be>
Re: Why? <paul@net366.com>
Re: Write to middle of file (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 09 Aug 2001 10:12:53 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: perldoc is like Greek to a beginner??
Message-Id: <obo4ntcl321i3l6ilhv612u3cusnoj14ia@4ax.com>
Carlos C. Gonzalez wrote:
>I guess I compared it to C in the sense that Perl can get
>quite...I think the word is obsfiscated...or something like that.
obfuscated
>Where
>you get these little symbols meaning all this stuff without it making
>much sense to human eyes who are not familiar with the symbols. As
>compared to something like Visual Basic where the code sort of explains
>itself.
Would you prefer having to write
multiply(a,b)
to
a*b
? I think not.
Once you have to use the things in expressions over and over again,
you're very glad if it it's so short (and cryptic), instead of verbose,
like Cobol. It saves a lot of typing, and misdirected thinking, IMO. If
you have to spend your energy on writing "multiply" right, you tend to
forget what it was you were actually trying to do.
--
Bart.
------------------------------
Date: Thu, 9 Aug 2001 22:29:19 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: perldoc is like Greek to a beginner??
Message-Id: <3pvc7.34$uv3.966786@news.interact.net.au>
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:obo4ntcl321i3l6ilhv612u3cusnoj14ia@4ax.com...
> Carlos C. Gonzalez wrote:
>
> >I guess I compared it to C in the sense that Perl can get
> >quite...I think the word is obsfiscated...or something like that.
>
> obfuscated
>
> >Where
> >you get these little symbols meaning all this stuff without it making
> >much sense to human eyes who are not familiar with the symbols. As
> >compared to something like Visual Basic where the code sort of explains
> >itself.
>
> Would you prefer having to write
>
> multiply(a,b)
>
> to
>
> a*b
>
> ? I think not.
Unless you're a COBOL junkie.
------------------------------
Date: Thu, 09 Aug 2001 12:15:40 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Reaping zombies in Win32 Perl CGIs
Message-Id: <fov4nts8ompo4qrd3a88tsmh6rcvc18htn@4ax.com>
Moth Mann wrote:
>I'm writing a CGI in Perl that wants to send mail. Unfortunately, I
>have to do it under some wierd operating system marketed by MicroSoft.
>(It's the misnamed Windows 2000.) And this wierd OS does not have
>sendmail. So I use Net::SMTP to send the mail, which works.
>So! I came up with the bright idea of forking off a child process to do
>the actual talking to the SMTP server so I can return a page quickly and
>still have the mail be sent. Thanks to the heroic efforts of people I
>have never met, I can do this in ActiveState Perl 5.6.1 for lame Win32.
>
>But, now I'm wondering about zombies.
From my tests I gather that zombies don't even exist on Win32, so
there's no need to worry.
p.s. There's always blat. That's a free sendmail "clone" for Windows.
--
Bart.
------------------------------
Date: 9 Aug 2001 10:11:30 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Regular Expression
Message-Id: <997351779.10500@itz.pp.sci.fi>
In article <slrn9mt6bs.6k5.trammell@haqq.hypersloth.net>, John J. Trammell wrote:
>On 06 Aug 2001 11:00:10 -0500, Ren Maddox <ren@tivoli.com> wrote:
>[snip]
>> A quick benchmark on my system found that /^\d*$/ is actually faster
>> than /\D/. I expect this is due to some of the regex optimizations
>> for anchored patterns.
>
>I have used it (and /\S/ as well), but only because it makes more
>sense to me; the regex is just easier on my internal parser.
..and less prone to subtle bugs too.
"666\n" =~ /^\d*$/ and warn;
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Thu, 09 Aug 2001 12:50:28 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: replacing hex characters within a string with their ascii equivalent
Message-Id: <3b7286d3.1484393875@news.isholf.is>
On Thu, 9 Aug 2001 14:48:56 +1000, "Dianne van Dulken"
<dianne@dogmac.com> wrote:
>
>"Dianne van Dulken" <dianne@dogmac.com> wrote in message
>news:RXnc7.1439$813.66485@ozemail.com.au...
>> Hi all
>>
>> I am having a bit of a problem with a querystring variable that I need to
>> save into a database. A typical string being passed might be:
>>
>> %3Cdel_phone%3E%28020%200202%2000202%3C/del_phone%3E
>
>Sorry to reply to my own post, but I just found the answer
>
>$string =~ s/%(..)/chr hex $1/eg;
>
>Though the real problem was how the data was being called initially, so I
>changed the parsing there.
No the real problem is that you are trying to home-roll
your input parsing routines instead of using CGI.pm
Regards,
Helgi Briem
------------------------------
Date: 9 Aug 2001 05:34:21 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Sub that defaults to use $_ in callers context
Message-Id: <74f348f7.0108090434.4bbcdcfb@posting.google.com>
Hi All,
Just curious if anyone knows how to get access to the callers $_ so
that it can be used as a default like so many keywords do?
I tried to do it directly by
sub func {
my $param=shift || $_;
}
but obviously this doesnt work as $_ is automatically localized to the
sub (at least im pretty sure I read that somwhere.) Either way though
it didnt work.
My other thought was that somehow caller() could be used, but alas I
couldn't see a way to use it effectively.
Sorry I have no code to post but on this one I'm at a loss as to even
where to begin.
Cheers,
Yves
------------------------------
Date: Thu, 09 Aug 2001 11:24:18 +0200
From: Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr>
Subject: Term::Complete package / Windows2000
Message-Id: <3B7256C2.EFC06A56@sxb.bsf.alcatel.fr>
Hi
I'm trying to use the Term::Complete package... I've no problem with
Solaris. But with Windows, it can't execute the system('stty raw -echo')
command (which isn't too surprising). What surprises me is that the
package came with the ActivePerl distribution, designed to work with
Windows.
Does anyone have an idea of what command(s) I should put to replace the
system('stty raw -echo') instruction ?
Thnx
--
PhP
------------------------------
Date: 09 Aug 2001 12:26:04 GMT
From: robseegel@aol.com (Rob Seegel)
Subject: Re: Tk MainWindow options???
Message-Id: <20010809082604.28110.00002206@ng-fl1.aol.com>
>Does enybody know how to made MainWindow with fixed width, heign
>and non resizeble?
$mw = MainWindow->new;
$mw->resizable(0, 0);
check out perldoc Tk::Wm
Rob
------------------------------
Date: 09 Aug 2001 16:53:55 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Uppercasing extended characters
Message-Id: <873d718kd8.fsf@abra.ru>
C> I am trying ot uppercase ASCII characters like ñ.
C> This character has the HTML character entity representation ñ, the
C> ASCII code 164 or the character code \361 on my Solaris box.
C> Why isn't the uc function uppercasing it?
C> $string = "ñ";
C> print uc($string);
C> It outputs the same character in small case.
C> Does this have anything to do with my locale? This is the only thing I
C> haven't played around with.
Short answer: add 'use locale' to your script. If you locale is
configured your script will work. Read 'perldoc perllocale' for more
info.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Thu, 9 Aug 2001 13:02:00 +0100
From: "Paul Fortescue" <paul@net366.com>
Subject: Why?
Message-Id: <997358441.13861.0.nnrp-08.d4f094e4@news.demon.co.uk>
#!/usr/bin/perl
print "Content-type:text/html\n\n";
$file="<./cgi-files/mail.txt";
open(HTML, "$file") || ($fileerr=1);
if (!$fileerr)
{
while ($line=readline HTML)
.
.
.
In ActivePerl, I get a warning Name "main::HTML" used only once: possible
typo at mail.pl line 6., although the script works.
On Linux, it doesn't do anything, the file HTML is open (ie $fileerr!=1) but
the readline breaks the while loop.
Can I not use readline? Is there something odd about it? Is there a 'better'
way to read a line of text, terminated by \n?
Sorry if this question is very fundamental!
Thanks in advance - Paul
------------------------------
Date: Thu, 09 Aug 2001 12:24:44 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Why?
Message-Id: <6705ntgpfbviqq6bbp1q92nhkhigjv7q4o@4ax.com>
Paul Fortescue wrote:
>while ($line=readline HTML)
>In ActivePerl, I get a warning Name "main::HTML" used only once: possible
>typo at mail.pl line 6., although the script works.
>
>On Linux, it doesn't do anything, the file HTML is open (ie $fileerr!=1) but
>the readline breaks the while loop.
>
>Can I not use readline? Is there something odd about it? Is there a 'better'
>way to read a line of text, terminated by \n?
The normal idiom is
while ($line=<HTML>) { ... }
or even
while(<HTML>) {... }
which reads into the default variable $_.
I can't understand how you can have missed that, if you did some reading
of the docs that came with perl.
--
Bart.
------------------------------
Date: Thu, 9 Aug 2001 14:00:22 +0100
From: "Paul Fortescue" <paul@net366.com>
Subject: Re: Why?
Message-Id: <997361947.15223.0.nnrp-08.d4f094e4@news.demon.co.uk>
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:6705ntgpfbviqq6bbp1q92nhkhigjv7q4o@4ax.com...
> Paul Fortescue wrote:
>
> >while ($line=readline HTML)
>
> >In ActivePerl, I get a warning Name "main::HTML" used only once: possible
> >typo at mail.pl line 6., although the script works.
> >
> >On Linux, it doesn't do anything, the file HTML is open (ie $fileerr!=1)
but
> >the readline breaks the while loop.
> >
> >Can I not use readline? Is there something odd about it? Is there a
'better'
> >way to read a line of text, terminated by \n?
>
> The normal idiom is
>
> while ($line=<HTML>) { ... }
>
> or even
>
> while(<HTML>) {... }
>
> which reads into the default variable $_.
>
> I can't understand how you can have missed that, if you did some reading
> of the docs that came with perl.
>
> --
> Bart.
Thanks, Bart. I did RTFM but it is not easy for me to understand. I did not
understand that while ($line=<HTML>) is the same thing as
$line=readlne(*HTML). I think I will recode it like you say, but I still
don't understand the difference between HTML and *HTML. I think it is
something to do with referencing or typeglobs but I am new to Perl so I will
struggle! If the manual was like Windows instead of like UNIX :) ...
------------------------------
Date: 9 Aug 2001 12:50:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Write to middle of file
Message-Id: <9ku0ua$9el$3@mamenchi.zrz.TU-Berlin.DE>
According to Sean Hamilton <sh@planetquake.com>:
> Well, the main issue is the breaking of shared locks. I'm probably just
> going to have to write B back into A. At least then I won't have a 50 meg
> chunk of memory used up.
>
> sh
>
> "Wyzelli" <wyzelli@yahoo.com> wrote in message
> news:IAkc7.3$x7.79118@wa.nnrp.telstra.net...
> > "Sean Hamilton" <sh@planetquake.com> wrote in message
> > news:_okc7.39918$b_3.3216291@news0.telusplanet.net...
[replacing a file with an updated version]
> > > Now here is the problem: I should then delete A and rename B to A.
> > However,
> > > I fear the brief period of time in which A is absent will break things.
> > >
> > > Ideas?
> > >
> >
> > Rename A and then rename B? Whilst there is still a brief moment of
> absence
> > of A, it may be significantly shorter than the delete - rename process.
> >
> > It also depends on your OS.
> >
> > If you are on a *nix, you could create a symbolic link to A, for normal
> > operations, then simply rename the symbolic link to point to B after the
> > write is completed. That is probably about as non disruptive as you could
> > get.
In Unix, it is common practice to move the updated version "over" the
original (i.e. without deleting the original before). This effectively
unlinks the original, and common usage seems to indicate that this is
viewed as an atomic operation. If that is literally true (even
over NFS?), or if it's just good enough to support a common practice
I don't know.
Anno
------------------------------
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 1475
***************************************