[11244] in Perl-Users-Digest
Perl-Users Digest, Issue: 4844 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 8 01:07:29 1999
Date: Sun, 7 Feb 99 22:00:20 -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, 7 Feb 1999 Volume: 8 Number: 4844
Today's topics:
Re: Ads script wanted <jjarrett@ecpi.com>
Re: can't call "writeblock" (Ronald J Kimball)
Re: Comments in Perl code <kihn@mindspring.com>
Re: contains? <jcounts@voicenet.com>
Converting a Byte to it's respective bits <ricks@acpub.duke.edu>
Converting a Byte to it's respective bits <ricks@acpub.duke.edu>
Converting a Byte to it's respective bits <ricks@acpub.duke.edu>
Re: CREATING TEXT TABLE (Sam Holden)
Re: CREATING TEXT TABLE (Matthew Bafford)
Re: Device I/O - Never Mind <ken_kuller@adc.com>
Re: Encrypting a password (Martin Vorlaender)
Re: Encrypting a password (Ronald J Kimball)
Re: I want to build shopping-mall..where I can get help <jjarrett@ecpi.com>
Re: impossible configure perl CGI on IIS4? <ricks@acpub.duke.edu>
Installing a Module: Can't find Perl <michael@datahost.com>
mod_perl on Win32 <gobeilb@cadvision.com>
Re: No such file or directory <undefined@undefined.com>
Re: Perl vs. ASP for new project <ssamat@ucsd.edu>
Re: PERL web ring script <jjarrett@ecpi.com>
Re: Program needs compactification (Abigail)
Re: Program needs compactification <uri@home.sysarch.com>
RegExp to substitue a string <reason@shadow.net>
Re: Rencontre Perl de Mtl (David H. Adler)
speed up the DBI/DBD dynamic module loading? (GEMINI)
Re: Syntax checking without "perl -c"? <ljz@asfast.com>
Re: Syntax checking without "perl -c"? <ljz@asfast.com>
Re: Syntax checking without "perl -c"? <rick.delaney@home.com>
Re: testing for scalar/list/array (Ronald J Kimball)
Re: The order of form fields that recieve by cgi progra <jjarrett@ecpi.com>
Re: Viewing remote Perl script before executing (Ronald J Kimball)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 07 Feb 1999 21:11:05 -0500
From: "John T. Jarrett" <jjarrett@ecpi.com>
Subject: Re: Ads script wanted
Message-Id: <36BE47B9.6DBCBDDE@ecpi.com>
have you tried cgi-resources.com yet? Most everyone that has free complete
scripts throws them up there - 100's of 'em.
John
editor@dvar.com wrote:
> Hi All,
>
> I do everything on my website manually & this eats my time...it can be
> easier. Who can help me out on this?
>
> Who knows of an AD script that can give the following:
> 1. An unique id_code for all visitors who wants to place an Ad. They
> could place, delete or edit an Ad with this ID_code.
> All placed ads will be in catagories
>
> 2. All place Ads must be automatically deleted from their respective
> catagory after, let's say, 10 days.
> 3. Of course, I must be in a position to delete unwanted Ads, censoring
>
> Thanks in advance.
> Regards
> Dvar
> http://www.dvar.com
------------------------------
Date: Sun, 7 Feb 1999 23:58:13 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: can't call "writeblock"
Message-Id: <1dmvq9k.rrblwymngr1sN@bay2-469.quincy.ziplink.net>
Dave Webb <dwebb@cvalley.net> wrote:
> $Response->writeblock(0); #First example of the While keyword error
> '80004005'
>
> Can't call method "writeblock" on an undefined value.
>
> ?
Apparently, $Response holds an undefined value. You should figure out
why it is that the value of $Response has not been defined.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 07 Feb 1999 21:12:44 -0700
From: Eric Kihn <kihn@mindspring.com>
Subject: Re: Comments in Perl code
Message-Id: <36BE643C.D5E425A3@mindspring.com>
As a final thought. Has anyone considered how simple it would be to
write a script called deploy.pl that simply
strips all the comments (and even white space if you want) so that the
"user" version is as fast as can be, but the coder get's his comments?
Again I realize this only affects compile time but the disk access can
be a real issue in many user systems. Of course with most of the code
I've seen stripping two lines won't really make a difference ;).
--
Eric Kihn
kihn@mindspring.com
------------------------------
Date: Sun, 7 Feb 1999 23:33:51 -0500
From: "John Counts" <jcounts@voicenet.com>
Subject: Re: contains?
Message-Id: <79lq58$8pr@world6.bellatlantic.net>
look into CGI.pm The documentation included with the module itself is an
excellent introduction to CGI.
BLUESRIFT wrote in message <19990207180525.09188.00001148@ng96.aol.com>...
>Please forgive me. I have been unsuccessful looking for an online or
>downloadable language reference for writing CGI scripts in perl such as one
can
>find at Netscape for the JavaScript language versions. I would greatly
>appreciate a link!!!
>
>In the meantime, I would like to learn how to perform a conditional based
on a
>test of the contents of a query string. Here's as close as I can get on my
own
>without such a reference guide:
>
>if ($ENV{QUERY_STRING} contains "this string") {...}
>
>Thank you
>
>Rob
>
>
------------------------------
Date: Mon, 08 Feb 1999 00:32:44 -0500
From: ricks <ricks@acpub.duke.edu>
Subject: Converting a Byte to it's respective bits
Message-Id: <36BE76FC.BF1AEFCD@acpub.duke.edu>
I'm reading information in from a binary file in bytes (using binmode
and read).
Cool fine and dandy. However, I can't figure out how to break that
information out into its separate bits (I need to be able to read out
the bit values).
--
ricks@duke.edu http://www.duke.edu/~ricks
------------------------------
Date: Mon, 08 Feb 1999 00:24:03 -0500
From: ricks <ricks@acpub.duke.edu>
Subject: Converting a Byte to it's respective bits
Message-Id: <36BE74F3.CF8D1CE2@acpub.duke.edu>
I'm reading information in from a binary file in bytes (using binmode
and read).
Cool fine and dandy. However, I can't figure out how to break that
information out into its separate bits (I need to be able to read out
the bit values).
--
ricks@duke.edu http://www.duke.edu/~ricks
------------------------------
Date: Mon, 08 Feb 1999 00:18:52 -0500
From: ricks <ricks@acpub.duke.edu>
Subject: Converting a Byte to it's respective bits
Message-Id: <36BE73BC.D025470C@acpub.duke.edu>
I'm reading information in from a binary file in bytes (using binmode
and read).
Cool fine and dandy. However, I can't figure out how to break that
information out into its separate bits (I need to be able to read out
the bit values).
--
ricks@duke.edu http://www.duke.edu/~ricks
------------------------------
Date: 8 Feb 1999 02:00:07 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: CREATING TEXT TABLE
Message-Id: <slrn7bsh97.6at.sholden@pgrad.cs.usyd.edu.au>
On Sun, 7 Feb 1999 20:27:59 -0500, John Moreno <phenix@interpath.com> wrote:
>Abigail <abigail@fnx.com> wrote:
>
>> --
>> perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
>> "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
>> "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
>
>What's this supposed to do? with the -we in it gives a error message,
>without it doesn't seem to have any effect.
Outputs JAPH to /dev/tty.
--
Sam
There's no such thing as a simple cache bug.
--Rob Pike
------------------------------
Date: Mon, 08 Feb 1999 02:24:14 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: CREATING TEXT TABLE
Message-Id: <slrn7bsifj.h64.dragons@Server.Network>
On Sun, 7 Feb 1999 20:27:59 -0500, John Moreno <phenix@interpath.com> wrote:
-> Abigail <abigail@fnx.com> wrote:
->
-> > --
-> > perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
-> > "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
-> > "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
->
-> What's this supposed to do? with the -we in it gives a error message,
-> without it doesn't seem to have any effect.
Eh?
I get:
% perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
Just another Perl Hacker
%
Of course you didn't post the error message, so there's no telling what
happened on your end.
--Matthew
------------------------------
Date: Sun, 07 Feb 1999 21:02:04 -0600
From: "Kenneth M. Kuller" <ken_kuller@adc.com>
Subject: Re: Device I/O - Never Mind
Message-Id: <36BE53AB.B66B07B5@adc.com>
Never mind ... I figured out how to solve my problem with POSIX. a
POSIX::read call reads all the data that's waiting and tells me how much
it's got.
---
Kenneth M. Kuller
ken_kuller@adc.com
"Kenneth M. Kuller" wrote:
> I am a novice at Perl, and rapidly running out of patience on a
> particular problem.
> I am working on a program that communicates with a device, and am trying
> to query various status parameters. Its replies are ASCII text without
> any terminator or delimiting character (such as an end-of-line or
> null.) In some instances, the reply is a variable-length list.
>
> Is there a way to tell in Perl whether a device (/dev/...) has any more
> characters waiting? Is there an input function with a timeout, a
> "return all characters" function, an input-available query, or any
> similar function?
>
> ---
> Kenneth M. Kuller
> ken_kuller@adc.com
------------------------------
Date: Sun, 07 Feb 1999 22:31:08 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Encrypting a password
Message-Id: <36be061c.524144494f47414741@radiogaga.harz.de>
Paul Farber (farber@admin.f-tech.net) wrote:
: How do a get an appropiat SALT vale and how does the CRYPT() function get
: called to return the encryped value?
As the salt, you generate 2 random characters, and call crypt() the way it
is described in perlfunc.pod. The salt comes back as the first two characters
in the encrypted password.
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
VMS is today what | work: mv@pdv-systeme.de
Microsoft wants | http://www.pdv-systeme.de/users/martinv/
Windows NT 8.0 to be! | home: martin@radiogaga.harz.de
------------------------------
Date: Sun, 7 Feb 1999 23:58:15 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Encrypting a password
Message-Id: <1dmvqdy.pfotw244p30gN@bay2-469.quincy.ziplink.net>
Paul Farber <farber@admin.f-tech.net> wrote:
> How do a get an appropiat SALT vale and how does the CRYPT() function get
> called to return the encryped value?
The salt appears as the first two characters of the encrypted password.
To test whether an entered password matches the encrypted password:
if ($encrypted eq crypt($password, $encrypted)) {
print "Ok!\n";
} else {
print "Incorrect password.\n";
}
When creating an account and encrypting a password for the first time,
you can use any salt you want, using characters from the set
[a-zA-Z0-9./]:
@chars = ('a' .. 'z', 'A' .. 'Z', 0 .. 9, '.', '/');
$salt = $chars[rand @chars] . $chars[rand @chars];
$encrypted = crypt($password, $salt);
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 07 Feb 1999 21:09:35 -0500
From: "John T. Jarrett" <jjarrett@ecpi.com>
Subject: Re: I want to build shopping-mall..where I can get help?
Message-Id: <36BE475F.D39F46BC@ecpi.com>
This is more of a CGI question; not necessarily perl - yet. The newsgroup to
follow would be comp.infosystems.www.authoring.cgi. The best place for you to
start out looking is at http://www.cgi-resources.com/ They have almost 2000
CGI resources including scripts in perl, C, Tcl - and several shopping mall /
shopping cart programs. From my experience, probably none of them will do what
you want (except maybe one that costs $1500) but if you can program each one
hits the problems from different directions giving you more ideas.
Also, links to tutorials in the different scripting languages as well.
hth
John T. Jarrett
ohmygod@tksun.aiit.or.kr wrote:
> [snip]
>
> I want to build online shopping mall..
> How can I get some source..some instruction..some help.?
------------------------------
Date: Sun, 07 Feb 1999 21:58:04 -0500
From: ricks <ricks@acpub.duke.edu>
To: Chris Jones <cj@interlog.com>
Subject: Re: impossible configure perl CGI on IIS4?
Message-Id: <36BE52BC.B2E8905@acpub.duke.edu>
I've got Perl 5 Win32 (ActivePerl) running on PWS and IIS4. As long as
you remember to add "%s %s" to the registry it seems to work fine.
Rick
Chris Jones wrote:
>
> Interesting following this thread. I am just today trying to get CGI
> to work with Personal WEB Server on my Win95 laptop. I had nothing
> but trouble trying to get PWS to recognize itself. I suppose it will
> be a struggle to get CGI to work.
>
> I was using Xitami which installed and worked in about 15 minutes.
> CGI worked immediately without any trouble. Unfortunately, the client
> I am working want to use IIS, oh well....
--
ricks@duke.edu http://www.duke.edu/~ricks
------------------------------
Date: Sun, 07 Feb 1999 19:44:37 -0800
From: Michael Stearns <michael@datahost.com>
Subject: Installing a Module: Can't find Perl
Message-Id: <36BE5DA5.3AA5@datahost.com>
Hello:
I am on a Linux system for which I don't have root access. I am
attempting to install the Perl URI-1.0 module.
When I run
perl Makefile.PL LIB=~/perllib
I get the following message:
Warning: prerequisite MIME::Base64 2 not found at (eval 1) line 221.
Unable to find a perl 5 (by these names: perl miniperl perl perl5
perl5.00404, i
n these dirs: /vs3/vs3/datahost/bin /vs3/vs3/datahost/usr/local/bin /bin
/usr/bi
n /usr/ucb /usr/local/bin /etc . /usr/bin)
Writing Makefile for URI
If I do:
% which perl
I get:
/vs3/vs3/datahost/bin/perl
I also know that I have no problem running perl scripts from the command
line. Any ideas why the installer can't find perl?
Thanks,
-- Michael
---------------------------------------------------------
Michael Stearns Datahost
michael@datahost.com 37540 Wallace Creek Rd
phone: 541-746-6418 Springfield, OR 97478
fax: 541-746-7176
pager: 541-718-2752
---------------------------------------------------------
------------------------------
Date: Sun, 07 Feb 1999 22:12:11 -0700
From: Bernard Gobeil <gobeilb@cadvision.com>
Subject: mod_perl on Win32
Message-Id: <36BE722B.BA0AED5@cadvision.com>
Does anyone know where I could locate binaries (win32) for Perl which
are compatible with Apache 1.3.4 and mod_perl? I am currently using
ActiveState's binaries but they have been compiled with Perl_Object
which is not compatible with mod_perl. I have tried compiling CPAN's
source to no avail. Thanks.
------------------------------
Date: Sun, 7 Feb 1999 23:46:16 -0500
From: "George Saunders" <undefined@undefined.com>
Subject: Re: No such file or directory
Message-Id: <79lq5u$9kp@news1.snet.net>
Try double-checking your path to Perl on the first line of the script. See
if that is an exact match to the path your server company gave you.
If that's not it -- show the code so we can look at it closer from there.
Best of luck to you.
Glen Lee Edwards wrote in message <79j503$avu2@iac7.navix.net>...
>I'm trying to install a Perl script on a Linux system and on three of the
>cgi scripts I keep getting a "no such file or directory" error. But when I
>look through the script it appears that the syntax referencing the files
are
>correct, and all the respective folders are in place. Any suggestion?
>
>Thanks,
>
>Glen
>
>
------------------------------
Date: Sun, 7 Feb 1999 21:47:40 -0800
From: "Sameer Samat" <ssamat@ucsd.edu>
Subject: Re: Perl vs. ASP for new project
Message-Id: <RGuv2.51204$641.41565@news.san.rr.com>
first, thank you very much for your help ...
>
>Unix/perl will not be faster than ASP on NT unless your using modperl. If
>you use modperl, it will be much faster (assuming Apache). You can't keep
the
>interpreter in memory, it will be spawned for each script I think.
modperl. ok, I'll have to look into that. would you, or anyone else
reading this, happen to know if most ISPs make use of modperl? is it
expected that and ISP will have modperl up and running on their unix based
Apache servers? ... or is it something that we may need to install?
(i know this is probably on a ISP case by case basis, but I think that if
modperl really does help this much any ISP would be crazy not to already
have it installed)
>Your not comparing apples to apples. Consider php3(www.php3.net), which
>accomplishes what ASP does but under Unix. Compile it into apache, and use
>its built in database access capabilities and you have a very fast
solution.
>Although php is for Unix, which is obviously perferred anyway for major
sites.
I'll give it a look. Thanks again
Sameer
------------------------------
Date: Sun, 07 Feb 1999 21:39:04 -0500
From: "John T. Jarrett" <jjarrett@ecpi.com>
Subject: Re: PERL web ring script
Message-Id: <36BE4E47.BB342796@ecpi.com>
cgi-resources.com
Glen Lee Edwards wrote:
> Anyone know where I can find a PERL web ring script to install on my Linux
> server?
>
> Thanks,
>
> Glen
------------------------------
Date: 8 Feb 1999 02:39:51 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Program needs compactification
Message-Id: <79lipn$m69$1@client2.news.psi.net>
Uri Guttman (uri@home.sysarch.com) wrote on MCMLXXXVI September MCMXCIII
in <URL:news:x7g18in7h4.fsf@home.sysarch.com>:
() >>>>> "PJK" == Peter J Kernan <pjk6@po.cwru.edu> writes:
()
() >> this is slightly cleaner but ugly nonetheless.
() >>
() >> perl -la0777ne 'print for keys %{{@F,(@F&1?():""),@F}}'
()
() PJK> another way: 'print for sort keys %{{(@F,@F%2?@F:pop @F)x2}}'
()
() PJK> no null
()
() and the ugliest code so far. :-)
perl -pale '@F{@F}=@F}for(keys%F){'
Abigail
--
perl -wle\$_=\<\<EOT\;y/\\\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: 07 Feb 1999 23:58:22 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Program needs compactification
Message-Id: <x74soxqyoh.fsf@home.sysarch.com>
>>>>> "A" == Abigail <abigail@fnx.com> writes:
A> perl -pale '@F{@F}=@F}for(keys%F){'
abby,
this is the second time (i know of) you resorted to using the -p
internal implementation to hack a tiny solution. it is obscure, elegant,
and inscrutable (even though i understand it). i think it violates some
(which?) rules of fair play in perl hackery as it takes advantage of
knowing how -p and -n are implemented. according to the docs that is
what virtually happens, but you know it actually is wrapped in that
source so the }{ stuff will work.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 06 Feb 1999 23:25:23 -0500
From: Vladik <reason@shadow.net>
Subject: RegExp to substitue a string
Message-Id: <87pv7msuvg.fsf@ararat.mygus.com>
Hello,
I am giving up,
I cannot figure out how to
substitute a string start starts with XM_
with BP_LM.
for example in my files I have XM_ZYDS, or
XM_DASD
I need to replace all of thouse with
just BP_LM.
I undertand that I can read each line,
then split it into words, then compare
the first 3 characters of each word with XM_
and if matches, relplace the whole word with
BP_LM, and then write the whole line back
to the file. But all that seems to be
tedious and not elegant, there got to
be a way to do it with RegExpressions
(I am just learning that stuff using
the excellent 'Mastering Regular Expressions'
book -- but I cannot seem to find a answer
there).
Thanks in advance for any tips,
Vladik
------------------------------
Date: 8 Feb 1999 00:46:27 -0500
From: dha@panix.com (David H. Adler)
Subject: Re: Rencontre Perl de Mtl
Message-Id: <slrn7bsuhh.kiq.dha@panix.com>
On Fri, 29 Jan 1999 14:39:22 GMT, droby@copyright.com
<droby@copyright.com> wrote:
>However, the m(o|u)nger arose from language differences across the puddle.
Actually, it arose from a desire to call the original (nyc) group
"NY.pm", using /M((o|u)ngers|aniacs*/ for the 'm' (unsurprisingly, the
'p' was intended to stand for 'perl'...).
A possibly clearer explanation of this can be found at
<http://www.perl.com/pace/pub/perldocs/1999/01/foy.html>.
HTH,
dave (ruthless godless dictator of ny.pm) (but, really, a nice
guy... :-)
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Got Perl? <www.perl.com>
Got a Perl User Group? <www.pm.org>
------------------------------
Date: 8 Feb 1999 05:20:24 GMT
From: dennis@info4.csie.nctu.edu.tw (GEMINI)
Subject: speed up the DBI/DBD dynamic module loading?
Message-Id: <79ls6o$26p$1@netnews.csie.NCTU.edu.tw>
hi all,
I make all my perl modules using dynamic linking.
The start up speed is acceptable for these modules
except for the DBI/DBD module.
It's much slower than other module to be loaded.
With the exception of static linking,
is there any way to speed up the loading time?
is it possible to make the module (dynamic linking library, *.so)
stay in memory permenently? and does it work?
thanks.
------------------------------
Date: 06 Feb 1999 21:56:04 -0500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Syntax checking without "perl -c"?
Message-Id: <lthfsyoraz.fsf@asfast.com>
mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:
> In article <ltemo4oobz.fsf@asfast.com>, Lloyd Zusman <ljz@asfast.com> wrote:
> >
> > [ ... ]
> >
> >So ... I'm wondering: is there any way within Perl that I could check
> >pieces of Perl code for valid syntax, given the preferences and
> >requirements I outlined above?
>
> How about
>
> eval "die 'Compiled OK\n'; $code";
> if ($@ eq "Compiled OK\n") { we are happy };
>
> That'll get caught by BEGIN or use, of course. And you may want to trap
> warnings with $SIG{__WARN__}.
But what if `$code' has side effects, such as deleting files,
contacting the net, etc.? I'm trying to avoid these during my
syntax check.
> Or alternatively, evaluate to a subroutine. That way, you wont need
> to compile again when you actually use the value:
>
> my $sub = eval "sub { $code }";
>
> Same caveats as above, and also it could be tricked by };{ .
Hmmmm ... this one's better. And as I just now mentioned in another post
in this thread (to "James M. Stern" <sternji@mail.northgrum.com>),
`$code' could be first fed to a curly brace counter, and then a
sufficient number of braces could be placed on either side of it.
This would solve the };{ problem you mentioned.
--
Lloyd Zusman ljz@asfast.com
perl -le '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'
------------------------------
Date: 06 Feb 1999 21:48:54 -0500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Syntax checking without "perl -c"?
Message-Id: <ltlnibnd2h.fsf@asfast.com>
"James M. Stern" <sternji@mail.northgrum.com> writes:
> Lloyd Zusman wrote:
> > [...]
> > So ... I'm wondering: is there any way within Perl that I could check
> > pieces of Perl code for valid syntax, given the preferences and
> > requirements I outlined above?
> > [Compile it without executing it and avoid the overhead of piping the code to "perl -c."]
> > [...]
>
> No answer, just a lead and a partial solution.
>
> Lead: If you're willing to write some C, function perl_parse,
> documented in perlembed, looks promising. I'm no expert in that part of
> Perl, though.
Yes, this indeed does look promising ... I'll check it out. However,
I forgot to mention that I was looking for a Perl-only solution, as
opposed to something that would require C compilation ... picky,
aren't I?! :):)
> Partial solution: eval "if (0) { $the_code }" but beware these
> drawbacks:
>
> * It still executes BEGIN blocks. (Although 'perl -c' does too.)
>
> * An extra '}{' in $the_code would place some of it outside the 'if'.
> A more paranoiac approach would be
> eval "if (0) {{{{ $the_code }}}}"
This is actually a great idea. All that would have to be done to deal
with the curly braces would be to run a brace counter against
`$the_code', and then use the results to put a sufficient number of
braces on either side. This doesn't solve the BEGIN block problem you
mentioned, but given the particular application I'm writing, I could
live with that.
So this more or less solves my immediate problem, but it also has
gotten me thinking about something that I'd like to put out to the
Perl developers who might be reading this: what do you folks think
about some future version of Perl having some sort of function which
will take an arbitrary bit of text and feed it through Perl's parser,
and which would then return true or false depending on whether the
text represents a piece of code which would pass the `perl -c' test?
Perhaps this could be controlled via an optional second argument to
`eval', which if present and true, would cause the syntax to be
evaluated without any execution taking place ... ???
--
Lloyd Zusman ljz@asfast.com
perl -le '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'
------------------------------
Date: Mon, 08 Feb 1999 04:54:30 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Syntax checking without "perl -c"?
Message-Id: <36BE6FE2.FDF78C44@home.com>
[posted & mailed]
Lloyd Zusman wrote:
>
> mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:
>
> >
> > How about
> >
> > eval "die 'Compiled OK\n'; $code";
> > if ($@ eq "Compiled OK\n") { we are happy };
> >
> > That'll get caught by BEGIN or use, of course. And you may want to
> > trap warnings with $SIG{__WARN__}.
>
> But what if `$code' has side effects, such as deleting files,
> contacting the net, etc.? I'm trying to avoid these during my
> syntax check.
How are these side effects going to run when the eval will die first?
If the compile fails, $code doesn't run and $@ is set to the compile
errors.
If the compile succeeds, the die statement is executed, $code still
doesn't run, and $@ is set to 'Compiled OK'.
Either way $code is not run, only compiled. I thought this was a very
clever solution.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sun, 7 Feb 1999 23:58:17 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: testing for scalar/list/array
Message-Id: <1dmvr5p.nsa8dw16r8d2kN@bay2-469.quincy.ziplink.net>
Rick Delaney <rick.delaney@home.com> wrote:
> #!/usr/local/bin/perl -w
>
> sub test {
> $one = 1;
> $two = 2;
> @three = qw(a b c d);
> $ref_inside = \($one, $two, @three);
>
> print 'Inside: ', ref $ref_inside, "\n";
>
> return ($one, $two, @three);
> }
>
> $ref_outside = \test();
> print 'Outside: ', ref $ref_outside, "\n";
> __END__
> Inside: ARRAY
> Outside: SCALAR
>
> I'm guessing it has something to do with this special case from perlref,
>
> As a special case, \(@foo) returns a list of references to the
> contents of @foo, not a reference to @foo itself. Likewise for
> %foo.
>
> but I still don't see it.
$ref_inside = \($one, $two, @three);
is equivalent to:
$ref_inside = (\$one, \$two, \@three);
which is equivalent to:
$ref_inside = \@three;
So you get a ref to an array.
$ref_outside = \test();
calls test() in a list context, returning (1, 2, 'a', 'b', 'c', 'd').
So this is equivalent to:
$ref_outside = \(1, 2, 'a', 'b', 'c', 'd');
which is equivalent to:
$ref_outside = (\1, \2, \'a', \'b', \'c', \'d');
which is equivalent to:
$ref_outside = \'d';
So you get a ref to a scalar.
The special case you quoted above turns out not to be involved here.
The key is that outside the function the list ($one, $two, @three) has
been flattened; inside the function the list has not been flattened.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 07 Feb 1999 21:38:27 -0500
From: "John T. Jarrett" <jjarrett@ecpi.com>
Subject: Re: The order of form fields that recieve by cgi program
Message-Id: <36BE4E22.70B7F6CF@ecpi.com>
I don't know how they do it - didn't really care - but bignosebird.com's form
mailer script requires you to specify the order in a hidden field in your
html AND THEN prints stuff out in the order you gave it.
John
fanxin@mailcity.com wrote:
> Hi,there:
> does here any experts know how to know the original order of html form
> fields in the submitted html form after these data has been splitted to
> an associated arrary in perl cgi program?
> Thanks
>
> fan
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sun, 7 Feb 1999 23:58:18 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Viewing remote Perl script before executing
Message-Id: <1dmvrrm.176r7rh1psp1nfN@bay2-469.quincy.ziplink.net>
<brackett@pobox.com> wrote:
> Is there an easy way to view a remote Perl script before executing it? For
> example, if I know clicking "OK" will trip a Perl script at
> http:///111.111.111.11/cgi-bin/script.pl, how can I see the script before
> letting it do whatever it does?
You can't, unless the script itself has been made available at another
URL.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
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 4844
**************************************