[11532] in Perl-Users-Digest
Perl-Users Digest, Issue: 5132 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 14 15:07:18 1999
Date: Sun, 14 Mar 99 12:00:31 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 14 Mar 1999 Volume: 8 Number: 5132
Today's topics:
[Q] Popping an array element <cfwu@slugger.ee.nthu.edu.tw>
Re: Alias for object methods? (Charles DeRykus)
Re: Another woeful flock post (M.J.T. Guy)
Re: Can't Increment Counter in FILE Using http:// (George Crissman)
Re: CGI.pm param persistence question (Bill Moseley)
Re: debugger mystery... (Andrew M. Langmead)
deleting an array of words from a string (Jason Q.)
Re: deleting an array of words from a string (M.J.T. Guy)
Re: Deleting the rest of the line... (brian d foy)
Re: FAQ 3.21: How can I hide the source for my Perl pro (David H. Adler)
Re: FAQ 3.21: How can I hide the source for my Perl pro (John Moreno)
HELP!! dccobb@yahoo.com
Re: HELP!! (Mike Bristow)
Re: HELP!! (Tad McClellan)
HELP: #$ARGV is -1 <paulhadley@earthlink.net>
Re: HELP: #$ARGV is -1 <msholund@bigfoot.com>
Re: HELP: #$ARGV is -1 (brian d foy)
Re: HELP: #$ARGV is -1 (Bart Lateur)
Re: HELP: #$ARGV is -1 (Tad McClellan)
Re: How can I change the 2-dimension array value? (brian d foy)
Identifier on Perl <cyril@ubik.crbm.cnrs-mop.fr>
loading code only if it is needed <khowe@performance-net.com>
Re: loading code only if it is needed (brian d foy)
mod_perl vs fast cgi <frodefi@ifi.uio.no>
Perl and JavaScript <cyril@crbm.cnrs-mop.fr>
Re: Perl and JavaScript <alex@kawo2.rwth-aachen.de>
RAD or WYSIWIG for Perl ??? <stevo@steve.com>
Re: Regex $1 behavior (brian d foy)
Re: Search engine question. <staffan@ngb.se>
searching a flat file database <winfieldh@mindspring.com>
Sendmail and Cc: field <nsurfer@bellsouth.net>
Re: Sendmail and Cc: field (brian d foy)
Re: Sendmail and Cc: field (Mike Bristow)
Re: Sendmail and Cc: field (Bill Moseley)
Re: Sendmail and Cc: field (brian d foy)
use and require compile time and runtime <khowe@performance-net.com>
Re: use and require compile time and runtime <pmoore@interaccess.com>
Re: Why 'use CGI' syntax works offline but not online? <unspam@codegeek.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Mar 1999 17:14:25 GMT
From: Chi-Feng Wu <cfwu@slugger.ee.nthu.edu.tw>
Subject: [Q] Popping an array element
Message-Id: <7cgqph$2rq$1@news.ee.nthu.edu.tw>
The Book tell us that
$tmp = pop ARRAY
has the same effect as
$tmp = $ARRAY[$#ARRAY--];
But why I just get an undefined $tmp while I use the second
method? Well, like this:
@bugs = qw/Flik Atta Hopper/;
print @bugs, $/;
$bugger = $bugs[$#bugs--];
print $bugger, $/;
then $bugger gets undef.
------------------------------
Date: Sun, 14 Mar 1999 19:04:14 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Alias for object methods?
Message-Id: <F8LMB2.9sv@news.boeing.com>
In article <36E98732.8C4B4277@harp.gsfc.nasa.gov>,
Larry Rosen <lrosen@harp.gsfc.nasa.gov> wrote:
>Is there a way to alias a method, perhaps using
>a typeglob?
>
>I've tried things like:
> my *func2 = *func1;
>>>> Can't declare ref-to-glob cast.
> my *func2 = *&func1;
>>>> Can't declare ref-to-glob cast, and Bareword error.
>
>I know I can do the following:
>
>sub func2 {
> $self = shift;
> $self->func1(@_);
>}
>
>but I was wondering if I could do it with an alias.
>
Not really except for trivial methods which don't rely on
the object state, e.g., something like the C<header> method
of CGI.pm. Of course, there's hardly any advantage to doing
this.
use CGI;
...
*ptr = *CGI::header;
print &ptr;
but, in other cases, you'll need a closure. Here's Tom C's
prepublished Perl Cookbook (11.8) explanation on the subject:
hth,
--
Charles DeRykus
Problem: You want to store a reference to a method.
Solution: Create a closure that makes the proper method call on the
appropriate object.
Discussion
The best way to do this is to first realize that when you ask for a
reference to a method, you're asking for more than just a raw function
pointer. You also need to record the precise object the method is to
be called upon. That means the best way to do this is using a closure.
$mref = sub { $obj->meth(@_) };
# later...
$mref->("args", "go", "here);
Even when $obj goes out of scope, the closure stored in $mref has
captured it, so when later called indirectly, all works out.
Be aware that the notation:
$sref = \$obj->meth;
Doesn't do what you were probably expecting. It first calls the
method on that object and gives you a reference to the return value,
or a reference to the last of the return values if the method returns
a list.
The `can()' method from the UNIVERSAL base class, while appealing,
is also unlikely to produce what you want.
$cref = $obj->can("meth");
This produces is a code ref to the appropriate method (should one be
found), one which carries no object information. Think of it as a raw
function pointer. The information about the object is lost. That's
why you need a closure to capture both the object state as well as
the method to call.
Tom Christiansen tchrist@jhereg.perl.com
------------------------------
Date: 14 Mar 1999 16:44:35 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Another woeful flock post
Message-Id: <7cgp1j$7bn$1@pegasus.csx.cam.ac.uk>
In article <7cg8rd$fd8$1@nnrp1.dejanews.com>, <shanx24@my-dejanews.com> wrote:
>_____________________CODE__________________________
>
>#!/usr/local/bin/perl5.00502 -w
>use fcntl ':flock';
>
>open(db, ">>data.txt") or die "Please call the experimenter: $!\n";
> flock(db, LOCK_EX);
> seek(db, 0, 2);
> print db "Hi there\n";
>close db;
>
>print "record written";
>
>____________________/CODE_______________________
>
>I am using Perl5.00502 and Sun OS "something.6" version... SYS command returns
>Sun4x_55 though I was told that it is a new enough version of SunOS to support
>file locks and stuff. So thats that.
Oh no you aren't! The following are Perl4 error messages.
>-----------------
>syntax error in file last2.cgi at line 2, next 2 tokens "use fcntl"
>syntax error in file last2.cgi at line 4, next 2 tokens ") or"
>Execution of last2.cgi aborted due to compilation errors.
>-----------------
And before you do try it with Perl5, correct the case of "fcntl" to
"Fcntl".
Otherwise, it looks like it ought to work.
Mike Guy
------------------------------
Date: Mon, 15 Mar 1999 18:00:37 GMT
From: strads@tmisnet.com (George Crissman)
Subject: Re: Can't Increment Counter in FILE Using http://
Message-Id: <36ed4811.8398427@news2.tmisnet.com>
On 12 Mar 1999 15:41:38 GMT, (Abigail) wrote:
>George Crissman (strads@tmisnet.com) wrote on MMXIX September MCMXCIII in
><URL:news:36e88bb1.12273154@news2.tmisnet.com>:
>`` I thought maybe Perl worked differently when called by a
>`` browser as compared to the command line.
>Of course not. That would be stupid. Besides, Perl cannot know whether
>it's called from a browser.
It turns out that "stupid" (while a bit strong) was accurate. I
changed the reference to the file from "relative" to "absolute"
and solved the problem.
Thanks!
-- George Crissman
-- strads@tmisnet.com
-----------------------------------------------------------------------
"There is no need to criminalize millions of legitimate and responsible
businesses and individuals in order to stop a very small group of
irresponsible people, particularly when there are other ways already
working ." says Mr. Dan Hufnal of the 10,000 member DEAA
<http://www.deaa.com>. What does he mean by "already working"?
Maybe: <http://www.tmisnet.com/~strads/spamhunt/index.html>
-----------------------------------------------------------------------
------------------------------
Date: Sun, 14 Mar 1999 10:45:05 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: CGI.pm param persistence question
Message-Id: <MPG.1155a390c69cffb99896d9@206.184.139.132>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <7cbflj$67n$1@nnrp03.primenet.com>, chogan@primenet.com
says...
> Well, I just read the latest CGI.pm manpage and apparently in version
> 2.0 and later the author decided to force you to change the value
> because it works better with shopping carts. He says to do:
>
> $Query->param('myvariable', 'myvalue');
> $Query->hidden('myvariable');
>
> Which is pretty much what you said. But it doesn't work for me! I
> have to do delete.
Do you think
print $Query->hidden(-name=>'myvariable',
-value=>'new value',
-override=>1);
might help?
--
Bill Moseley mailto:moseley@best.com
------------------------------
Date: Sun, 14 Mar 1999 17:53:45 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: debugger mystery...
Message-Id: <F8LJ1M.M5u@world.std.com>
John Chambers <john.chambers@gte.com> writes:
>Matthew O. Persico wrote:
>> This mostly happens with loops. You hit the loop top and the next step
>> takes you to the first executable line past the loop bottom. It's
>> annoying, but it is not harmful. If you really have a problem with it,
>> report it as a bug. The docs that come with perl tell you how. Try
>> perldoc perlbug.
>Not harmful? It makes the debugging session utterly worthless
>and a waste of time. When it happens, I have to abandon the
>debugger and start adding print statements. If this isn't
>harmful (to the task of getting the code working), then what
>would qualify?
Although the debugger shows perl at the statement after the brace, it
does not get executed. It doesn't make the debugging session "utterly
worthless" and doesn't waste your time beyond the amount that it takes
to hit the enter key again.
I guess I never worried about it. I've dealt with compilers that would
move conditional tests to the bottom of the loop (with an initial jump
to the bottom so that the conditional would execute first) and
debuggers that showed the true order of execution. When I saw perl do
this, I assumed that it was something similar.
--
Andrew Langmead
------------------------------
Date: Sun, 14 Mar 1999 16:21:32 GMT
From: pigs_can_fly@mindless.com (Jason Q.)
Subject: deleting an array of words from a string
Message-Id: <36ebde67.7410602@news.cyberway.com.sg>
Hi,
There are certain words that I would like to be taken out of a string
as below:
----------------------------------------
@ignore = (i, am, a);
$string = "a boy am i";
-----------------------------------------
Currently, I'm using this simple (and wrong) method
----------------------------------------
foreach (@ignore)
{
$string =~ s/^$_ //g;
$string =~ s/ $_ //g;
$string =~ s/ $_$//g;
}
-----------------------------------------
which will fail if the words to be ignored happen to be next to each
other because after stripping away " am " (note the spaces), "i" will
not be recognised because the " " (space) before "i" is already
stripped away.
Would I be able to achieve this is in just one line, perhaps in the
following format:
$string =~ s/(all the words of be stripped)//g;
I hope I have described my problem clearly. Any help would be
appreciated.
Thanks
Jason Q.
------------------------------
Date: 14 Mar 1999 16:54:06 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: deleting an array of words from a string
Message-Id: <7cgpje$7si$1@pegasus.csx.cam.ac.uk>
Jason Q. <pigs_can_fly@mindless.com> wrote:
>There are certain words that I would like to be taken out of a string
>as below:
>
>----------------------------------------
>
>@ignore = (i, am, a);
>
>$string = "a boy am i";
>
>-----------------------------------------
You need the \b escape. Try
$string =~ s/\b(?:i|am|a)\b//g;
Of course, that'll remove the words but not the adjacent spaces.
Adjust as required.
Mike Guy
------------------------------
Date: Sun, 14 Mar 1999 13:19:24 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Deleting the rest of the line...
Message-Id: <comdog-ya02408000R1403991319240001@news.panix.com>
In article <36ebd042.8366911@news.cybernex.net>, gertyk@mail.cybernex.net posted:
> On Sat, 13 Mar 1999 06:52:16 -0500, tadmc@metronet.com (Tad McClellan)
> wrote:
> >David Falconer (webmaster@guestcities.com) wrote:
> >: In a text file I have, I want to delete all characters after a certain
> >: occurance of a word.
> >: So each time it comes across the word TRUCK it deletes all characters after
> >: that for the rest of the line.
> > s/\bTRUCK\b.*/TRUCK/; # leave FIRETRUCK alone
> Try this:
> @lines=("Something TRUCK something else\n",
> "TRUCK nothing before\n",
> "Nothing after TRUCK\n",
> "This has TRUCK two TRUCK times!\n");
> foreach $line(@lines){
> $line=~/(.*\bTRUCK)\b.*/; #<---- Here is the Regex
> print $1."\n";
> }
did you try that with the last string in your test data? Tad's
example works much better. but there is always more than one way
to do it:
@lines=("Something TRUCK something else\n",
"TRUCK nothing before\n",
"Nothing after TRUCK\n",
"This has TRUCK two TRUCK times!\n");
foreach my $line (@lines)
{
substr($line, index($line, 'TRUCK')) = 'TRUCK';
print "$line\n";
}
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: 14 Mar 1999 12:12:23 -0500
From: dha@panix.com (David H. Adler)
Subject: Re: FAQ 3.21: How can I hide the source for my Perl program?
Message-Id: <slrn7enrfm.dad.dha@panix.com>
On Fri, 12 Mar 1999 09:20:34 -0500, John Moreno <planb@newsreaders.com> wrote:
>Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
>
>> John Moreno <planb@newsreaders.com> wrote:
>>
>> > Tom Christiansen <perlfaq-suggestions@perl.com> wrote:
>> >
>> > > Security through obscurity, the name for hiding your bugs instead of
>> > > fixing them, is little security indeed.
>> >
>> > This isn't true. All security is through obscurity -- it's always about
>> > limiting access to something.
>>
>> Not at all. Limiting access is not the same as obscurity.
>
>Limiting access to information is.
Perhaps. Nevertheless, the use of 'obscurity' here strikes me as more
its use as 'not readily understood or clearly expressed', rather than
literally hidden (i.e. w/limited access). Maybe I'm wrong, but I was
always under the impression that the 'security through obscurity'
comment on code referred to making one's code difficult to understand,
rather than limiting access to it.
P'rspective 'R' us...
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Your point being..." - Homer Simpson
------------------------------
Date: Sun, 14 Mar 1999 14:53:29 -0500
From: planb@newsreaders.com (John Moreno)
Subject: Re: FAQ 3.21: How can I hide the source for my Perl program?
Message-Id: <1dontki.fqf356cumg29N@roxboro0-0009.dyn.interpath.net>
David H. Adler <dha@panix.com> wrote:
> >Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
> >
> >> John Moreno <planb@newsreaders.com> wrote:
> >>
> >> > Tom Christiansen <perlfaq-suggestions@perl.com> wrote:
> >> >
> >> > > Security through obscurity, the name for hiding your bugs
> >> > > instead of fixing them, is little security indeed.
> >> >
> >> > This isn't true. All security is through obscurity -- it's always about
> >> > limiting access to something.
> >>
> >> Not at all. Limiting access is not the same as obscurity.
> >
> >Limiting access to information is.
>
> Perhaps. Nevertheless, the use of 'obscurity' here strikes me as more
> its use as 'not readily understood or clearly expressed', rather than
> literally hidden (i.e. w/limited access). Maybe I'm wrong, but I was
> always under the impression that the 'security through obscurity'
> comment on code referred to making one's code difficult to understand,
> rather than limiting access to it.
>
> P'rspective 'R' us...
You're right that is probably what is intended, I'm just saying that if
that's what is meant, that is what should be said. "Security through
obscurity" makes a nice rhyme and may be easy to remember but IMO that
isn't sufficient reason to use it -- it's incorrect unless
qualified/explained, and it'd be simpler and better to just give the
correct explanation in the first place.
--
John Moreno
------------------------------
Date: Sun, 14 Mar 1999 16:31:00 GMT
From: dccobb@yahoo.com
Subject: HELP!!
Message-Id: <7cgo84$r61$1@nnrp1.dejanews.com>
Can anybody help me please, I need to restrict access to certain files
e.g. .log files.
What do I need to do to restrict access to these files through
the apache conf files??
Cheers, Dave
"Everything should be as simple as possible, but no simpler",
Albert Einstein.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sun, 14 Mar 1999 18:52:16 GMT
From: mike@fat.dotat.at (Mike Bristow)
Subject: Re: HELP!!
Message-Id: <slrn7eo1b0.79n.mike@lindt.fat.dotat.at>
On Sun, 14 Mar 1999 16:31:00 GMT, dccobb@yahoo.com <dccobb@yahoo.com> wrote:
>Can anybody help me please, I need to restrict access to certain files
>e.g. .log files.
>
>What do I need to do to restrict access to these files through
>the apache conf files??
You will probably find people able to answer this question
elsewhere. My guess would be comp.infosystems.www.servers.unix,
but I don't read that group so could well be wrong. Read the
group before posting to found out if my guess is correct.
--
We are Pentium of Borg. Division is futile. You will be approximated.
(seen in someone's .signature)
------------------------------
Date: Sun, 14 Mar 1999 08:32:23 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HELP!!
Message-Id: <7pdgc7.if1.ln@magna.metronet.com>
dccobb@yahoo.com wrote:
: Subject: Re: HELP!!
You should put the subject of your post in the Subject:
header of your post.
: Can anybody help me please, I need to restrict access to certain files
: e.g. .log files.
: What do I need to do to restrict access to these files through
: the apache conf files??
This is the Perl newsgroup.
We discuss Perl things here.
Do you have a Perl question?
Sounds like you meant to ask in some newsgroup that is
connected in some way to WWW things.
This is not one of those newsgroups.
comp.infosystems.www.servers.mac
comp.infosystems.www.servers.misc
comp.infosystems.www.servers.ms-windows
comp.infosystems.www.servers.unix
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 13 Mar 1999 23:56:15 +0000
From: Paul Hadley <paulhadley@earthlink.net>
Subject: HELP: #$ARGV is -1
Message-Id: <36EAFB1F.22737C60@earthlink.net>
Hi, I'm drinving NT and pulling my hair out. I can't get seem to get
arguments from the command line into my perl scripts; @ARGV
has a length of -1!
Has anyone encountered this problem? Do you have any suggestions?
Thank you very much for your help.
Scott Selberg
------------------------------
Date: Sun, 14 Mar 1999 12:53:48 -0500
From: Mark Sholund <msholund@bigfoot.com>
Subject: Re: HELP: #$ARGV is -1
Message-Id: <36EBF7AC.C71A9373@bigfoot.com>
Perhaps it's just a typing error, but the length of @ARGV is found in
$#ARGV not #$ARGV. If the code segment is short, post it; it will make
it easier to diagnose.
Paul Hadley wrote:
> Hi, I'm drinving NT and pulling my hair out. I can't get seem to get
> arguments from the command line into my perl scripts; @ARGV
> has a length of -1!
>
> Has anyone encountered this problem? Do you have any suggestions?
>
> Thank you very much for your help.
>
> Scott Selberg
------------------------------
Date: Sun, 14 Mar 1999 13:07:10 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: HELP: #$ARGV is -1
Message-Id: <comdog-ya02408000R1403991307100001@news.panix.com>
In article <36EAFB1F.22737C60@earthlink.net>, Paul Hadley <paulhadley@earthlink.net> posted:
> Hi, I'm drinving NT and pulling my hair out. I can't get seem to get
> arguments from the command line into my perl scripts; @ARGV
> has a length of -1!
sounds like there is nothing in @ARGV. hard to tell what the problem
is without a snippet of code.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 14 Mar 1999 19:14:34 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: HELP: #$ARGV is -1
Message-Id: <36ec0a09.664098@news.skynet.be>
Paul Hadley wrote:
>Hi, I'm drinving NT and pulling my hair out. I can't get seem to get
>arguments from the command line into my perl scripts; @ARGV
>has a length of -1!
If you're saying that $#ARGV is -1, this means that @ARGV is (), or 0 in
scalar context. No array elements.
scalar @ary is: number of array elements
$#ary is: index of last array element
and if $[ is 0, the default (and preferably you don't tamper with that),
$#ary is always one less than scalar @ary .
HTH,
Bart.
------------------------------
Date: Sun, 14 Mar 1999 08:28:04 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HELP: #$ARGV is -1
Message-Id: <4hdgc7.if1.ln@magna.metronet.com>
Mark Sholund (msholund@bigfoot.com) wrote:
: Perhaps it's just a typing error, but the length of @ARGV is found in
: $#ARGV not #$ARGV.
No it *isn't*.
It is not.
$#array is not the length of the array.
It just isn't.
Strange that this same wrong thing has been said about 4
times in the last day or two...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 14 Mar 1999 13:03:02 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: How can I change the 2-dimension array value?
Message-Id: <comdog-ya02408000R1403991303020001@news.panix.com>
In article <36EB7A88.19DAF534@hongkong.com>, Aaron Au <au_aaron@hongkong.com> posted:
> I want to change the $array[0][0] to '8'.
$array[0][0] = '8'
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 14 Mar 1999 17:55:19 +0100
From: "Cyril Sarrauste de Menthihre" <cyril@ubik.crbm.cnrs-mop.fr>
Subject: Identifier on Perl
Message-Id: <36EBE9F6.226CF4B7@ubik.crbm.cnrs-mop.fr>
Hi
I use the CGI. pm library, bur i got a little problem ...
I want to include a Javascript on my perl file like :
$JSCRIPT=<<STOP;
# ....
STOP
;
# ....
print $q->start_html(-title=>'Recherche',
-BGCOLOR=>'white',
-xbase=>$ighref,
-script=>$JSCRIPT);
#.....
But it's always the same error message :
Can't find string terminator "STOP" anywhere before EOF at line
"$JSCRIPT=<<STOP;"
So is there a way to define at the begining of the file an identifier
(STOP in this exemple) ???
Thanks for your help.
Cyril.
(cyril@crbm.cnrs-mop.fr)
------------------------------
Date: Sun, 14 Mar 1999 13:14:14 -0400
From: "Kevin Howe" <khowe@performance-net.com>
Subject: loading code only if it is needed
Message-Id: <q7SG2.13205$134.128694@tor-nn1.netcom.ca>
Hi, I have done much research on modules and namespaces and so on, but all
the information I've found seems to dodge the answer I'm looking for.
I have a program made up of 40 subroutines. This program has 4 different
functions/uses and each use uses only 10 of the subroutines.
What I want is to ensure that ONLY THE CODE THAT IS NEEDED GETS LOADED.
Right now when the program is used, all 40 of the subroutines will get read
into memory, despite the fact that I only need about 10 of them.
The only way I can figure to do what I want is to keep each sub in a
separate file, and then OPEN and DO the code when needed. Can anybody help
me?
The reason I am doing this is for speed, am I wrong in assuming that this
would increase the speed?
Any help would be much appreciated,
Thanks,
Sincerely,
Kevin Howe
P.S. Could you please respond by email, I will post the solution to the
problem once it is resolved.
------------------------------
Date: Sun, 14 Mar 1999 13:06:23 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: loading code only if it is needed
Message-Id: <comdog-ya02408000R1403991306230001@news.panix.com>
In article <q7SG2.13205$134.128694@tor-nn1.netcom.ca>, "Kevin Howe" <khowe@performance-net.com> posted:
> Hi, I have done much research on modules and namespaces and so on, but all
> the information I've found seems to dodge the answer I'm looking for.
>
> I have a program made up of 40 subroutines. This program has 4 different
> functions/uses and each use uses only 10 of the subroutines.
sounds like a job for the Autoloader (or Selfloader)
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 14 Mar 1999 19:35:59 +0100
From: "Frode Fikke" <frodefi@ifi.uio.no>
Subject: mod_perl vs fast cgi
Message-Id: <7cgvj8$lng$2@elle.eunet.no>
I have some Perl-scripts that uses too much resources on a webserver (lots
of users and all the pages comes from perl-scripts).
mod_perl and fast cgi are two methods to solve my problems. What is the best
with regard to speed and resources, and what is the quickest/easiest to
implement?
Thanx!
-Frode
------------------------------
Date: Sun, 14 Mar 1999 18:19:05 +0100
From: "Cyril Sarrauste de Menthihre" <cyril@crbm.cnrs-mop.fr>
Subject: Perl and JavaScript
Message-Id: <36EBEF88.19CEF562@crbm.cnrs-mop.fr>
Hi
I use the CGI. pm library, but i got a little problem ...
I want to include a Javascript on my perl file like :
$JSCRIPT=<<STOP;
# ....
STOP
;
# ....
print $q->start_html(-title=>'Recherche',
-BGCOLOR=>'white',
-xbase=>$ighref,
-script=>$JSCRIPT);
#.....
But it's always the same error message :
Can't find string terminator "STOP" anywhere before EOF at line
"$JSCRIPT=<<STOP;"
So is there a way to define at the begining of the file an identifier
(STOP in this exemple) ???
Thanks for your help.
Cyril.
(cyril@crbm.cnrs-mop.fr)
------------------------------
Date: Sun, 14 Mar 1999 19:47:47 -0500
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: cyril@crbm.cnrs-mop.fr
Subject: Re: Perl and JavaScript
Message-Id: <36EC58B2.14785AAC@kawo2.rwth-aachen.de>
Hi!
"Cyril Sarrauste de Menthihre" wrote:
> $JSCRIPT=<<STOP;
> # ....
> STOP
> ;
^^^ remove this ;
> But it's always the same error message :
> Can't find string terminator "STOP" anywhere before EOF at line
> "$JSCRIPT=<<STOP;"
/Alex
--
http://www.simplex.ru/pref.html
------------------------------
Date: Sun, 14 Mar 1999 11:13:11 -0500
From: "Steve Davis" <stevo@steve.com>
Subject: RAD or WYSIWIG for Perl ???
Message-Id: <7cgn67$qkb$1@samsara0.mindspring.com>
RAD or WYSIWIG for Perl ???
Does it exist??
Steve
------------------------------
Date: Sun, 14 Mar 1999 13:10:32 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Regex $1 behavior
Message-Id: <comdog-ya02408000R1403991310320001@news.panix.com>
In article <36ebdb60.11212870@news.cybernex.net>, gertyk@mail.cybernex ADD .net posted:
> Try this:
>
> $address = "127.0.0.1";
> $address =~ s/((\d+\.)+)\d+/\1/;
> print $address;
>
you should try this:
#!/usr/bin/perl -w
$address = "127.0.0.1";
$address =~ s/((\d+\.)+)\d+/\1/;
print $address;
so that you'd see this warning:
\1 better written as $1 at test.pl line 4.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 14 Mar 1999 17:05:12 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Search engine question.
Message-Id: <36EBDE38.53A87308@ngb.se>
Anonymous wrote:
>
> Sorry for the wrong title in the last post...
Actually, it was pretty funny. Interesting typo.
> I use this perl script below to search in an image database its a
> simple search script that will return all lines where the search word
> is contained
> This works fine but I would like the modify the script so the result
> will be returned like this:
>
> <tr><td>1. Line</td><td>2. Line</td><td>3. line</td></tr>
> <tr><td>4. Line</td><td>5. Line</td><td>6. line</td></tr>
> <tr><td>1. Line</td><td>2. Line</td><td>3. line</td></tr>
> and so on...
you should take the number of the result mod 3 (% 3) and do the correct
thing thereafter. If you look at the code, look in the manuals and fool
around a bit, you should be able to accomplish it with a simple if
statement. If you don't, mail me for my rates.
Staffan
------------------------------
Date: Sun, 14 Mar 1999 14:15:44 -0500
From: "Winfield Henry" <winfieldh@mindspring.com>
Subject: searching a flat file database
Message-Id: <7ch1n6$b0c$1@camel15.mindspring.com>
Hello all,
Its been a while since I've done any programming (15years), but a buddy of
mine has convinced to learn Perl and do some side work for him. I'll have to
say Perl is really a neat language and I am enjoying learning it.
I have made a great perl/cgi script to search and ascii txt file '|'
delimited. Works great using a single word/phrase search key. What I need to
be able to do is break up the search key and search for the words
individually. Heres an example using cars. the database would look like
year|make|model|color
The input search string would be
'1990 ford explorer'
I need to break up the search string into '1990' 'ford' 'explorer' and (I
think) loop through each record however many times there are items in the
search string to match them all/partial. Its the breaking up of the search
string that I'm having difficulties with. Here is the beginning part of the
code so that you can see how things are coming from the html form.
use CGI qw /:standard :html3/;
$query = new CGI;
$datafile = "inns2.txt";
$search = $query->param('search');
if($search eq ""){$search = ".";}
&Do_Search;
$count=@matches;
&No_Matches if($count == 0);
&Print_Results;
exit;
sub Do_Search{
open(DATAFILE,"$datafile");
while(<DATAFILE>){
if(/$search/i){
push @matches, $_;
} # End of if.
} # End of while.
close(DATAFILE);
return;
} # End of Do_Search subroutine.
I hope I've not made this incomprehensible. Go easy on me, I'm still
learning....Thanks for any help. Winfield
------------------------------
Date: Sun, 14 Mar 1999 17:54:14 GMT
From: Steve Miles <nsurfer@bellsouth.net>
Subject: Sendmail and Cc: field
Message-Id: <36EBF7B8.AC690A1C@bellsouth.net>
Hi all, I'm trying to send email through a perl script using sendmail to
multiple people. I'm trying to use the "Cc:" field but I only get the
email sent to the first person on the list. Is there a sendmail resource
on the web I don't know about? Thanks.
open (MAIL, "|$mailprog $email") || die "Can't open $mailprog!\n";
print MAIL "Subject: $subject\n";
print MAIL "From:$admin_email\n";
print MAIL "Cc:myemai1\@mysite.com\n";
print MAIL "Cc:myemail2\@mysite.com\n";
print MAIL "$message\n";
close (MAIL);
Thanks,
Steve Miles
------------------------------
Date: Sun, 14 Mar 1999 13:41:46 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Sendmail and Cc: field
Message-Id: <comdog-ya02408000R1403991341460001@news.panix.com>
In article <36EBF7B8.AC690A1C@bellsouth.net>, Steve Miles <nsurfer@bellsouth.net> posted:
> Hi all, I'm trying to send email through a perl script using sendmail to
> multiple people. I'm trying to use the "Cc:" field but I only get the
> email sent to the first person on the list. Is there a sendmail resource
> on the web I don't know about? Thanks.
>
> open (MAIL, "|$mailprog $email") || die "Can't open $mailprog!\n";
oi! don't specify the $email address on the command line:
open MAIL, "| /usr/lib/sendmail -oi -odq -t";
print MAIL "To: $email\n";
> print MAIL "Subject: $subject\n";
> print MAIL "From:$admin_email\n";
> print MAIL "Cc:myemai1\@mysite.com\n";
> print MAIL "Cc:myemail2\@mysite.com\n";
all of this can be cleaned up with a here document:
print MAIL <<"HEADER";
To: $email
Subject: $subject
From: $admin_email
Cc: myemai1\@mysite.com,myemail2\@mysite.com
HEADER
don't forget that blank line after the header!
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 14 Mar 1999 19:10:08 GMT
From: mike@fat.dotat.at (Mike Bristow)
Subject: Re: Sendmail and Cc: field
Message-Id: <slrn7eo2ce.79n.mike@lindt.fat.dotat.at>
On Sun, 14 Mar 1999 17:54:14 GMT, Steve Miles <nsurfer@bellsouth.net> wrote:
>Hi all, I'm trying to send email through a perl script using sendmail to
>multiple people. I'm trying to use the "Cc:" field but I only get the
>email sent to the first person on the list. Is there a sendmail resource
>on the web I don't know about? Thanks.
www.sendmail.org is probably a good starting point, however:
>open (MAIL, "|$mailprog $email") || die "Can't open $mailprog!\n";
You probably want to list all the people you want to send to in
$email.
> print MAIL "Cc:myemai1\@mysite.com\n";
> print MAIL "Cc:myemail2\@mysite.com\n";
The meaning of multiple Cc: lines is undefined.
Additionaly, you may find it more convient to use some of the modules
in CPAN - avoid reinventing the wheel!
A quick glance suggests that Mail::Sendmail may be useful.
--
apples have meant trouble since eden
-- Madsen Wikholm
------------------------------
Date: Sun, 14 Mar 1999 11:00:39 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: Sendmail and Cc: field
Message-Id: <MPG.1155a734de13dba79896da@206.184.139.132>
In article <36EBF7B8.AC690A1C@bellsouth.net>, nsurfer@bellsouth.net
says...
> Hi all, I'm trying to send email through a perl script using sendmail to
> multiple people. I'm trying to use the "Cc:" field but I only get the
> email sent to the first person on the list. Is there a sendmail resource
>
> open (MAIL, "|$mailprog $email") || die "Can't open $mailprog!\n";
> print MAIL "Cc:myemai1\@mysite.com\n";
man sendmail and look at the switches to make sendmail look at the CC
header.
Oh, what a lucky guess: http://www.sendmail.org
--
Bill Moseley mailto:moseley@best.com
------------------------------
Date: Sun, 14 Mar 1999 14:52:59 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Sendmail and Cc: field
Message-Id: <comdog-ya02408000R1403991452590001@news.panix.com>
In article <slrn7eo2ce.79n.mike@lindt.fat.dotat.at>, mike@fat.dotat.at (Mike Bristow) posted:
> On Sun, 14 Mar 1999 17:54:14 GMT, Steve Miles <nsurfer@bellsouth.net> wrote:
> >Hi all, I'm trying to send email through a perl script using sendmail to
> >multiple people. I'm trying to use the "Cc:" field but I only get the
> >email sent to the first person on the list. Is there a sendmail resource
> >on the web I don't know about? Thanks.
>
> www.sendmail.org is probably a good starting point, however:
reading about sendmail is not going to solve this problem. it would
take quite awhile to digest all the sendmail trivia before someone
could think to start looking for an answer.
> >open (MAIL, "|$mailprog $email") || die "Can't open $mailprog!\n";
>
> You probably want to list all the people you want to send to in
> $email.
no you don't:
* they would all show up in the To: line, which is messy.
* sendmail treats Cc: just like To:
* you don't want to specify recipients on the command line anyway.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 14 Mar 1999 13:18:04 -0400
From: "Kevin Howe" <khowe@performance-net.com>
Subject: use and require compile time and runtime
Message-Id: <%aSG2.13206$134.130465@tor-nn1.netcom.ca>
The advantage of USE is that it happens at "compile time" instead of "run
time" like REQUIRE does. What the heck is the difference?
What is "compile time" and why is it better?
Kevin
------------------------------
Date: Sun, 14 Mar 1999 13:44:58 -0600
From: "Peter Moore" <pmoore@interaccess.com>
Subject: Re: use and require compile time and runtime
Message-Id: <7ch46c$gfv$1@remarQ.com>
Kevin Howe wrote in message
>The advantage of USE is that it happens at "compile time" instead of "run
>time" like REQUIRE does. What the heck is the difference?
>What is "compile time" and why is it better?
>
>Kevin
>
>
Im not by any means an expert but "use" uses the code wheather it is
required or not, but "require" uses the code only if it is called directly
or indirectly by your program.
Use therfore could have a higher comlpile time on small programs but as far
as i can see it is easier to write code for objects that have been included
by the "use". Ive seen many programming styles and and im not sure what is
right at this point.
Pete
------------------------------
Date: Sun, 14 Mar 1999 19:46:27 GMT
From: unspam <unspam@codegeek.com>
Subject: Re: Why 'use CGI' syntax works offline but not online?
Message-Id: <nmUG2.6311$fq6.7252215@newsgate.direct.ca>
In comp.lang.perl.modules Changheng Du <duch@cig.mot.com> wrote:
: My CGI scripts once worked with 'use my_needed_mod'. However recently
: they work offline but not online. 'Server Error' message will generate
: when using Online.
: I want to know this is due to Web server or 'use module' or both
: interact?
: Can you help me on this? One more thing: without 'use mod', that is,
: writing everything from scratches is OK. Is it Web server configuration
: problem?
One thing I run into quite regularly is bad Perl installations.
For example, the perl installation consisting of only a copied Perl
executable (no library files or modules), etc. If it works on your
server (which I assume has a full installation) but fails on another
this could be a cause.
Cheers,
~kj
(followups reset to only comp.lang.perl.misc)
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5132
**************************************