[15690] in Perl-Users-Digest
Perl-Users Digest, Issue: 3103 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 19 21:06:27 2000
Date: Fri, 19 May 2000 18:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958784714-v9-i3103@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 19 May 2000 Volume: 9 Number: 3103
Today's topics:
Re: "If" Not Being Evaluated - Vars Are Being Subsitute <uri@sysarch.com>
Re: "If" Not Being Evaluated - Vars Are Being Subsitute (Abigail)
[2nd post] Perl for Windows - Plz somebody help... (Lobo)
Re: [2nd post] Perl for Windows - Plz somebody help... <lauren_smith13@hotmail.com>
Re: a script's own fullpath, when run in crontab <sergey@cgen.com>
a wacky idea <nomail@nomail.com>
Re: a wacky idea <jeff@vpservices.com>
Re: Bug or Feature: Can't dereference array ref inside (Steve Leibel)
Can't retrieve from a hash after I restarted Apache <vincent@luckysurf.com>
Can't retrieve from a hash after I restartes Apache <vincent.riffierNOviSPAM@free.fr.invalid>
Re: count the number of lines <rick.delaney@home.com>
Re: Forum for 'how to do it' questions? <bmb@dataserv.libs.uga.edu>
Re: Forum for 'how to do it' questions? <ra.jones@NO_UCE*cwcom.net>
Re: HTML output from MS Word (Was: Re: alphabeticalize <flavell@mail.cern.ch>
Re: Manipulate all *values* using CGI.pm? <uri@sysarch.com>
Re: matching question(s) <lr@hpl.hp.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 19 May 2000 22:24:38 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: "If" Not Being Evaluated - Vars Are Being Subsituted?
Message-Id: <x7hfbufaah.fsf@home.sysarch.com>
>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
BL> $number = 3;
BL> if ($number eq "3") {
BL> <IMG SRC="test.jpg" BORDER=0 ALT="Test">
BL> }
BL> And it DOESN'T give any error messages. Not even a warning. Why
BL> not? How does Perl interpret this... junk?
ever heard of a file glob?
perl -MO=Deparse deparse.pl
$number = 3;
if ($number eq '3') {
CORE::GLOBAL::glob 'IMG SRC="test.jpg" BORDER=0 ALT="Test"', 0;
}
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 19 May 2000 22:30:05 GMT
From: abigail@foad.org (Abigail)
Subject: Re: "If" Not Being Evaluated - Vars Are Being Subsituted?
Message-Id: <slrn8ibg3d.vii.abigail@ucan.foad.org>
On Fri, 19 May 2000 21:28:46 GMT, Bart Lateur <bart.lateur@skynet.be> wrote:
++ Abigail wrote:
++
++ >You mean, you *don't*?
++ >
++ >The about *IS* valid Perl. It just doesn't do much.
++
++ I can't believe this. I tried this:
++
++ #!/usr/local/bin/perl -w
++ $number = 3;
++ if ($number eq "3") {
++ <IMG SRC="test.jpg" BORDER=0 ALT="Test">
++ }
++
++
++ And it DOESN'T give any error messages. Not even a warning. Why not? How
++ does Perl interpret this... junk?
Junk? Perhaps you should read 'man perlop'.
Abigail
------------------------------
Date: Fri, 19 May 2000 23:23:10 GMT
From: er@matrix.com.br (Lobo)
Subject: [2nd post] Perl for Windows - Plz somebody help...
Message-Id: <3925cc82.564696@news.matrix.com.br>
Hello there.
I guess many people must ask and want this, so please if anybody can
give me some information about...
I want to install Perl on my computer. I'm currently running Windows
98 and these are my questions - things that I'm really worried about:
1) Wich one is the best webserver to run perl on windows (free, if
possible)?
2) Do I HAVE to get ActiveState? I've heard a lot of criticism about
ActiveState, so I'm really scared. Is there any other kind of Perl for
Windows?
3) I've installed Perl Builder here, wich seems to have a Perl
interpreter. How is that? If it really have a Perl interpreter, how
can I update it - to Perl 5.0.0.6, for an example? If I install this
ActiveState it will conflict with
Perl Builder's interpreter?
Please, any comments, insights and tips will be very appreciated.
Best regards,
------------------------------
Date: Fri, 19 May 2000 17:36:22 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: [2nd post] Perl for Windows - Plz somebody help...
Message-Id: <8g4mn2$qnn$1@brokaw.wa.com>
Lobo <er@matrix.com.br> wrote in message
news:3925cc82.564696@news.matrix.com.br...
> Hello there.
>
> I guess many people must ask and want this, so please if anybody can
> give me some information about...
>
> I want to install Perl on my computer. I'm currently running Windows
> 98 and these are my questions - things that I'm really worried about:
>
> 1) Wich one is the best webserver to run perl on windows (free, if
> possible)?
This is not a Perl question. It is better asked in a webserver newsgroup.
>
> 2) Do I HAVE to get ActiveState? I've heard a lot of criticism about
> ActiveState, so I'm really scared. Is there any other kind of Perl for
> Windows?
No, you don't have to get ActiveState, but if you don't have the unction to
compile Perl yourself (god knows I don't), then ActiveState is the way to
go.
>
> 3) I've installed Perl Builder here, wich seems to have a Perl
> interpreter. How is that? If it really have a Perl interpreter, how
> can I update it - to Perl 5.0.0.6, for an example? If I install this
> ActiveState it will conflict with
> Perl Builder's interpreter?
Sounds like something that would be addressed in the Perl Builder
documentation.
Lauren
------------------------------
Date: Fri, 19 May 2000 22:12:21 GMT
From: Sergey Gribov <sergey@cgen.com>
Subject: Re: a script's own fullpath, when run in crontab
Message-Id: <3925BB49.15844064@cgen.com>
ahnew wrote:
>
> if i submit a351.pl as a cron job, i can't get a351.pl's fullpath. i
> have tried $0, `pwd`, cwd()
>
> please reply to victor@catchacorp.com
Try Cwd.pm (perdoc Cwd)
use Cwd;
$dir = getcwd;
- should work.
Cheers,
//========================================================================\\
Sergey Gribov | A specialist is someone who
E-Mail: sergey@cgen.com | learns more and more about less
sergey@sergey.com | and less, and ends up knowing
WWW: http://www.sergey.com/ | everything about nothing...
Compugen Inc. Phone: (617)9283096, Fax: (617)9283070
\\========================================================================//
------------------------------
Date: Fri, 19 May 2000 18:06:48 -0400
From: "Jonah" <nomail@nomail.com>
Subject: a wacky idea
Message-Id: <8g4k62$343g$1@onlink3.onlink.net>
Ok, is it possible to run a perl script from a graphic on a standard
html page?
Example.
<img src="http://www.server.com/cgi-bin/image.cgi">
The script will display an image, (1x1 pixel) but before it does that, maybe
it
can do other stuff, like, say, save the query string to a file.
Is this possible or am I a total nutjob for even thinking about it?
------------------------------
Date: Fri, 19 May 2000 17:41:02 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: a wacky idea
Message-Id: <3925DF1E.42433AF8@vpservices.com>
Jonah wrote:
>
> Ok, is it possible to run a perl script from a graphic on a standard
> html page?
Yes.
>
> Example.
> <img src="http://www.server.com/cgi-bin/image.cgi">
That works. Try it. In fact, make that a general principle -- if you
get a whacky idea, give it a shot and see what happens. If nothing
happens or something different than you expected, research it out. Uh,
except in the case of whacky ideas that are dangerous like things that
have the words delete or rm in them in which case you are much better
off doing the research first :-)
> The script will display an image, (1x1 pixel) but before it does that, maybe
> it
> can do other stuff, like, say, save the query string to a file.
Or create an image on the fly, or create a logfile, or show the current
time in Timbuktu.
> Is this possible or am I a total nutjob for even thinking about it?
The only thing out of whack is discussing this in the Perl newsgroup
rather than the CGI newsgroup because this is a property of CGI scripts
and works regardless of whether the script is written in Perl or in the
magical language of foobarbaz and because whether it works or not has
nothing to do with the Perl language, its syntax, or its usage.
--
Jeff
------------------------------
Date: Fri, 19 May 2000 15:48:54 -0700
From: stevel@coastside.net (Steve Leibel)
Subject: Re: Bug or Feature: Can't dereference array ref inside hash
Message-Id: <stevel-1905001548540001@192.168.100.2>
In article <slrn8iavn9.prq.abigail@ucan.foad.org>, abigail@arena-i.com wrote:
> ++ When I ran this program with -w and 'use strict' it gave the error
> ++
> ++ "Odd number of elements in hash assignment"
>
> Indeed. Didn't that ring a bell? Did you look up what it means in
> man perldiag?
>
>
Abigail,
I wasn't running with -w originally. My bad. In any event I'm now using
square brackets for an array reference. I must say though that the
distinction between lists and arrays is one of the more confusing features
of Perl. For example if you look at all the documentation in the Camel
book, etc., you find that all the examples of arrays of arrays are notated
as LoL, ie "lists of lists." So even the authors are not rigorously clear
about the distinction between () and []. And in cases where a syntactic
distinction is subtle but important, good documentation should be crystal
clear.
I would be grateful if someone could explain this distinction to me,
rather than just saying "read perlref", since I've already read every word
in the Camel book first edition; every word in the Camel book 2nd edition;
have written thousands of lines of production Perl code; and that I still
freely admit I don't understand the deeper meaning of "Odd number of
elements in hash assignment" in response to
$myhash = {
whatever => (),
};
So maybe it's not just me being clueless, perhaps this is a confusing part
of the language and a lot of readers could benefit from a clear
explanation of this example.
Thanks,
Steve L
------------------------------
Date: Sat, 20 May 2000 00:17:31 GMT
From: "Vincent" <vincent@luckysurf.com>
Subject: Can't retrieve from a hash after I restarted Apache
Message-Id: <vQkV4.94$DF1.632880@nnrp6.proxad.net>
This is the problem.
I have two scripts.
*The first one : 'startup.pl' is called when I restart Apache. In this
script I put every html pages in a hash.
At this moment, I can retrieve the files, everything is ok. When I call the
script manually my hash is full, but when I restart Apache my hash is empty
*The second one : 'play' is called anytime I am looking a page which call
this script. But there I can't retrieve the page anymore. My Hash if empty.
If anyone knows a solution please let me know
This is the code I wrote :
########
#in startup.pl
########
use vars qw(%file_cache);
sub load_file
{
my($fn) = @_;
local(*IN);
my($file);
if (open(IN, $fn)) {
read(IN, $file, -s IN);
close(IN);
}
else {
my ($dir, $name) = split( /\//, $fn, 2 );
$fn="NewSite/$name";
if (open(IN, $fn)) {
read(IN, $file, -s IN);
close(IN);
}
}
$file;
}
sub processing_directory($) #to parse directory
{
my $folder = $_[0];
my $fName = $folder;
my $file;
local (*FOLD);
$fName =~ s/.*\///;
opendir( FOLD, $folder) or die "Can't open $folder: !
$\n";
while(defined($file = readdir(FOLD))) {
next if $file =~ /^\.\.?$/;
if(!-d "$file") {
$file_cache{"$fName/$file"} = load_file ("$folder/$file") if $file =~ /.*\.html$/;
print "$fName/$file\n";
}
else {
processing_directory(sprintf("%s/%s",
$folder, $file));
}
}
closedir(FOLD);
}
########
#in play
########
sub load_file_hinted_core($$)
{
my($name, $valref) = @_;
my $s;
unless ($main::debugMode) {
$s = $main::file_cache{"$valref->{site}/$name"};
$req->warn ("Page $valref->{site}/$name unknown") unless $s;
}
unless ($s) {
$s = load_file("$valref->{site}/$name");
}
there, everytime I got is Page ***** unknown
------------------------------
Date: Fri, 19 May 2000 16:54:21 -0700
From: vinceSF <vincent.riffierNOviSPAM@free.fr.invalid>
Subject: Can't retrieve from a hash after I restartes Apache
Message-Id: <05d74e70.714a524b@usw-ex0103-024.remarq.com>
This is the problem.
I have two scripts.
*The first one : 'startup.pl' is called when I restart Apache.
In this script I put every html pages in a hash.
At this moment, I can retrieve the files, everything is ok. When
I call the script manually my hash is full, but when I restart
Apache my hash is empty
*The second one : 'play' is called anytime I am looking a page
which call this script. But there I can't retrieve the page
anymore. My Hash if empty. If anyone knows a solution please let
me know
This is the code I wrote :
########
#in startup.pl
########
use vars qw(%file_cache);
sub load_file
{
my($fn) = @_;
local(*IN);
my($file);
if (open(IN, $fn)) {
read(IN, $file, -s IN);
close(IN);
}
else {
my ($dir, $name) = split( /\//, $fn, 2 );
$fn="NewSite/$name";
if (open(IN, $fn)) {
read(IN, $file, -s IN);
close(IN);
}
}
$file;
}
sub processing_directory($) #to parse directory
{
my $folder = $_[0];
my $fName = $folder;
my $file;
local (*FOLD);
$fName =~ s/.*\///;
opendir( FOLD, $folder) or die "Can't open $folder: !
$\n";
while(defined($file = readdir(FOLD))) {
next if $file =~ /^\.\.?$/;
if(!-d "$file") {
$file_cache{"$fName/$file"} = load_file ("$folder/$file") if
$file =~ /.*\.html$/;
print "$fName/$file\n";
}
else {
processing_directory(sprintf("%s/%s",
$folder, $file));
}
}
closedir(FOLD);
}
########
#in play
########
sub load_file_hinted_core($$)
{
my($name, $valref) = @_;
my $s;
unless ($main::debugMode) {
$s = $main::file_cache{"$valref->{site}/$name"};
$req->warn ("Page $valref->{site}/$name unknown") unless $s;
}
unless ($s) {
$s = load_file("$valref->{site}/$name");
}
there, everytime I got Page *** unknown
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Sat, 20 May 2000 00:25:42 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: count the number of lines
Message-Id: <3925DC90.79A96759@home.com>
Larry Rosler wrote:
>
> As for the best search mechanism, I would expect that the index function
> is faster for finding a literal pattern without metacharacters.
I wouldn't expect that anymore.
> Anyone who feels inclined to benchmark these is welcome to, of course.
> :-)
#!/usr/bin/perl -lw
use strict;
use Benchmark;
open 0;
our @a = <0>;
timethese 20000 => {
Idx => q {
my $count = grep index($_, 'pattern') == 0 => @a;
},
RE => q {
my $count = grep /^pattern/ => @a;
},
};
__END__
pattern
rick $ ./benchmark.pl
Name "main::a" used only once: possible typo at ./benchmark.pl line 6.
Benchmark:
timing 20000 iterations of
Idx, RE
...
Idx: 2 wallclock secs ( 1.69 usr + 0.06 sys = 1.75 CPU) @
11428.57/s (n=20000)
RE: 2 wallclock secs ( 1.58 usr + 0.08 sys = 1.66 CPU) @
12048.19/s (n=20000)
Anyone who feels inclined to vary the test data is welcome to, of
course.
:-)
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Fri, 19 May 2000 18:34:34 -0400
From: Brad Baxter <bmb@dataserv.libs.uga.edu>
Subject: Re: Forum for 'how to do it' questions?
Message-Id: <Pine.GSO.4.21.0005191833100.18271-100000@dataserv.libs.uga.edu>
On Fri, 19 May 2000, jones wrote:
...
> I tried perldoc perlfaq at the telnet command line and received a very
> user-unfriendly screen giving me one line at a time. I then found a
> PerlFaq at www.perl.com spanning PerlFaq1 to PerlFaq 9. Is this the
> document you referred to?
...
Yes, indeed, that is it. No doubt you have seen the other answers to your
note. Happy Hunting ...
--
Brad
------------------------------
Date: Fri, 19 May 2000 23:47:59 +0100
From: jones <ra.jones@NO_UCE*cwcom.net>
Subject: Re: Forum for 'how to do it' questions?
Message-Id: <0rT8OdBfScJ5EwQ1@cwc.com>
On Fri, 19 May 2000 at 18:34:34, Brad Baxter <bmb@dataserv.libs.uga.edu>
wrote:
>Yes, indeed, that is it. No doubt you have seen the other answers to your
>note. Happy Hunting ...
>
OK, thanks - it looks like a great reference document which I shall
retain for future use. I scanned it for an answer to my question, but
I'm not sure under which section of the FAQ to look, so I posted it
here anyway. Hoping for some (favourable) replies :-)
--
Richard Jones, Leeds, UK
rajones (at) mail.com
or remove NO_UCE* from the 'reply-to' address
------------------------------
Date: Sat, 20 May 2000 00:43:32 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: HTML output from MS Word (Was: Re: alphabeticalize a perl array)
Message-Id: <Pine.GHP.4.21.0005200029150.4460-100000@hpplus01.cern.ch>
On Fri, 19 May 2000, Larry Rosler wrote:
> The primary choice was to use MS Word, which was made because the
> requirements for printed publication in the Perl Conference proceedings
> specified two columns with specified width and separation. I know how
> to do that with MS Word, so that's what I chose to use.
That's OK. No dispute with that.
> I used the
> HTML output capability of MS Word to produce the HTML file in question,
MS Word does not have a capability to produce HTML, as this example
amply demonstrates. It extrudes tag soup.
> Well aware of the vagaries of MS Word's HTML output, I wrote a minimal
> filter needed to produce correct output on the Nutscrape and Exploder
> browsers. At no time was any concern or interest given to HTML
> validation. To put it bluntly, who the hell cares?
For a one-off to be seen by a limited audience and then thrown away,
nobody cares. Is that how you value this work?
I'm not going to make out that your actions were indefensible: I know
the pressures of getting something out to a conference deadline.
Excuse me for butting in, but I don't think you should act so shocked
that someone finding your example should decide to comment on it.
Perhaps this discussion will alert some folk who will yet find
themselves in a similar position, so that they can consider their
options ahead of time. It's not as if there aren't some quite
reasonable solutions available for this task.
See, some of us _do_ care, and find it sad when others are willing to
put up with less. Yes, you're right, this is the wrong forum, so I'll
shut up now.
------------------------------
Date: Fri, 19 May 2000 22:10:17 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Manipulate all *values* using CGI.pm?
Message-Id: <x7ln16fayf.fsf@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> [Posted and a courtesy copy mailed.]
LR> In article <x73dnfgfe5.fsf@home.sysarch.com> on Fri, 19 May 2000
LR> 07:36:50 GMT, Uri Guttman <uri@sysarch.com> says...
>> >>>>> "CW" == Christian Winter <thepoet1@arcormail.de> writes:
>>
CW> map { ($paramhash{$_} = $_) =~ tr/[0-9]/[A-J]/ } $new_query->param;
>> ( $paramhash{$_} = param($_) ) =~ tr/[0-9]/[A-J]/ for param() ;
>> tr/[0-9]/[A-J]/ for values %paramhash ;
LR> I know you just copied and pasted that tr() operation. Next time,
LR> look at it. Around here, translating'[' to '[' and ']' to ']' is
LR> considered to be gauche, at best! :-)
guilty as charged. i was just keeping the dummy (in both senses of the
word) code and didn't see any need to replace it or examine it closely.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 19 May 2000 17:26:30 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: matching question(s)
Message-Id: <MPG.138f7b8e3b04b27698aaa0@nntp.hpl.hp.com>
In article <Pine.A41.4.20.0005190239110.51126-100000@unix1.cc.ysu.edu>
on Fri, 19 May 2000 02:55:26 -0400, NagaPutih
<s0218327@unix1.cc.ysu.edu> says...
>
> 1. i have the following statements:
>
> $_="@all_keys";
> @valid_keys=grep(!/\b$badkey\b/,m/\b[a-z]{$len}\b/g);
Only in Perl Golf should one run all the tokens together the way you
have. For legibility:
@valid_keys = grep !/\b$badkey\b/ => /\b[a-z]{$len}\b/g;
I don't know why you bothered to stringify the array before searching
it. This would do:
@valid_keys = grep !/\b$badkey\b/ =>
map /\b[a-z]{$len}\b/g => @all_keys;
I would be concerned about recompiling each of those regexes many times,
so would either suffix the /o modifer if the interpolations are constant
for the run of the program, or compile the regexes ahead of the
statement using qr//.
> what i want to do is take all keys that are 3-letter strings
> while excluding the bad key (assume it is also a 3-letter string);
> and the above statements works just fine.
>
> but, is there any better way to do this? (other than do the
> matcing m// first; loop through the matched keys and compare each one
> to the bad key)
Your way looks OK to me, but overly complicated. As the list to be
filtered is already reduced to words, just an equality check will do,
not a regex:
@valid_keys = grep $_ ne $badkey =>
map /\b[a-z]{$len}\b/g => @all_keys;
> 2. what matching algorithm is used in grep()? what about regexp too?
As you can see, grep just evaluates the truth of its first argument for
each member of the argument list. You specify how it should do that.
I don't understand the part of the question about rexes.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3103
**************************************