[13004] in Perl-Users-Digest
Perl-Users Digest, Issue: 414 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 7 12:05:44 1999
Date: Sat, 7 Aug 1999 09:05:10 -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 Sat, 7 Aug 1999 Volume: 9 Number: 414
Today's topics:
Re: a time to kill (Larry Rosler)
Re: a time to kill (I R A Darth Aggie)
Re: a time to kill <tchrist@mox.perl.com>
Re: Beginners question: printf %s justification (I R A Darth Aggie)
Re: Complex data structure (Larry Rosler)
Re: Complex data structure (Larry Rosler)
Re: file size (Larry Rosler)
FORM processing <s.r.boschman@student.utwente.nl>
Re: How [not] to be Y2K compliant (Chris Nandor)
Re: Is this an appropreate use of -i switch? <rootbeer@redcat.com>
JavaScript or Perl? <JFedor@datacom-css.com>
MIME::Lite mr_potato_head@my-deja.com
Re: modem dialingL HOWTO. (Bbirthisel)
Re: modem dialingL HOWTO. (Greg Teets)
Re: Nastiness contrary to the spirit of perl? (I R A Darth Aggie)
Re: Nastiness contrary to the spirit of perl? (I R A Darth Aggie)
Re: Nastiness contrary to the spirit of perl? <tchrist@mox.perl.com>
Nicer Way <admin@gatewaysolutions.net>
Problem with qx() under NT <larry@lkba.com>
Re: qr{} and quoting pattern metachars <ltl@rgsun40.viasystems.com>
Re: qr{} and quoting pattern metachars <ltl@rgsun40.viasystems.com>
Re: Renaming a hash key ? (Matthew Bafford)
The IF and AND commands <everymans@argonet.co.uk>
Re: The IF and AND commands <kims@emmerce.com.au>
Re: The IF and AND commands <JFedor@datacom-css.com>
what does this warning mean ? <hongy@panther.cs.ucla.edu>
Re: what does this warning mean ? <tchrist@mox.perl.com>
Re: Win32 Perl 'alarm()' substitution? (Bbirthisel)
windows executable <voyeur@istar.ca>
Re: windows executable <kims@emmerce.com.au>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 7 Aug 1999 08:07:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: a time to kill
Message-Id: <MPG.1215eb91b34206c1989dfd@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <x71zdggr01.fsf@home.sysarch.com> on 07 Aug 1999 00:21:34 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "A" == Abigail <abigail@delanet.com> writes:
>
> A> [comp.lang.perl.*]
> A> Score:: 2000
> A> From: elaine ashton
> A> From: Greg Bacon
> A> From: Larry Rosler
> A> From: Uri Guttman
>
> hey, i made abigail's list but not tom's :-()
>
> i wonder if i am who larry referred to when he noticed his name on tom's
> list and someone else was missing?
I'll let you keep on wondering.
Note that all of the above are scored higher than merlyn. How's that
for an idiosyncratic value judgment?
I don't bother with such things. I might miss out on some of the 'fun'.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 6 Aug 1999 20:39:09 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: a time to kill
Message-Id: <slrn7qmi3h.9pa.fl_aggie@thepentagon.com>
On Fri, 6 Aug 1999 11:46:29 -0700, Larry Rosler <lr@hpl.hp.com>, in
<MPG.1214cd5e6d4f221c989df0@nntp.hpl.hp.com> wrote:
+ 2. Tolkien
And in another post TC refered to him as the grandfather of perl.
+ > First we kill anybody so clueless as not to include lower-case letters
+ > in their subject. STOP SHOUTING, YOU NIMRODS!
+ 5. Genesis
Quoth: Nimrod was a mighty hunter before the LORD. The footnotes I've
read claim he was a hunter of _men_.
+ > Out, out, you demons of stupidity!
+ 7. Mark, Luke, Acts
Actually, St. Dogbert. Quoth Dilbert: I don't think I've ever seen your
spiritual side before. Had the demons been cast out into a herd of swine,
then you may have been onto something.
Of course, those particular demons were called LEGION. Sounds vaguely
familiar...legions of newbies...
+ What did I miss, anyone?
You asked...
James
------------------------------
Date: 7 Aug 1999 09:54:26 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: a time to kill
Message-Id: <37ac56b2@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
lr@hpl.hp.com (Larry Rosler) writes:
:Note that all of the above are scored higher than merlyn. How's that
:for an idiosyncratic value judgment?
Ah; so that's what "idiosyncratic" means now. Fascinating. :-)
--tom
--
Unix is supported by IBM, like a hanging man is supported by rope
- _Life With Unix_ Don Libes & Sandy Ressler
------------------------------
Date: 6 Aug 1999 18:34:23 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Beginners question: printf %s justification
Message-Id: <slrn7qmapj.9bi.fl_aggie@thepentagon.com>
On Fri, 6 Aug 1999 02:39:07 +1000, Kim Saunders <kims@emmerce.com.au>, in
<933957530.662452@draal.apex.net.au> wrote:
+ >Reading the manual is so much faster than waiting for Usenet followups.
+ Yeah, but then YOU have to do it yourself. A ng will deliver it on a plate
+ in your inbox in hours!
Presuming, of course, that you get a correct answer...
James
------------------------------
Date: Sat, 7 Aug 1999 07:30:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Complex data structure
Message-Id: <MPG.1215e2c4292ae427989dfb@nntp.hpl.hp.com>
In article <37ABDF1A.A78902AC@dstc.com> on Sat, 07 Aug 1999 17:24:10
+1000, Derek Thomson <derek@dstc.com> says...
> Abigail wrote:
> > Derek Thomson (derek@dstc.com) wrote on MMCLXVI September MCMXCIII in
> > <URL:news:37AA3351.E522E2E0@dstc.com>:
> > `` > In article <FFzL6I.1yH@csc.liv.ac.uk>,
> > `` > ijg@connect.org.uk (I.J. Garlick) wrote:
> > `` > > map {print "Code = $_\n"} @{$Codes{$Comp}};
> > ``
> > `` Map in a void context. Why build a list that you're going to throw away?
> >
> > Don't blame him for a long standing bug in Perl. It can't be that
> > bad, else the bug would have been fixed long time ago.
>
> Ah, these blasted newbies. According to "perldoc -f map" it seems to be
> functioning perfectly.
>
> Did you *read* the man pages, or what?
>
> :)
>
> Please, have mercy, I'm only kidding. Creating a list is a consequence
> of the statement provided. I was just pointing that out. I don't want to
> start a style war. I've always been annoyed about this a little, because
> I like the map function. The "expr for (list);" statement seems to have
> taken care of this somewhat.
One would think it had taken care of this entirely, one and for all.
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my @a = (1) x 1000;
timethese(1 << (shift || 0), {
For => sub { $_ *= 1 for @a },
GrepL => sub { grep { $_ *= 1 } @a },
GrepS => sub { my $x = grep { $_ *= 1 } @a },
Map => sub { map { $_ *= 1 } @a },
});
__END__
Benchmark: timing 1024 iterations of For, GrepL, GrepS, Map...
For: 3 wallclock secs ( 3.14 usr + 0.00 sys = 3.14 CPU)
GrepL: 12 wallclock secs (11.91 usr + 0.00 sys = 11.91 CPU)
GrepS: 12 wallclock secs (12.20 usr + 0.00 sys = 12.20 CPU)
Map: 12 wallclock secs (12.41 usr + 0.00 sys = 12.41 CPU)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 7 Aug 1999 07:51:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Complex data structure
Message-Id: <MPG.1215e7e4c4a1348b989dfc@nntp.hpl.hp.com>
In article <37ABEF72.70DFED0@dstc.com> on Sat, 07 Aug 1999 18:33:54
+1000, Derek Thomson <derek@dstc.com> says...
> Abigail wrote:
...
> > It ticks me off that people think or suggest that it's logical that map{}
> > is void context creates a list. It's not. Context sensitivity is a key
> > feature of Perl. Any buildin that doesn't take advantage of it is *B0RKEN*.
>
> I'm sensing that you've discussed this before, because I never said or
> even remotely suggested that it was logical, or nice, or desirable -
> just that right now it is a consequence of using map in a void context
> that you create an unnecessary list.
>
> I'm off to deja-news to check it out, it's sure to be interesting ...
>
> Is this likely to be changed? Do others have a problem with this? I'm
> guessing that there is an opposing viewpoint as it hasn't, in fact, been
> "fixed".
It is 'only' a performance bug, in an area where those in the know have
trained themselves to do it Another Way. It is even documented. There
are innumerable ways to do things slowly in Perl. Some of them can be
fixed by the compiler; some cannot. Some are documented; some are not.
To say 'it is *BORKEN*' is wildly overstating the case. On my list of
priorities (which gets murky toward the bottom):
broken functionality (wrong answers)
erroneous user documentation
new functionality
inadequate user documentation
poor performance (no reasonable alternative)
erroneous internal documentation
poor performance (ready alternative)
inadequate internal documentation
it's a tie for the bottom, about as important as fixing Abigail's
spelling typo. :-)
All that said, if it were trivial to fix, someone might have fixed it
(map and grep -- and split, for that matter). I have resolutely avoided
delving into the perl source, so I don't much care.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 7 Aug 1999 08:27:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: file size
Message-Id: <MPG.1215f030197a6297989dfe@nntp.hpl.hp.com>
In article <37abd5a7$0$220@nntp1.ba.best.com> on 07 Aug 1999 06:43:51
GMT, John Callender <jbc@shell2.la.best.com> says...
> Larry Rosler <lr@hpl.hp.com> wrote:
>
> > perldoc -f -X
>
> [jbc@xena jbc]$ perldoc -f -X
> No documentation for perl function `-X' found
>
> [jbc@xena jbc]$ perldoc -f '-X'
> No documentation for perl function `-X' found
>
> [jbc@xena jbc]$ perl -v
>
> This is perl, version 5.004_04 built for alpha-linux
> (with 1 registered patch, see perl -V for more detail)
Yeah. I tested it on Windows 95, and was so surprised when it worked
that I forgot about the different option handling in Unix shells and
didn't test it there as well.
perldoc -f -- -X
However:
C:\WINDOWS>perldoc -f -- -X
No documentation for perl function `--' found
Can't win 'em all. Sigh...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 7 Aug 1999 15:57:39 +0200
From: "S.R. Boschman" <s.r.boschman@student.utwente.nl>
Subject: FORM processing
Message-Id: <7ohe7f$ivo$1@dinkel.civ.utwente.nl>
Hey,
I'm kinda new to perl programming and I have something I cant figure out
with help of all the webpages (perhaps didnt find the right one).
I'm working on a guestbook script but the problem thing is that I want
1 script file that is capable of handling different guestbooks. So the
webpage calling the script has to pass on a variable containing its name, so
the script knows which guestbook to update. Well thats the idea. Now did I
find somewhere a good guestbook script and tried to
implement my idea. But now comes the problem. The script uses a
variable which is normally set in the script with the location to the
guestbook file.
$GUESTBOOK="path/gbook.htm";
now did I change this into
$GUESTBOOK= join "/","path",$fields{'filename'};
but it just wont place the filename there, the filename string is empty! BUT
when I add a line the script to print the value of filename to the file
it shows up correctly. Thats the weird part of it.
I also tried the following code to get the parameters passed on by the form
(POST method)
@fields = split(/&/,$buffer);
foreach $field (@fields) {
($name,$value) = split(/=/,$field);
$form{$name} = $value;}
$filename = $form{'filename'};
but I get the same result, the $filename variable stays empty. But he knows
the value of filename somewhere because he can print it to screen!!!!!
Is there anybody who knows what I'm doing wrong? Or has an idea how to make
a path and filename string on the fly using variables from the form? Thnx in
advance
a desperate
Sverre
------------------------------
Date: Sat, 07 Aug 1999 11:26:38 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: How [not] to be Y2K compliant
Message-Id: <pudge-0708990726440001@192.168.0.16>
In article <933956686.624320@draal.apex.net.au>, "Kim Saunders"
<kims@emmerce.com.au> wrote:
>Gee Tom, (sic) didn't realise you had so much spare time? (sic) I'd have
>though (sic) you were to (sic) busy for this??? (sic)
I'd have thought you were too busy to write _this_ post. Then again, the
abundance of errors may be an indication that indeed, you were too busy to
write the post.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Sat, 7 Aug 1999 08:51:02 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Is this an appropreate use of -i switch?
Message-Id: <Pine.GSO.4.10.9908070843340.19222-100000@user2.teleport.com>
On Fri, 6 Aug 1999, Bill Moseley wrote:
> I'm doing text substitution on a bunch of files and I got lazy
> and decided to let perl's magic -I do some work for me.
>
> As it's magic (at least in my mind), I'm wondering if there's
> any pitfalls to watch out for using this method.
Yes, depending upon what you consider a pitfall. :-)
> For example, would I be better off doing the reading/writing/renaming
> myself to catch open/write/close errors (to prevent a partially
> updated file), or does the -I magic do that for me? That is, with -I
> do the files only get renamed at the end if all goes well?
Here's a program which may (or may not) answer your question.
#!/usr/bin/perl -w
use strict;
@ARGV = $0;
$^I = '.bak';
while (<>) {
die "emergency exit" if $. > 3;
} continue {
print;
}
You can always do the work of $^I on your own, if it's not to your liking.
But for most purposes, it's fine. That's assuming that you don't mind
renaming *.bak in bulk from time to time. :-)
> Would pre-compiling the search pattern with /o be a good idea, even if
> they are constants?
Well, using /o on a literal pattern is a lot like taking the light bulb
out of your refrigerator to make it stay cooler. It doesn't make any
practical difference, but it makes other people snicker at you behind your
back.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 7 Aug 1999 11:32:04 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: JavaScript or Perl?
Message-Id: <7ohhgq$l4v$1@plonk.apk.net>
I don't know where to ask this question:
Does anyone know if there is a comparable function in JavaScript as Perl's
"ord" function and "chop" function?
Perl's "ord" function converts a character to its ASCII equivalent and the
"chop"
function removes the last character of a string.
I'm trying to convert the following line of code to JavaScript:
$num = ord(chop($test)) - 32;
Any suggestions?
Jody
------------------------------
Date: Sat, 07 Aug 1999 14:28:11 GMT
From: mr_potato_head@my-deja.com
Subject: MIME::Lite
Message-Id: <7ohfpm$1rr$1@nnrp1.deja.com>
Hi,
I'm currently running solaris 2.6 with perl 5.005 on a ultra 1. I
followed the MIME::Lite install to the tee and it installed without any
problems that I could see. I copyed the sample script and inserted my
email address instead of the generic that was in there along with a real
gif file and ran the mail attachment script. I got no errors that I
could see but I never got the email. Can anyone tell me how to trouble
shoot this? I've never installed these perl add-on modules before but
this MIME::Lite I think was really a no brainer. Any trouble shooting
help would be appreciated. Thanks in advance...
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 07 Aug 1999 13:16:47 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: modem dialingL HOWTO.
Message-Id: <19990807091647.04904.00005326@ng-cl1.aol.com>
Hi Greg:
>>open(MODEM,">/dev/modem") || die"Can't open modem: $!";
>>print MODEM "ATDT5551212\r"; # Hayes command language common to
>> # most modems
>>close MODEM;
>>
>>Hope this helps.
>How would I do this on Win32?
use Win32::SerialPort;
Available on CPAN. See The Perl Journal #13 for examples.
Also available at http://members.aol.com/bbirthisel/alpha.html
(both module and examples)
-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)
------------------------------
Date: Sat, 07 Aug 1999 15:50:44 GMT
From: teetsg@fuse.net (Greg Teets)
Subject: Re: modem dialingL HOWTO.
Message-Id: <37ac55af.45130450@nntp.fuse.net>
>Assumption: You want to run your Perl app on linux.
>
>Simplest way:
>
>open(MODEM,">/dev/modem") || die"Can't open modem: $!";
>print MODEM "ATDT5551212\r"; # Hayes command language common to
> # most modems
>close MODEM;
>
>Hope this helps.
What about on Windows98?
Thanks.
------------------------------
Date: 6 Aug 1999 18:30:55 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <slrn7qmaj2.9bi.fl_aggie@thepentagon.com>
On Fri, 06 Aug 1999 17:06:59 GMT, dont_jump@on_me.com <dont_jump@on_me.com>, in
<37b5162d.11475761@news.iag.net> wrote:
+ I am not defending lazy newbies. I am suggesting that they be
+ ignored.
Depends on why the lazy newby is a lazy newby.
1. A lazy newby that wants someone else to do his work for him.
2. Someone who doesn't realize they have documentation available,
for free and already installed.
3. Someone who doesn't know how to effectively use the documentation
to find answers quickly.
There may be other cases.
The only thing we can do for Type 1 is to send them a rate card. Type
2 can be educated, and then taught to use search tools to make finding
information more efficient (applicable to Type 3).
At that point, a Type 2 or Type 3 newbie can become either a Type 1
newbie thru willful ignorance (and thus, maybe safely ignored) or they
graduate to Just Another Perl Beginner.
Ignoring the beginner from start to finish is not a particularly good
solution.
James
------------------------------
Date: 6 Aug 1999 20:53:25 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <slrn7qmiu9.9pa.fl_aggie@thepentagon.com>
On Fri, 06 Aug 1999 17:34:01 GMT, dont_jump@on_me.com <dont_jump@on_me.com>, in
<37b619b3.12377768@news.iag.net> wrote:
+ disagreements, I am simply keeping the comments in usenet - not in my
+ e-mail box.
If you're going to go with fake addresses, you should really use a
fake domain. I could go out today and reserve the on_me.com domain,
as Network Solutions claims it isn't taken. One recommendation I've
seen is to add .invalid to the end.
It isn't as if the determined or enterprising can't track down your
in-box...and if your worried about that one or two bad apples, well,
you're a day late and dollar short...
+ All of the aliases I have used in these posts are obvious inventions
Multiple aliases? is that due to "lighthearted" fun, or an attempt to
evade killfiles? To coin a phrase: that simply isn't cricket.
James
------------------------------
Date: 7 Aug 1999 09:57:25 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <37ac5765@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
fl_aggie@thepentagon.com (I R A Darth Aggie) writes:
:If you're going to go with fake addresses, you should really use a
:fake domain. I could go out today and reserve the on_me.com domain,
:as Network Solutions claims it isn't taken. One recommendation I've
:seen is to add .invalid to the end.
The cretin has earned a new killfile entry:
/\biag\.net/HMessage-ID:j
Pity I have to throw all the apples out due to one bad one. But I shall
not suffer illegal and unaccountable messages to grace my screen.
--tom
--
Fifty years of programming language research, and we end up with C++ ???
--Richard A. O'Keefe
------------------------------
Date: Sat, 7 Aug 1999 09:49:19 -0500
From: "Scott Beck" <admin@gatewaysolutions.net>
Subject: Nicer Way
Message-Id: <rqohn6emkur21@corp.supernews.com>
I am sure there is a nicer way to write this so I am not even going to pose
that question.
What is the nicer way?
#!/usr/bin/perl
%ch=(r=>4,
w=>2,
x=>1,
k=>0
);
$chmod="rwxr-xr-x";
$chmod =~ s/\-/k/g;
$chmod =~
s/(.)(.)(.)(.)(.)(.)(.)(.)(.)/$ch{$1}+$ch{$2}+$ch{$3}.$ch{$4}+$ch{$5}+$ch{$6
}.$ch{$7}+$ch{$8}+$ch{$9}/e; #note: this is one long line!
print "$chmod";
Thanks
--
Scott Beck
admin@gatewaysolutions.net
www.gatewaysolutions.net
------------------------------
Date: Sat, 07 Aug 1999 11:18:16 -0400
From: Larry Blische <larry@lkba.com>
Subject: Problem with qx() under NT
Message-Id: <37AC4E38.D5FB921F@lkba.com>
I'm porting a set of Perl scripts from UNIX to NT and can't figure out what's
wrong with the following use of qx().
This is ActiveState Perl and the Cygwin bash shell.
I have a file 'h' which contains one line of the text: 'hello',
a perl script 'a':
#!/usr/local/bin/perl5
#
print qx(cat h);
print qx(headoff h);
and perl script 'headoff':
#!/usr/local/bin/perl5
###############################
die "usage: headoff\n" if @ARGV != 0;
Running a gives the following:
bash-2.02$ a
hello
The name specified is not recognized as an
internal or external command, operable program or batch file.
bash-2.02$
i.e., the qx(cat h) works but the qx(headoff) does not.
Running headoff at the shell works too:
bash-2.02$ headoff h
usage: headoff
I'm running this Perl:
bash-2.02$ perl -v
This is perl, version 5.005_03 built for MSWin32-x86-object
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-1999, Larry Wall
Binary build 515 provided by ActiveState Tool Corp. http://www.ActiveState.com
Built 19:53:14 Apr 9 1999
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
bash-2.02$
Any ideas?
--
Larry Blische * Consultant/Programmer
Desktop Applications : Client/Server : Embedded Systems : Device Drivers : Etc.
6195 Eagles Nest Drive * Jupiter, Florida 33458 USA
561.747.7844 * NeXT, MIME and ASCII mail Welcome!
mailto:lkb@lkba.com * resume at http://www.charm.net/~lkb/
------------------------------
Date: 7 Aug 1999 13:20:43 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: qr{} and quoting pattern metachars
Message-Id: <7ohbrb$c7v$1@rguxd.viasystems.com>
Tom Christiansen <tchrist@mox.perl.com> wrote:
:>In comp.lang.perl.misc,
:> lee.lindley@viasystems.com writes:
:>:I thought that I understood what was happening with qr{}. perldoc
:>:perlop says that it quotes like a double quoted string (unless qr'').
:>:I expected \Q..\E quoting of metacharacters to work within a
:>:string passed to the qr operator. But it is not working the way
:>:I expect. Bug? Or am I missing something about how the quoting
:>:is done and the expression is being evaluated?
[snip]
:> Gory details of parsing quoted constructs
[snip]
:> `""', ```', `qq//', `qx//', `<file*glob>'
:> `\Q', `\U', `\u', `\L', `\l' (possibly paired with `\E')
:> are converted to corresponding Perl constructs. Thus,
:> `"$foo\Qbaz$bar"' is converted to `$foo .
:> (quotemeta("baz" . $bar))' internally. The other
:> combinations are replaced with appropriate expansions.
[snip]
:> Interpolated scalars and arrays are converted internally
:> to the `join' and `.' catentation operations. Thus,
:> `"$foo XXX '@arr'"' becomes:
:> $foo . " XXX '" . (join $", @arr) . "'";
:> All operations above are performed simultaneously, left
:> to right.
[snip]
Since the quotemeta treatment is performed simultaneously
with variable interpolation, '\Q' contained within a variable
is not treated specially?
Seems to be supported by this:
#!/usr/lib/lprgs/perl -w
use strict;
#use re 'debug';
my $re_string = q{(\Qfirst.second\E|\Qfirst.last\E)};
my $re_string_qq = qq{(\Qfirst.second\E|\Qfirst.last\E)};
my $re_string_dq = "(\Qfirst.second\E|\Qfirst.last\E)";
my $re_string_qq_interp = qq{$re_string};
my $re_string_dq_interp = "$re_string";
my $test_string = 'xxx first.second yyy';
foreach my $test_re_string ($re_string, $re_string_qq, $re_string_dq,
$re_string_qq_interp, $re_string_dq_interp,) {
my $re = qr{$test_re_string};
if ($test_string =~ $re) {
print "MATCHED: $test_re_string\n";
} else {
print "FAILED : $test_re_string\n";
}
}
########## END ##############
FAILED : (\Qfirst.second\E|\Qfirst.last\E)
MATCHED: (first\.second|first\.last)
MATCHED: (first\.second|first\.last)
FAILED : (\Qfirst.second\E|\Qfirst.last\E)
FAILED : (\Qfirst.second\E|\Qfirst.last\E)
So \Q is something that is applied to a quoted string,
which is not necessarily a re. Hmm. Not how I had thought
about it before.
P.S.
use re 'debug';
was most helpful. I had never read that far down the perldebug
document before and was surprised to find it there.
------------------------------
Date: 7 Aug 1999 13:37:30 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: qr{} and quoting pattern metachars
Message-Id: <7ohcqq$c7v$2@rguxd.viasystems.com>
:>#!/usr/lib/lprgs/perl -w
:>use strict;
:>#use re 'debug';
:>my $re_string = q{(\Qfirst.second\E|\Qfirst.last\E)};
:>my $re_string_qq = qq{(\Qfirst.second\E|\Qfirst.last\E)};
:>my $re_string_dq = "(\Qfirst.second\E|\Qfirst.last\E)";
:>my $re_string_qq_interp = qq{$re_string};
:>my $re_string_dq_interp = "$re_string";
:>my $test_string = 'xxx first.second yyy';
:>foreach my $test_re_string ($re_string, $re_string_qq, $re_string_dq,
:> $re_string_qq_interp, $re_string_dq_interp,) {
:> my $re = qr{$test_re_string};
:> if ($test_string =~ $re) {
:> print "MATCHED: $test_re_string\n";
:> } else {
:> print "FAILED : $test_re_string\n";
:> }
:>}
:>########## END ##############
:>FAILED : (\Qfirst.second\E|\Qfirst.last\E)
:>MATCHED: (first\.second|first\.last)
:>MATCHED: (first\.second|first\.last)
:>FAILED : (\Qfirst.second\E|\Qfirst.last\E)
:>FAILED : (\Qfirst.second\E|\Qfirst.last\E)
Wait a minute. Some ugly tcl practices are perking in my back brain
$var = eval qq{"$re_string"}; # \Q in $re_string applied
--
// Lee.Lindley /// Programmer shortage? What programmer shortage?
// @bigfoot.com /// Only *cheap* programmers are in short supply.
//////////////////// 50 cent beers are in short supply too.
------------------------------
Date: Sat, 07 Aug 1999 15:09:03 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Renaming a hash key ?
Message-Id: <slrn7qohgm.bg.*@dragons.duesouth.net>
On Fri, 6 Aug 1999 22:21:16 -0700, Larry Rosler) poured coffee onto a
keyboard, producing the following in comp.lang.perl.misc:
: In article <37AB1F75.4D217CC4@dwc.ch> on Fri, 06 Aug 1999 19:46:29
: +0200, Christoph Wernli <cw@dwc.ch> says...
: > Is there a possibility other than
: >
: > $hash{new_key} = $hash{old_key};
: > delete $hash{old_key};
: >
: > to rename a key ?
:
: Interesting. The third time this week for this question or equivalent,
: but never before that I can recall. An inFAQ.
:
: Oh, the answer: No.
But you can squish it down slightly:
$hash{new_key} = delete $hash{old_key};
: (Just Another Larry) Rosler
--Matthew
------------------------------
Date: Sat, 07 Aug 1999 13:46:16 BST
From: Everymans Wine <everymans@argonet.co.uk>
Subject: The IF and AND commands
Message-Id: <na.88da0d492d.a70160everymans@argonet.co.uk>
Hi,
I'm trying to write a CGI script in perl and have hit a stumbling block -
what I want to write is:
If ($this_variable 'is equal to' $variable1 'and' $variable2)
so is it possible to use 'and' in an if statement? Does anyone else have
another way round this problem?
Many thanks in advance,
Peter.
--
Everymans Wine, Tel: +44 (0) 1743 36 24 66
100 Frankwell, Shrewsbury, Fax: +44 (0) 1743 23 12 48
United Kingdom, SY3 8JS. WWW: http://www.everymans.com/
------------------------------
Date: Sun, 8 Aug 1999 01:25:03 +1000
From: "Kim Saunders" <kims@emmerce.com.au>
Subject: Re: The IF and AND commands
Message-Id: <934039448.979838@draal.apex.net.au>
>If ($this_variable 'is equal to' $variable1 'and' $variable2)
>
>so is it possible to use 'and' in an if statement? Does anyone else have
>another way round this problem?
Try it and find out:
if (($this_variable eq $variable1) && $variable2){
print "Seems to work...\n";
}
KimS
------------------------------
Date: Sat, 7 Aug 1999 12:04:08 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: The IF and AND commands
Message-Id: <7ohjcv$nem$1@plonk.apk.net>
Everymans Wine wrote in message ...
>Hi,
>
>I'm trying to write a CGI script in perl and have hit a stumbling block -
>what I want to write is:
>
>If ($this_variable 'is equal to' $variable1 'and' $variable2)
is equal is relevant if it is a string or numeric. numeric uses == and
string uses eq
if ($this_string eq $string1 && $this_string eq $string2) {do this};
if ($this_number == $number1 && $this_number == $number2) {do this};
>so is it possible to use 'and' in an if statement? Does anyone else have
>another way round this problem?
>
>Many thanks in advance,
>Peter.
Peter, you need to read the FAQ's and manuals!
Look at Perl Scalar Operators & String Operators.
perldoc perldata or man perldata
perldoc perlop or man perlop
Jody
------------------------------
Date: 7 Aug 1999 00:30:31 GMT
From: Hong Yuan <hongy@panther.cs.ucla.edu>
Subject: what does this warning mean ?
Message-Id: <7ofun7$eto$1@news.cs.ucla.edu>
Hi,
I came across a warning message and had no idea what it means. I
stripped away the rest of the code and got this minimal script that
still produces the warning:
perl -we 'open(F,"z"); my $line; while ($line=<F>){} close F'
Warning: Value of <HANDLE> construct can be "0"; test with defined() at
-e line 65535.
If I change the "while" line to: while (<F>){}
The warning would disappear.
This is on perl version 5.004_04 built for sun4-solaris.
Any idea?
Thx!
Hong.
------------------------------
Date: 7 Aug 1999 06:28:27 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: what does this warning mean ?
Message-Id: <37ac266b@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, Hong Yuan <hongy@panther.cs.ucla.edu> writes:
:Warning: Value of <HANDLE> construct can be "0"; test with defined() at
:This is on perl version 5.004_04 built for sun4-solaris.
:Any idea?
It's a spurious warning trying to scare you into wraping a defined()
around the whole assignment. Upgrade to 5.005 or better you'll be fine.
--tom
--
Besides, REAL computers have a rename() system call. :-)
--Larry Wall in <7937@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 07 Aug 1999 13:36:30 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Win32 Perl 'alarm()' substitution?
Message-Id: <19990807093630.04904.00005333@ng-cl1.aol.com>
Hi Thomas:
> I just came accross this searching for exactly what you're asking
>about.. In my case, I have a Perl/Tk program that I need to have poll
>something ever once and a while, and I can't for the life of me figure
>out what I'm going to need to do.. Every several seconds I need to be
>able to call 'Process(1)' on my object, and well, I can't.. :-{
What you quoted is unrelated to the question you asked. You
want to poll something periodically. In Perl/Tk you do that with
a callback and a timer. There is an example at:
http://members.aol.com/bbirthisel/demo7.txt
That one polls a serial port (using the "after" method to reset
the timer).
The quote you used concerns aborting hung system calls. Not
usually a factor in well written Perl/Tk programs which avoid all
blocking calls if possible and certainly all lengthy ones.
-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)
------------------------------
Date: Sat, 07 Aug 1999 05:23:30 -0600
From: Bob Klein and Brian Favel <voyeur@istar.ca>
Subject: windows executable
Message-Id: <37AC1732.E60D5FDE@istar.ca>
Is there a way to start a Windows executable from a Perl program running
under linux?
Oh, and excuse me if this sounds like blasphemy to some of you!
------------------------------
Date: Fri, 6 Aug 1999 22:47:47 +1000
From: "Kim Saunders" <kims@emmerce.com.au>
Subject: Re: windows executable
Message-Id: <934030046.596652@draal.apex.net.au>
>Is there a way to start a Windows executable from a Perl program running
>under linux?
Umm... this has exacltly what to do with perl? So, what, it was written in
perl. Still, you do it the same way as you do a proggy written in C++. But
you wouldn't ask that in a C++ ng.
You can try your luck with wine or dosemu, but basically this is a linux
question, not a perl one, so ask in a linux ng. Dunno why you wouldn't just
interpret the source with perl
>Oh, and excuse me if this sounds like blasphemy to some of you!
Perl is a multi-platform language, therefore we don't care. People use perl
on MacOS, doze, linux, etc...
KimS
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 414
*************************************