[7360] in Perl-Users-Digest
Perl-Users Digest, Issue: 985 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 5 21:17:53 1997
Date: Fri, 5 Sep 97 18:00:27 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 5 Sep 1997 Volume: 8 Number: 985
Today's topics:
Re: "headers" in Perl? <rootbeer@teleport.com>
Re: "Odd number of elements in hash list": So? <rootbeer@teleport.com>
Re: 2-dim arrays help please! (dave)
Re: CGI Will not recognise if or unless statements. <pittelli@ehsct7.envmed.rochester.edu>
Re: complex pattern?!? it shouldn't be, i think :) <pittelli@ehsct7.envmed.rochester.edu>
Difference between a link() and File::Copy <achoy@us.oracle.com>
Re: Does anyone know how to call a perl script with 2 a <robertk@mfg.sgi.com>
Re: Dynmical pattern problem <rootbeer@teleport.com>
Re: how do I redirect the output of an existing perl sc <rootbeer@teleport.com>
Re: How to get keys of array? <merlyn@stonehenge.com>
how to use dbm with PERL? <daftary@cisco.com>
Re: I seem to be missing something obvious with package <rootbeer@teleport.com>
Re: Is it a module, or what? <rootbeer@teleport.com>
Re: Minimizing Memory Needed for Numbers Read from Bina <rootbeer@teleport.com>
Re: multidimensional arrays ? <daftary@cisco.com>
Re: newbie: how do I break a WHILE loop? <rootbeer@teleport.com>
Password Change Using Web and Perl rlitiatc@amgen.com
Re: Perl on win32 book <merlyn@stonehenge.com>
Re: Perl on win32 book <rootbeer@teleport.com>
Re: Programming question (hymie!)
Re: Shakespearian insult program <rootbeer@teleport.com>
Re: Speeding up C preprocessor-like text-substitution s <rootbeer@teleport.com>
Re: unpack <rootbeer@teleport.com>
Re: wee quickie on special variables <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 4 Sep 1997 07:48:36 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Doug Jacobs <djacobs@gilligan.tsoft.net>
Subject: Re: "headers" in Perl?
Message-Id: <Pine.GSO.3.96.970904074402.11084H-100000@julie.teleport.com>
On 4 Sep 1997, Doug Jacobs wrote:
> So far, I've determined that I can do:
>
> require 'My_Header.pl';
>
> Where My_Header.pl is the "header" file in question.
>
> For some reason when the apllication is called in certain environments,
> the header file doesn't seem to impart its information properly :(
Isn't it behaving as documented?
> It doesn't seem to do the path thing properly - yet it doesn't complain,
> it just doesn't work :(
What "path thing" do you mean? It doesn't use your $ENV{PATH}, it uses
@INC - could that be part of the problem? If you're getting an error
message, what is it, and is it found in the perldiag(1) manpage? If you're
not getting an error message, could you post a short example (say, ten
lines) of code which doesn't do what you expect?
I'd be remiss if I didn't point out that perhaps you should consider the
more versatile relative of 'require', which is 'use'. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 5 Sep 1997 16:17:39 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Kingpin <mthurn@irnet.rest.tasc.com>
Subject: Re: "Odd number of elements in hash list": So?
Message-Id: <Pine.GSO.3.96.970905161009.24123S-100000@julie.teleport.com>
On 5 Sep 1997, Kingpin wrote:
> > >With -w and strict turned on, perl 5.004 warns me that I have an
> > >"Odd number of elements in hash list".
> >
> > This happens when you try to assign a list with an odd number of
> > elements to a hash
>
> Unfortunately, it also gives this warning if you assign undef to a
> hash. What's wrong with that? What's even potentially wrong with that?
>
> %hash = undef;
What's even potentially right with that? :-) I think you meant this,
which is substantially different.
undef %hash;
> Similarly, an array which has been assigned undef shows a length of
> 1 (versus an empty array, which shows a length of 0):
>
> @a0 = (); print scalar(@a0); # prints 0 as expected
> @a1 = undef; print scalar(@a1); # prints 1! Why?!?
Here's a rule which Perl always uses: When evaluating a scalar value in a
list context, the value is automatically promoted to a one-element list.
@foo = 123; # @foo becomes the list (123)
@bar = 'hello world'; # @bar becomes ('hello world')
@baz = \@foo; # @baz becomes a list containing
# one element, which is a
# reference to @foo
@biz = undef; # @biz becomes (undef)
undef is a valid scalar, and Perl treats it like any other. So, that last
line is almost always wrong, and should usually be written like one of
these. (TMTOWTDI.)
undef @biz; # Wipe out @biz
@biz = (); # Empty @biz
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 05 Sep 1997 22:16:05 GMT
From: over@the.net (dave)
Subject: Re: 2-dim arrays help please!
Message-Id: <341082c2.1995809@news.one.net>
robert burditt <rburditt@no.spam.please.fedex.com> wrote:
>I have spent much time reading some perl books trying to figure out
>how to create, fill, and access a 2-dim array. i am aware that
>perl doesn't directly support them, but i've also read that you
I had a little trouble understanding what you are trying to do, but I
think that syntax is:
$arrayref->[$A][$B] = $result;
If the array does not already exist, it springs into existence. I
think that all cells "below" [$A][$B] are set to undef.
Sorry if I misinterpretted your question.
Dave
|
| Please visit me at http://w3.one.net/~dlripber
|
| For reply by email, use:
| dlripber@one.net
|________
------------------------------
Date: Fri, 05 Sep 1997 19:23:49 -0600
From: Randal Pittelli <pittelli@ehsct7.envmed.rochester.edu>
Subject: Re: CGI Will not recognise if or unless statements.
Message-Id: <873504624.21209@dejanews.com>
Try:
if (!defined $Username) {
as first line.
In article <34101EB5.615BCEF8@acay.com.au>,
Dexter Plameras <dexterp@acay.com.au> wrote:
>
>
> Hi
>
> I am having Trouble composing a cgi script in perl with if or unless
> statements.
>
> My System is
> NCSA HTTPd Server 1.5.2
> Free Bsdi 2.1.5
> Perl 5.002
>
> This is the code excert of the code that is causeing the problem.
>
> if(!defined($Username)
> {
> &err("$Param1","$ETC1","ETC2"); # &err Prints a cgi form
> }
>
> When running the Code on the command line it runs fine it produces html
> formatted documents.
>
> But when running the form on the web it returns
>
> 500 Server error
>
> ......etc
>
> When I use this code it runs fine on both the command line and on the
> web.
>
> ### if(!defined($Username)
> ### {
> &err("$Param1","$ETC1","ETC2"); # &err Prints a cgi form
> ### }
>
> I believe it has to do with the logic statements if, unless, elsif,
> ....etc.
>
> Any clues would apprieciated.
> Dexterp Plameras
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Fri, 05 Sep 1997 19:51:05 -0600
From: Randal Pittelli <pittelli@ehsct7.envmed.rochester.edu>
Subject: Re: complex pattern?!? it shouldn't be, i think :)
Message-Id: <873506467.22826@dejanews.com>
>
> <!-- -- -->
> If you see this, you have a buggy browser. Perhaps you should
> <A HREF="http://lynx.browser.org/">upgrade to Lynx</A>?
> <!-- -- -->
>
That's absurd. How could the comment be defined to allow for that text to
be hidden???? There is no rational difference between the 1st and 2nd
`-->`.
-Randy
> But I think that would just upset the 80% of the visitors to my site
> that thought they had a good browser. :-)
>
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Fri, 05 Sep 1997 16:55:12 -0700
From: Allen Choy <achoy@us.oracle.com>
Subject: Difference between a link() and File::Copy
Message-Id: <34109BDF.ACB70B55@us.oracle.com>
Hi.
Can anyone tell me what's the difference of creating a new file via
link() versus using the
File::Copy module?
I'm also not very clear about the concept of hard links.
Thanks,
Allen
------------------------------
Date: Fri, 05 Sep 1997 16:44:56 -0700
From: Robert Kuropkat <robertk@mfg.sgi.com>
Subject: Re: Does anyone know how to call a perl script with 2 arguments in an html file?
Message-Id: <34109978.794A@mfg.sgi.com>
Roxy wrote:
>
> I got a perl script, and I would like to execute the perl script with 2
> arguments from an
> html file as I did in a unix shell.
> Something likes
> perl filename.pl input.txt output.txt
> Could anyone help me?
> TIA,
> --
> --------------------------------------------------
> Roxy
> Get PR-Tracker -- Tracks problem reports (bugs, defects)
> INFORMATION http://www.prtracker.com/info.html
> DOWNLOAD http://www.prtracker.com/download.html
> TECH SUPPORT http://www.prtracker.com/TechSupport.html
>
If what you mean is, you want to be able to click on a link in your html
document and have it execute your perl script you could use the link tag
like so:
<A HREF="./filename.pl?input.txt+output.txt">Click Here</A>
The plus sign gets interpreted as a space and the question mark
seperates the file name from parameters. Your perl script can then pick
up the two values as $ARGV[0] and $ARGV[1]. NOTE: In the above
example, the perl script is in the same directory as the html file. I
believe your web server has to be configured specifically to allow
this. Presumably, this would still work if your perl script is in the
standard cgi-bin directory and the path set appropriatly.
--
---------------------------
"I do have a life! It's backed up on 8 inch floppy in case I ever need
it again!"
------------------------------
Date: Thu, 4 Sep 1997 08:09:36 -0700
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Dynmical pattern problem
Message-Id: <Pine.GSO.3.96.970904075522.11084J-100000@julie.teleport.com>
On 2 Sep 1997, Andreas SLATEFF wrote:
> From: Andreas SLATEFF
<slateff@netway.at.Please.remove.this.I.really.hate.spam>
> Because nobody has answered me so far, I found a brute force solution:
>
> Print "s/.../$e/" in a temorary file and execute it with `perl ...`.
> Ugly.
>
> Isn't there any better solution?
Yes, there is, and I've seen at least one reply to your question posted in
this newsgroup recently; it's also shown up on Deja News.
Clearly, you've mangled your address to keep from getting email replies to
your postings here. If you don't want to get mail, that's understandable,
but I think you've forfeited any right to complain that "nobody has
answered" you. You've merely neglected to read the answers which were
sitting right here in the newsgroup.
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 5 Sep 1997 16:54:49 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Peter Tiemann <peter@preview.org>
Subject: Re: how do I redirect the output of an existing perl script
Message-Id: <Pine.GSO.3.96.970905165351.24123d-100000@julie.teleport.com>
On Fri, 5 Sep 1997, Peter Tiemann wrote:
> Newsgroups: comp.lang.perl, comp.lang.perl.misc
If your news administrator still carries comp.lang.perl, please let him
or her know that that newsgroup has not existed since 1995. If you
have such an outdated newsgroup listing, you are probably missing out
on many other valid newsgroups as well. You'll be doing yourself and
many others a favor to use only comp.lang.perl.misc (and other valid
Perl newsgroups) instead.
> I'd like to redirect the standard output of a perl function that I call.
> (Right now it writes on the screen = in a web page in my particular case)
> I would like to have that function write to a file to be able to process the
> output.
Probably you want the one-argument form of select, documented in the
perlfunc(1) manpage. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 04 Sep 1997 08:27:07 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "Dave Hoyt" <dshoyt@worldnet.att.net>
Subject: Re: How to get keys of array?
Message-Id: <8coh69w14k.fsf@gadget.cscaper.com>
>>>>> "Dave" == Dave Hoyt <dshoyt@worldnet.att.net> writes:
Dave> Tracy,
Dave> Would you be opposed to using a hash for these? It seems like a unique
Dave> definable key almost screams hash table. If you are getting them from a
Dave> file for example:
Dave> while (<INFILE>) {
Dave> ($key, $line) = /^(.*):(.*)$/;
Dave> $MyHash{$key}=$line;
Dave> }
Or even more perverse and wonderful:
%MyHash = map /^(.*?):(.*)/, <INFILE>;
Map rules! (Giving us map-rules as well. :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 362 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Fri, 5 Sep 1997 17:14:08 -0700
From: Kuntal M Daftary <daftary@cisco.com>
Subject: how to use dbm with PERL?
Message-Id: <Pine.GSO.3.96.970905170829.27989A-100000@flipper.cisco.com>
i wanted to use DBM with PERL for makeing a database.
i found some reference about sunctions i can use for that in PERL like
dbmopen and dbmclose. they are supposed to read dbm files. but how do i make
a dbm file in the first place using PERL?
secondly, how do search among the keys of dbm file based on a regex?
eg, i want the dbm entry which has a key matching the following regex:
/^..hellow?b[0-9]*$/
so that the result of the search is something like this:
abhellob234234
bchellowb34234
dohellowb743
---
Kuntal M. Daftary Cisco Systems Inc
Ph: 408 527 9789 170 W. Tasman Dr
daftary@cisco.com San Jose CA 95134
------------------------------
Date: Thu, 4 Sep 1997 07:43:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: I seem to be missing something obvious with packages
Message-Id: <Pine.GSO.3.96.970904072511.11084G-100000@julie.teleport.com>
On 4 Sep 1997, Eli the Bearded wrote:
> This (seems to) work fine, except that '-w' gives me warnings
> that @MyLists::list, et al, is referenced only once from main.
> What am I overlooking?
I saw this happening with somebody else the other day. IMHO, it's an
unnecessary shortcoming in 'use vars' that it can't declare vars in
another package and thereby avoid the "used only once" warning. That is to
say, instead of this...
{
package Mixed::Nuts;
use vars qw($almond $cashew $peanut);
}
...we should be able to use this.
use vars qw(
$Mixed::Nuts::almond
$Mixed::Nuts::cashew
$Mixed::Nuts::peanut );
Either that, or I seem to be missing something obvious... :-)
Until and unless this is fixed, you can use the first form as a
workaround. But before anybody goes to fix it, I'm thinking: If vars.pm
were just a little smarter, wouldn't this line be easier to type and
understand?
use vars qw(package Mixed::Nuts; $almond $cashew $peanut);
Then again, some cans marked "Mixed nuts" actually have spring snakes
inside, and maybe this idea is one of those...
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 5 Sep 1997 16:39:09 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Anagrams of the Word 'A' <jefpin@bergen.org>
Subject: Re: Is it a module, or what?
Message-Id: <Pine.GSO.3.96.970905163639.24123X-100000@julie.teleport.com>
On Fri, 5 Sep 1997, Anagrams of the Word 'A' wrote:
> I am creating a group of functions (factor,prime factor,greatest common
> factor...) and I am putting them into MATH::. Is this put into a module,
> or what?
I don't know; are you doing what it says in the perlmod(1) manpage? (Be
sure that you start with h2xs, since that's really the only way to make
modules.)
> I can incorporate them using a push and require statement,
It would be easier to make them modules, so you can simply 'use' them.
If you want these to be of use to the people of the world, which is a Good
Thing, you should also see what the modules' list on CPAN has to suggest.
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 5 Sep 1997 16:52:45 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Brett Denner <Brett.W.Denner@lmtas.lmco.com>
Subject: Re: Minimizing Memory Needed for Numbers Read from Binary Files
Message-Id: <Pine.GSO.3.96.970905164831.24123c-100000@julie.teleport.com>
On Fri, 5 Sep 1997, Brett Denner wrote:
> open (FH, "< $big_file");
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check of the return value of open.
> $array[$j][$i] = unpack "f", $string;
> This problem with this is that the binary data are converted to a
> string representation before being stored in @array,
Do you mean that you think that the list element is getting both 3.14159
and '3.14159' assigned to it? Whatever gave you that idea? It may be true,
but I don't believe it. :-)
If you're trying to make this list take up less memory, consider using a
tied structure, with some of the array off on disk at any given time. Good
luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 5 Sep 1997 17:16:29 -0700
From: Kuntal M Daftary <daftary@cisco.com>
To: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: multidimensional arrays ?
Message-Id: <Pine.GSO.3.96.970905171526.27989B-100000@flipper.cisco.com>
> Bas van Reek <basvreek@channels.nl> writes:
>
> > Is there a way to create multidimensional arrays in perl. (something
> > like a(10,10) in a lot of other languages)
Yes.
> > could noy find any docs about it ?
search the web for FMTYEWTK
or scourge the CSPAN site for it
Kuntal M. Daftary Cisco Systems Inc
Ph: 408 527 9789 170 W. Tasman Dr
daftary@cisco.com San Jose CA 95134
------------------------------
Date: Fri, 5 Sep 1997 16:06:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "William Wue(2xP)elma(2xN)" <williamw@rooster.igs.deleteTheRooster.net>
Subject: Re: newbie: how do I break a WHILE loop?
Message-Id: <Pine.GSO.3.96.970905160540.24123Q-100000@julie.teleport.com>
On Fri, 5 Sep 1997, William Wue(2xP)elma(2xN) wrote:
> > last CATS; #<========
> If you're going to use a label, you might as well use a goto.
Not so. last is much faster than goto, among other advantages.
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 05 Sep 1997 17:01:53 -0700
From: rlitiatc@amgen.com
Subject: Password Change Using Web and Perl
Message-Id: <34109D71.6745@amgen.com>
I am working on an application to allow users to change their UNIX
password via a web form using a cgi. Has anyone done this before on
Solaris (NIS+)?
------------------------------
Date: 05 Sep 1997 16:35:46 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Re: Perl on win32 book
Message-Id: <8cg1rjuyel.fsf@gadget.cscaper.com>
>>>>> "Scott" == Scott McMahan <scott@lighthouse.softbase.com> writes:
Scott> Jonathan Tracey (jont@uunet.pipex.com) wrote:
Scott> : There is now a perl for win32 book available form O`reilly its a rewrite of
Scott> : the learning perl (llama) book and is very good for NT perl people
Scott> I don't think it is available yet. It's been preannounced.
It's shipping. Otherwise, I wouldn't have my case-o'-author-copies
downstairs right now. Got that just before the Perl Conference.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 360 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Fri, 5 Sep 1997 16:47:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Scott McMahan <scott@lighthouse.softbase.com>
Subject: Re: Perl on win32 book
Message-Id: <Pine.GSO.3.96.970905164627.24123b-100000@julie.teleport.com>
On 5 Sep 1997, Scott McMahan wrote:
> Jonathan Tracey (jont@uunet.pipex.com) wrote:
>
> : There is now a perl for win32 book available form O`reilly
> : its a rewrite of
> : the learning perl (llama) book and is very good for NT perl people
>
> I don't think it is available yet. It's been preannounced.
It's so strongly preannounced that I've held one in my hands and turned
the pages. :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 5 Sep 1997 23:07:49 GMT
From: hymie@lactose.smart.net (hymie!)
Subject: Re: Programming question
Message-Id: <5uq3c5$s3m$1@news.smart.net>
In our last episode, the evil Dr. Lacto had captured our hero,
wolverin@is.usmo.com, who said:
>I also would like to make a script that, when I delete a person, the
>script will redo all the table colors so that they go color one, color
>two, color one, color two, and so forth.
Easy.
Given that:
Color1=xxxxxx (six-digit hex number)
Color2=yyyyyy (six-digit hex number)
ColorMask= (xxxxxx + yyyyyy)
Then
On the first entry in the table,
This_Line_Color = Color1
For each entry in the table,
This_Line_Color = ColorMask - This_Line_Color
..hymie!
http://www.smart.net/~hymowitz * agis customers: e-mail and web service refused
hymie@lactose.smart.net ********** pgp public key: e-mail pgp@lactose.smart.net
===== Unsolicited commercial e-mail spam will be forwarded to postmasters =====
He's neurotic, which is Jewish for "intense." --Cybill
===============================================================================
------------------------------
Date: Fri, 5 Sep 1997 16:36:09 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Eric Anderson <eric@semaphore.com>
Subject: Re: Shakespearian insult program
Message-Id: <Pine.GSO.3.96.970905163245.24123W-100000@julie.teleport.com>
On 5 Sep 1997, Eric Anderson wrote:
> I noticed some room for improvement and some errors like the @column_1[]
> instead of $column_1[]. I often make that mistake and have to scan thru
> my code, searching for @'s and making sure they are not on array-element
> references.
That's the hard way to find those. The easier way is to use -w. The
easiest way is to never type them in in the first place. :-)
Until you're ready to write slices (by which time your habits will be
ingrained and you won't need to worry about this rule) if there's an
at-sign in front and bracket or braces after, it's wrong.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 5 Sep 1997 16:04:44 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Brett Denner <Brett.W.Denner@lmtas.lmco.com>
Subject: Re: Speeding up C preprocessor-like text-substitution subroutine
Message-Id: <Pine.GSO.3.96.970905155658.24123P-100000@julie.teleport.com>
On Fri, 5 Sep 1997, Brett Denner wrote:
> I have a Perl subroutine that does text substitution in a way that is
> similar to the C preprocessor. Namely, it looks for lines of the form:
>
> OLD := new
>
> and replaces every appearance of OLD on subsequent lines with the text
> 'new'.
Is it possible to gather all of the substitutions first? It would be more
convenient. Probably not... :-(
> foreach (@file) {
> # substitute for each defined variable in current line
>
> foreach my $old (@old_text) {
> s/\b$old\b/$new_text{$old}/;
> }
Ack! :-) This has to compile each regular expression again and again for
every line - no wonder it's taking so long!
Let's try this. First, I'll make a pattern which matches the possible OLD
strings. (If you want to enlarge this set, you'll just need to make a
different pattern. But the more non-OLD things which match, the slower it
may get...)
/\b[A-Z_]{3,}\b/
Now, that inner loop is easy to re-write like this.
s[(\b[A-Z_]{3,}\b)]
{
exists($new_text{$1}) ? $new_text{$1} : $1
}ge;
That should be much faster. How does that work for you?
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 5 Sep 1997 16:26:09 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Andrew D. Arenson" <arenson@hen.imgen.bcm.tmc.edu>
Subject: Re: unpack
Message-Id: <Pine.GSO.3.96.970905162054.24123U-100000@julie.teleport.com>
On 5 Sep 1997, Andrew D. Arenson wrote:
> What happens if you try to unpack something which isn't as
> big as you think it is?
>
> Let's say you do:
>
> $newvalue = unpack("L",$value,0,4)
>
> but $value only actually has 2 bytes of data. I think I'm seeing that
> this causes memory problems in other psuedo-random places in one's script.
That shouldn't be a problem, but you _may_ have found a bug in Perl. (I
heard that there was one left. :-) If you can verify it with a short
script using the latest version of Perl, run perlbug to file a bug report.
Or post it here, and somebody will show you where your mistake is. :-)
Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 4 Sep 1997 07:24:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Colin Forde <C.Forde@Queens-Belfast.AC.UK>
Subject: Re: wee quickie on special variables
Message-Id: <Pine.GSO.3.96.970904072333.11084F-100000@julie.teleport.com>
On Wed, 3 Sep 1997, Colin Forde wrote:
> Im getting rid of all duplicates but the path one which
> is the first one appearing in the input stream.
> Any ideas
Have you tried stepping through your code with the debugger, to see where
the unwanted output is coming from? Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 985
*************************************