[16204] in Perl-Users-Digest
Perl-Users Digest, Issue: 3616 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 11 00:05:43 2000
Date: Mon, 10 Jul 2000 21:05:13 -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: <963288312-v9-i3616@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 10 Jul 2000 Volume: 9 Number: 3616
Today's topics:
"balanced text" problem ...? ynotssor@my-deja.com
Re: "module" method missing in mod_perl Apache.pm? <randy@theory.uwinnipeg.ca>
<newbie> (11 .. 21) for arrays. alexserve@my-deja.com
about Net::SMTP (Haazi2)
Re: about Net::SMTP (Keith Calvert Ivey)
Re: Anyone have a Free Meta Crawler Script <karlt96@nox.nyx.net>
Re: cgi-lib - How to get parameters from url? (Jesse)
Re: Comparing two strings (golf, anyone?) <bwalton@rochester.rr.com>
Creating users using www CGI <landim2NOlaSPAM@brhs.com.br.invalid>
Re: Experienced PERL / CGI programmers needed (Keith Calvert Ivey)
Re: Faster way to do it... <lauren_smith13@hotmail.com>
Re: Faster way to do it... <lr@hpl.hp.com>
Re: Faster way to do it... (Tad McClellan)
Re: Help with converting part of a page to CGI <fedya@banet.net>
Re: How to display the correct time from a time server (T. Postel)
Re: How to display the correct time from a time server (Abigail)
Re: intercept a return from Redirect (David Efflandt)
Re: Language Challenge -- Results <uri@sysarch.com>
Re: multidimensional associative arrays (Abigail)
Re: Re-directing dos stderr stdout to file. How? (Steve A. Taylor)
Re: running system command as root from perl ynotssor@my-deja.com
Re: running system command as root from perl (brian d foy)
Re: Shuffling an array (Douglas Wilson)
Re: Shuffling an array (Abigail)
Re: Shuffling an array <mouimet@direct.ca>
Sill can't figure out random array <mouimet@direct.ca>
Re: String length? <uri@sysarch.com>
Re: String length? (John Stanley)
Re: String length? <uri@sysarch.com>
Re: String length? (John Stanley)
Re: this newsgroup (Abigail)
Re: this newsgroup <Juergen.pfann@t-online.de>
Trouble Installing Modules vaton@postoffice.pacbell.net
Trouble Installing Modules vaton@postoffice.pacbell.net
Re: warning?? <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 11 Jul 2000 02:20:16 GMT
From: ynotssor@my-deja.com
Subject: "balanced text" problem ...?
Message-Id: <8ke08l$mc5$1@nnrp1.deja.com>
I'm trying to deal with incoming emails that contain inline uuencoded
files. The perl structures in use currently can deal successfully with
inline content, removing it and re-attaching as MIME/base64.
The problem occurs with multiple inline uuencoded files, e.g.:
begin
1
2
3
end
begin
4
5
6
end
The regexp structure:
while (<BODY>) {
if (/^begin\s+\d\d\d\s+/ .. /^end$/) {
print DEC_PART unpack 'u', $_;
}
}
concatenates all inline uuencoded files, and DEC_PART is simply the
first file in the concatenation.
Would someone please suggest a coded solution that would successively
unpack each of the begin/end pairs ?
- tony
-
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 10 Jul 2000 21:58:04 -0500
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: "module" method missing in mod_perl Apache.pm?
Message-Id: <8ke2ko$f3o$1@canopus.cc.umanitoba.ca>
Jason Duell <jduell@alumni.princeton.edu.nohamspamwich> wrote in message
news:3969C0BA.CA0683B9@alumni.princeton.edu.nohamspamwich...
> I'm trying to get Apache::DBI working on a RedHat box, and I'm running
> into the following problem:
> Apache::DBI.pm refers to "Apache->module()" in Apache.pm, yet Apache.pm
> (which ships with mod_perl) has no such method.
[...]
Apache::module is only defined when you're running inside
an httpd. In Apache::DBI, the reference to Apache->module
if ($INC{'Apache.pm'} and Apache->module('Apache::Status'));
should read
if ($INC{'Apache.pm'} and $ENV{MOD_PERL}
and Apache->module('Apache::Status'));
in order to work inside and outside of httpd.
best regards,
randy kobes
------------------------------
Date: Tue, 11 Jul 2000 03:30:51 GMT
From: alexserve@my-deja.com
Subject: <newbie> (11 .. 21) for arrays.
Message-Id: <8ke4dc$ine$1@nnrp2.deja.com>
I have an flat file text database and I have it
tied to an array. I want to print 10 items from
this database per page of viewing.
I have the searching sorted but i want
a "Browsable" style page also.
For example i have 60 entries in my database with
7 fields in each deliminated by a | (pipe). I
want visitors to view 10 enties at a time.
Right now I have this code:
while (<DATA>) {
if (11 .. 21) {
@tabledata=split(/\s*\|\s*/, <DATA>);
$id = $tabledata[0];
$title = $tabledata[1];
$website_url = $tabledata[2];
$email = $tabledata[3];
$software = $tabledata[4];
$type = $tabledata[5];
$page_url = $tabledata[6];
print "<a
href=\"$page_url\">$software</a><br>\n";
}
}
When i run this (according to the cookbook) I
should get the entries from 11 through 21 and I
do if I don't use an array. But if I tie the
array perl prints only the even number entries
between 11 and 21. Or if I want 12 through 22
perl prints every odd entry.
WHY??? Please help me as this project needs
completion soon and in all of CPAN i could not
find an answer. I cannot use any non-bundled
modules either as I am using my hosting companies
server and they only include the modules that
perl comes with.
Many thanks, Alex (A Perl loner, due to lack of
enthusiasm from my peers).
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 11 Jul 2000 03:16:42 GMT
From: haazi2@aol.com (Haazi2)
Subject: about Net::SMTP
Message-Id: <20000710231642.10552.00000072@ng-mb1.aol.com>
How do you carbon copy to an email address using Net::SMTP?
Thanks in advance for any help offered.
------------------------------
Date: Tue, 11 Jul 2000 03:26:35 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: about Net::SMTP
Message-Id: <396b92bd.11825867@nntp.idsonline.com>
haazi2@aol.com (Haazi2) wrote:
>How do you carbon copy to an email address using Net::SMTP?
The same way you send any other message. The only difference
with a CC is that you put the address in the "Cc:" line instead
of the "To:" line when you're constructing the header.
Recipients are recipients.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Mon, 10 Jul 2000 21:40:41 -0400
From: "Karl Thomas" <karlt96@nox.nyx.net>
Subject: Re: Anyone have a Free Meta Crawler Script
Message-Id: <O6NU5kt6$GA.240@cpmsnbbsa09>
Josie wrote in message ...
>Thanks very much for everyones help. You are all so helpful. What happened
>to the time where people who visited NG's were helpful?
>
>Sad, sad people
>
That was before people became too lazy to look on deja and discover that
there question has been answered 10 Million times before.
------------------------------
Date: Tue, 11 Jul 2000 03:31:53 GMT
From: jesse@juga.org.invalid (Jesse)
Subject: Re: cgi-lib - How to get parameters from url?
Message-Id: <396a934e.68734474@news.m.iinet.net.au>
On 10 Jul 2000 10:08:37 GMT, efflandt@xnet.com (David Efflandt) wrote:
>cgi-lib.pl is obsolete. See if my massaged version of your script isn't
>somewhat easier (and works). For more info, on a system with Perl, type:
Thanks David,
It wasn't until I tried your script (and it too didn't work) that I
began to question the setup I was running it all on.
It turns out that DirectDomains.com's URLKeeper works for most things,
but does not pass on parameters properly when running scripts - and
this was what was confusing me.
eg. http://games.juga.org/test2.cgi?skip=123&number=456 (doesn't work)
but the direct URL
http://members.ii.net/~magic2/juga.org/games/test2.cgi?skip=123&number=456
does work.
Thanks for your help though - I'll be looking at converting all my
perl scripts to use the newer CGI stuff now that I have your example
to play with. I'm still kinda new at this, and so still learning the
lingo and teaching myself as I go :)
Thanks again!
Jesse
------------------------------
Date: Tue, 11 Jul 2000 03:23:18 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Comparing two strings (golf, anyone?)
Message-Id: <396A9386.F842A70A@rochester.rr.com>
Matthew Zimmerman wrote:
...
> (2) Less important, but certainly more fun, is this the shortest way to do
> it? Golf, anyone? My best shot is:
>
> sub compare{@b=$_[1]=~/(.)/g;for($_[0]=~/(.)/g){$c++ if $_ eq $b[$i++]};$c}
>
> Surely y'all can beat that.
sub compare{@a=map{split//}@_;$a=grep{$a[$_]eq$a[$_+@a/2]}(0..$#a)}
If compare is always called in a scalar context:
sub compare{@a=map{split//}@_;grep{$a[$_]eq$a[$_+@a/2]}(0..$#a)}
...
> |Matthew Zimmerman http://www.people.virginia.edu/~mdz4c |
...
--
Bob Walton
------------------------------
Date: Mon, 10 Jul 2000 19:19:33 -0700
From: Landim <landim2NOlaSPAM@brhs.com.br.invalid>
Subject: Creating users using www CGI
Message-Id: <00091c0e.02cc17c0@usw-ex0109-068.remarq.com>
Hi all...
I want to know how to create popusers on my linux server
using a perl CGI.
What is the command?
Like in hotmail, when you enter with the username and
password...
landim2@brhs.com.br
Thanks...
* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful
------------------------------
Date: Tue, 11 Jul 2000 02:17:01 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Experienced PERL / CGI programmers needed
Message-Id: <396a82f6.7785716@nntp.idsonline.com>
tadmc@metronet.com (Tad McClellan) wrote:
> foreach ( 0 .. length($typo)-1 ) {
> my $pat = $typo;
> substr($pat, $_, 1) = '.'; # wrong character?
> push @patterns, $pat;
>
> $pat = $typo;
> substr($pat, $_, 0) = '.'; # missing character?
> push @patterns, $pat;
You forgot
$pat = $typo;
substr($pat, $_, 1) = ''; # extra character?
push @patterns, $pat;
(not that it helps with "worl").
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Mon, 10 Jul 2000 17:52:39 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Faster way to do it...
Message-Id: <8kdr69$1l2$1@brokaw.wa.com>
<sept00@my-deja.com> wrote in message news:8kdp4a$hfn$1@nnrp1.deja.com...
> When trying to replace strings in a text file for later output, I need
> to read in a file, transfer it into a string and let the regular
> expressions run over it, right? But now I'm stumped: Because of Perl's
> miraculous TMTOWTDI-approach, I don't know which of the following
> method is faster:
>
> foreach (<$fh>) {
> s/BLAH1/$sub_text1/eg;
> s/BLAH2/$sub_text2/eg;
> s/BLAH3/$sub_text3/eg;
> s/BLAH4/$sub_text4/eg;
> s/BLAH5/$sub_text5/eg;
> print;
> }
>
> OR this
>
> @text_list = <$fh>;
> $text_scalar = "@text_list";
> $text_scalar =~ s/BLAH1/$sub_text1/eg;
> $text_scalar =~ s/BLAH2/$sub_text2/eg;
> $text_scalar =~ s/BLAH3/$sub_text3/eg;
> $text_scalar =~ s/BLAH4/$sub_text4/eg;
> $text_scalar =~ s/BLAH5/$sub_text5/eg;
> print $text_scalar;
>
If you want to know definitively whether one method is faster than another,
use the Benchmark module.
perldoc Benchmark
If you want to cram the contents of a file into a scalar, you can use this
method:
read FH, $text_scalar, -s FH;
Lauren
------------------------------
Date: Mon, 10 Jul 2000 18:50:11 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Faster way to do it...
Message-Id: <MPG.13d40e7010f6bcc498abb3@nntp.hpl.hp.com>
In article <8kdp4a$hfn$1@nnrp1.deja.com> on Tue, 11 Jul 2000 00:18:33
GMT, sept00@my-deja.com <sept00@my-deja.com> says...
> When trying to replace strings in a text file for later output, I need
> to read in a file, transfer it into a string and let the regular
> expressions run over it, right? But now I'm stumped: Because of Perl's
> miraculous TMTOWTDI-approach, I don't know which of the following
> method is faster:
...
> I'd appreciate all the info I could get on this, so thanks in advance!!
perldoc Benchmark
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 10 Jul 2000 20:58:28 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Faster way to do it...
Message-Id: <slrn8mks9k.24h.tadmc@magna.metronet.com>
On Tue, 11 Jul 2000 00:18:33 GMT, sept00@my-deja.com <sept00@my-deja.com> wrote:
>When trying to replace strings in a text file for later output, I need
>to read in a file, transfer it into a string and let the regular
>expressions run over it, right? But now I'm stumped
[ snip "matching many regular expressions at once" }
You are computing the same regex everytime through the loop.
This is going to be pretty darn slow.
Use qr// or the m//o option, if possible for a big speedup.
>I'd appreciate all the info I could get on this, so thanks in advance!!
Perl FAQ, part 6:
"How do I efficiently match many regular expressions at once?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 10 Jul 2000 22:17:30 -0400
From: Ted <fedya@banet.net>
Subject: Re: Help with converting part of a page to CGI
Message-Id: <396A83BA.2CEDDC84@banet.net>
Tad McClellan wrote:
> On Sun, 09 Jul 2000 21:52:45 -0400, Ted <fedya@banet.net> wrote:
>
> [ snip ]
I was going to accuse you of snipping the part where I said I was a newbie to
Perl, but I notice that's only in my original post and not the later posts on
this thread. :-)
> >could I simply write the HTML code for the middle part of
> >the page in a text file, and use more or less the following code to insert
> >the text file into the script:
>
> Yes (provided the code below is converted from whatever language
> it is in into Perl).
Thank you for correcting my rather poor Perl script.
> >open (FHANDLE) /tables/davenport.txt;
> ^
> ^ the end of open()'s argument list
>
> You should always check the return value from open() too:
>
> open(FHANDLE, '/tables/davenport.txt') ||
> die could not open '/tables/davenport.txt' $!";
>
> >while (FHANDLE);
>
> while (<FHANDLE>);
This brings up one more question. The statistics for players' won-lost
records, rankings, and so on, are going to be all in one file (something like
stats.pl -- I haven't decided the exact name) separate from the .txt files
which contain the players' matches and tournaments, so that I can access that
file for the pages which print tables of, say, the Top 20 players. If I open a
document with a table of a certain player's matches in the middle of the Perl
script, do I have to re-open the first file later on in order to avoid getting
a bunch of 0s when my Perl script prints out the values of certain variables?
> >print;
> >
> >?
>
> That will work. Whatever perl writes to STDOUT is what the
> browser gets. You can orchestrate input from as many different
> sources as you want in your (Perl) CGI program.
>
> >Also, would I need to use a HERE document to do it?
> ^^^^
>
> You _never_ *need* here-docs.
Let me rephrase the question slightly:
If we take a very simple table with the following HTML code:
<TABLE BORDER="0" WIDTH="1000">
<TR><TD>This table has only one cell!</TD></TR>
</TABLE>
and use the open command to stick this code into the Perl script, will the fact
that special characters such as the / and " are used cause me problems if I
don't use a HERE document? Or, if I don't use a HERE document, do I have to
use \ characters in front of the " and / characters?
> They are merely another form of quoting.
>
> Anywhere you can use other forms of quoting ( '', "", q//, qq//, ...)
> you can instead use a here-doc.
>
> Anywhere you can use a here-doc, you can instead use another form
> of quoting.
Thanks for the comments. It looks as though I should be able to create the
pages with a minimum of difficulty as the Perl scripting goes. (I have to make
certain that I get an FTP utility that can upload an entire folder of .txt
files in one fell swoop, but that probably shouldn't be too difficult.) As I
said, I'm a newbie to Perl, so I'd like my first scripts to be as simple as
possible. :-)
--
--Ted I have always challenged the "psychoses." Why don't
fedya@banet.net you have a right to say you are Jesus? And why isn't
the proper response to that congratulations?"
Thomas Szasz, "Reason" Magazine, July 2000
------------------------------
Date: Tue, 11 Jul 2000 01:05:53 GMT
From: T.Postel@ieee.org (T. Postel)
Subject: Re: How to display the correct time from a time server on a page?
Message-Id: <rpua5.3882$%wF2.129761497@news.randori.com>
In article <idikmsk36lfiip654a796atsb0sr2rgqco@4ax.com>, Ryin <Ryin@mailmenot.com> wrote:
>Have seen many javascript clocks get the time from users'
>systems. Is it possible to display a correct time from a
>time server when a page is viewed?
>
>Any input is welcome. Live example is better.
This is just a time display:
<IMG SRC="http://tycho.usno.navy.mil/cgi-bin/nph-usnoclock.gif?zone=PDT&ticks=04 " ALT="PDT Clock">
Good luck.
--
While my e-mail address is not munged, | T.Postel@ieee.org
I probably won't read anything sent there. |
------------------------------
Date: 10 Jul 2000 21:06:12 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: How to display the correct time from a time server on a page?
Message-Id: <slrn8mktpk.7v7.abigail@alexandra.delanet.com>
Ryin (Ryin@mailmenot.com) wrote on MMDV September MCMXCIII in
<URL:news:idikmsk36lfiip654a796atsb0sr2rgqco@4ax.com>:
`` Have seen many javascript clocks get the time from users'
`` systems. Is it possible to display a correct time from a
`` time server when a page is viewed?
#!/opt/perl/bin/perl -wT
use strict;
print <<__END__
Content-type: text/plain
Please look at your watch.
__END__
HTH. HAND.
Abigail
--
$_ = "\x3C\x3C\x45\x4F\x54\n" and s/<<EOT/<<EOT/ee and print;
"Just another Perl Hacker"
EOT
------------------------------
Date: 11 Jul 2000 01:09:11 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: intercept a return from Redirect
Message-Id: <slrn8mkst9.lk.efflandt@efflandt.xnet.com>
On Mon, 10 Jul 2000, zhuangv@my-deja.com <zhuangv@my-deja.com> wrote:
>I try to redirect to a remote URL which is composed of cgi-bin. However,
>the remote server returns a confirmation page. How can I intercept that
>or trash it?
You cannot intercept a redirect since the browser makes the request and
the result goes to the browser. But you could use one of the Perl modules
like LWP (libwww), IO::Socket or Socket in increasing order of difficulty.
If you need to POST something then LWP is your best bet.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: Tue, 11 Jul 2000 02:48:55 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Language Challenge -- Results
Message-Id: <x7d7klmlew.fsf@home.sysarch.com>
>>>>> "b" == bv <bvoh@sdynamix.com> writes:
b> We'd like to particularly encourage a visit by the younger generation
b> which probably never even saw a code without trailing semicolons, and to
b> those who are curious how to "roll your own" before purchasing expensive
b> optimization toolboxes.
b> To view the contest summary please click on the "Language Challenge
b> 2000" on http://sdynamix.com
what a stupid contest. the problem is a pure math one which is not
interesting to anyone other than fortran types. all the submissions were
in fortran and 1 in assembler. try coming up with a 'real world' problem
that involve complex data structures, communications, protocols or
whatever else but pure math. of course fortran is faster for this
problem as it was INVENTED for it. DUH!!
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: 10 Jul 2000 21:11:16 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: multidimensional associative arrays
Message-Id: <slrn8mku33.7v7.abigail@alexandra.delanet.com>
Philip Rennert (phil.rennert@ioip.com) wrote on MMDV September MCMXCIII
in <URL:news:3969DFA5.B7BE6B5E@ioip.com>:
__ When I have a multidimensional array, it's easy to fix one index and
__ iterate on another:
__
__ for($j=1;$j<=$n;$j++)
__ {
__
__ code involving $a[6][$j]
__
__ }
That's horrid, and anti-Perl.
foreach my $element (@{$a [6]}) { ... }
__ but what's a good way to do that with associative arrays, other than the
__ kludgey:
__
__ foreach( keys %a)
__ {
__ if not (/^Fred/){next}
__
__ code involving $a{$_} to deal with only elements of the form
__ $a{"Fred"}{whatever}
__
__ (also this assumes "Fred" doesn't occur in another index or in longer
__ form in the first)
__
__ }
Once you know the Perl way of doing the nested array, nested hashes
are trivial.
foreach my $key (keys %{$a {Fred}}) { ... }
or
while (my ($key, $value) = each %{$a {Fred}}) { ... }
Abigail
--
sub J::FETCH{Just }$_.='print+"@{[map';sub J::TIESCALAR{bless\my$J,J}
sub A::FETCH{Another}$_.='{tie my($x),$';sub A::TIESCALAR{bless\my$A,A}
sub P::FETCH{Perl }$_.='_;$x}qw/J A P';sub P::TIESCALAR{bless\my$P,P}
sub H::FETCH{Hacker }$_.=' H/]}\n"';eval;sub H::TIESCALAR{bless\my$H,H}
------------------------------
Date: Tue, 11 Jul 2000 03:55:10 GMT
From: an400@freenet.carleton.ca (Steve A. Taylor)
Subject: Re: Re-directing dos stderr stdout to file. How?
Message-Id: <396a99e8.1299061@news.ncf.carleton.ca>
On Mon, 10 Jul 2000 02:50:09 GMT, Bob Walton
<bwalton@rochester.rr.com> wrote:
>"Steve A. Taylor" wrote:
>...
>> Thanks. It still surprises me that the author(s) of find2perl created
>> a batch file rendered .. difficult or impractical .. because the
>> output I need is staring at me on the screen (Posting to CLPModules
>> may be another answer).
>
>Well, I think the find2perl folks probably did about as well as can be
>done and still have something that will work when you type "find2perl
>..." in DOS. You could nab the Perl program out of find2perl.bat (it is
>just a short .bat wrapper around a standard Perl program that runs as-is
>under Unix with no redirection problems) and then execute it as "perl
>find2perl.pl ...", which isn't quite as nice to type, but should permit
>redirection. If you want to castigate someone, castigate Micro$loth for
>the incredibly lousy job they did with their command "shell".
>--
>Bob Walton
No, not castigate -- understand the purpose and functionality of batch
files distributed with Perl; which would of course be easier if dos
was more unix.. The find2perl.pl script shows up in the source of
5.60.
------------------------------
Date: Tue, 11 Jul 2000 02:47:15 GMT
From: ynotssor@my-deja.com
Subject: Re: running system command as root from perl
Message-Id: <8ke1rg$nf7$1@nnrp1.deja.com>
In article <8kdhge$bpp$1@nnrp1.deja.com>,
kmhanser@my-deja.com wrote:
> Yeah, I had thought of having a cron running and checking for a
> file...
> you mention that restarting the server is different than reloading the
> conf file... I haven't been able to find in apache's dox/man pages how
> to make this happen w/out stopping and restarting the server. How can
> I get it to reload the conf w/out a restart?
>
> Also, I'd be interested to hear your security concerns. I'm always
> interested in what sort of holes I'm opening up :)
>
> As for the cron, that may be what I end up doing, I just thought there
> was a way I could su and restart the server/reload the config with the
> press of a button on a web form. Would be a neat trick. Regardless
> of if I use it for this or not, it still would be handy to know how to
> run a command as root...
...
Making the process suid is one possible solution:
$ ls -l killhttpd
-r-sr-x--- 1 root http 77 Jan 12 2000 killhttpd
This allows whatever group your cgi scripts run as (http in this
example) to HUP the apache daemon, which parent process runs as root and
children as nobody.
The killhttpd program is a trivial script:
#!/bin/sh
kill -HUP `ps -aef | grep httpd | grep -v grep | awk '{print $2}'`
- tony
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 10 Jul 2000 23:08:00 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: running system command as root from perl
Message-Id: <brian-ya02408000R1007002308000001@news.panix.com>
In article <8ke1rg$nf7$1@nnrp1.deja.com>, ynotssor@my-deja.com posted:
> The killhttpd program is a trivial script:
>
> #!/bin/sh
> kill -HUP `ps -aef | grep httpd | grep -v grep | awk '{print $2}'`
that won't work for many reasons, and it's just dumb. if you had
read the apache docs, you would have discovered that you want the
USR1 signal and the PID file.
kill -USR1 `cat /etc/httpd.pid`
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Tue, 11 Jul 2000 01:07:26 GMT
From: dwilson@gtemail.net (Douglas Wilson)
Subject: Re: Shuffling an array
Message-Id: <396a705e.961711@news>
On Mon, 10 Jul 2000 22:39:07 GMT, "Marcus Ouimet" <mouimet@direct.ca> wrote:
>I have been trying to shuffle an array for a while, I have read all the
>faq's etc. And this is where I am.
Did you read this part of the perldoc?
perldoc -q shuffle
I've read all the faq's too. But I can't remember everything I've read either.
HTH,
Douglas Wilson
------------------------------
Date: 10 Jul 2000 22:25:15 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Shuffling an array
Message-Id: <slrn8ml2dr.7v7.abigail@alexandra.delanet.com>
Marcus Ouimet (mouimet@direct.ca) wrote on MMDV September MCMXCIII in
<URL:news:fgsa5.102456$Do1.1116067@news1.rdc1.bc.home.com>:
$$ I have been trying to shuffle an array for a while, I have read all the
$$ faq's etc. And this is where I am. I want to shuffle my array and display
$$ multiple items at a time not just one. ie if someone searchs for a city it
$$ brings up all the members in a random order. If someone could take a look at
$$ what I am doing, and give me some directions or help it would be most
$$ appreciated, thanks - here is is:
You have read the FAQ? Really? The FAQ has an algorithm to shuffle
an array. Yet, I don't see a single trace of that in your program.
$$ srand(time ^ $$);
The FAQ also explains why this is very, very, very bad.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Mon, 10 Jul 2000 20:22:24 -0700
From: "Marcus Ouimet" <mouimet@direct.ca>
Subject: Re: Shuffling an array
Message-Id: <6mwa5.11645$BS1.339272@brie.direct.ca>
Yes I did read it, I am new to perl and couldn't get it to shuffle any other
way. I was at least able to get srand to work. Anyways...
Abigail <abigail@delanet.com> wrote in message
news:slrn8ml2dr.7v7.abigail@alexandra.delanet.com...
> Marcus Ouimet (mouimet@direct.ca) wrote on MMDV September MCMXCIII in
> <URL:news:fgsa5.102456$Do1.1116067@news1.rdc1.bc.home.com>:
> $$ I have been trying to shuffle an array for a while, I have read all the
> $$ faq's etc. And this is where I am. I want to shuffle my array and
display
> $$ multiple items at a time not just one. ie if someone searchs for a city
it
> $$ brings up all the members in a random order. If someone could take a
look at
> $$ what I am doing, and give me some directions or help it would be most
> $$ appreciated, thanks - here is is:
>
> You have read the FAQ? Really? The FAQ has an algorithm to shuffle
> an array. Yet, I don't see a single trace of that in your program.
>
> $$ srand(time ^ $$);
>
> The FAQ also explains why this is very, very, very bad.
>
>
>
> Abigail
> --
> perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Mon, 10 Jul 2000 20:43:55 -0700
From: "Marcus Ouimet" <mouimet@direct.ca>
Subject: Sill can't figure out random array
Message-Id: <hGwa5.11648$BS1.339201@brie.direct.ca>
I figure I should reword a previous post of mine. I have read the perl faq,
in fact the part about shuffling an array is pasted below. Problem is it
doesn't explain it very well for someone who has never done it. Has anyone
seen a working example of this I tried to do a little test script and didn't
get very far... any help/examples appreciated. I have been trying to figure
this out for sometime and it is most likely something little I am
overlooking.
How do I shuffle an array randomly?
Use this:
# fisher_yates_shuffle( \@array ) :
# generate a random permutation of @array in place
sub fisher_yates_shuffle {
my $array = shift;
my $i;
for ($i = @$array; --$i; ) {
my $j = int rand ($i+1);
next if $i == $j;
@$array[$i,$j] = @$array[$j,$i];
}
}
fisher_yates_shuffle( \@array ); # permutes @array in place
------------------------------
Date: Tue, 11 Jul 2000 02:39:45 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: String length?
Message-Id: <x7g0phmlu7.fsf@home.sysarch.com>
>>>>> "JS" == John Stanley <stanley@skyking.OCE.ORST.EDU> writes:
JS> $string = 'a test string';
JS> $me=$ENV{'USER'};
JS> $now = `mail | head -1`;
JS> $now = $1 if /: (\d+) message/;
what is $_ set to?
JS> @arry = split( //, $string );
JS> foreach $i (@arry) {
JS> `echo $i | mail $me`;
JS> }
JS> $then = `mail | head -1`;
JS> $then = $1 if /: (\d+) message/;
same here?
JS> print "length = ", $then-$now, "\n";
and what if you got mail during the execution of this?
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: 11 Jul 2000 03:01:09 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: String length?
Message-Id: <8ke2ll$d05$1@news.NERO.NET>
In article <x7g0phmlu7.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "JS" == John Stanley <stanley@skyking.OCE.ORST.EDU> writes:
>
> JS> $string = 'a test string';
> JS> $me=$ENV{'USER'};
>
> JS> $now = `mail | head -1`;
> JS> $now = $1 if /: (\d+) message/;
>
>what is $_ set to?
You actually wanted to use this code in production?
>and what if you got mail during the execution of this?
You lose.
------------------------------
Date: Tue, 11 Jul 2000 03:10:23 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: String length?
Message-Id: <x78zv9mkf4.fsf@home.sysarch.com>
>>>>> "JS" == John Stanley <stanley@skyking.OCE.ORST.EDU> writes:
JS> In article <x7g0phmlu7.fsf@home.sysarch.com>,
JS> Uri Guttman <uri@sysarch.com> wrote:
>>>>>>> "JS" == John Stanley <stanley@skyking.OCE.ORST.EDU> writes:
>>
JS> $string = 'a test string';
JS> $me=$ENV{'USER'};
>>
JS> $now = `mail | head -1`;
JS> $now = $1 if /: (\d+) message/;
>>
>> what is $_ set to?
JS> You actually wanted to use this code in production?
well, most of the code in this thread actually worked even if they were
very slow or whatever. and i didn't notice any purely extraneous code as
those two regex statements seem to be. since $_ is not set anywhere and
can be assumed to be undef (or junk) those statements are meaningless as
they will never modify $now/$then
>> and what if you got mail during the execution of this?
JS> You lose.
and so do you. most of the other posts were entertaining. this one
wasn't.
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: 11 Jul 2000 03:24:00 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: String length?
Message-Id: <8ke40g$drd$1@news.NERO.NET>
In article <x78zv9mkf4.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
> >> what is $_ set to?
>
> JS> You actually wanted to use this code in production?
>
>well, most of the code in this thread actually worked even if they were
>very slow or whatever.
If I had thought anyone wanted to actually use the code, I would have
tested it thoroughly. I'd have included the shebang line, and would have
caught that $_ was unset.
> JS> You lose.
>
>and so do you. most of the other posts were entertaining. this one
>wasn't.
Lighten up. It was a joke. I'm sorry you didn't find it funny. Maybe
by your reaction I win the most ridiculous way to length a string
award.
------------------------------
Date: 10 Jul 2000 21:20:18 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: this newsgroup
Message-Id: <slrn8mkuk2.7v7.abigail@alexandra.delanet.com>
Day (reui@fdd.ff) wrote on MMDV September MCMXCIII in
<URL:news:8kdm15$iho$9@sunce.iskon.hr>:
,,
,, What for exactly is this news group?
To discuss the effect of broken beaks on the sexlife of woodpeckers.
Except for the red-tailed European woodpecker, who has its own subgroup.
And the moderated group is for the R and X rated stuff.
Abigail
--
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";`$@`'
------------------------------
Date: Tue, 11 Jul 2000 03:31:26 +0200
From: Juergen Pfann <Juergen.pfann@t-online.de>
Subject: Re: this newsgroup
Message-Id: <396A78EE.96A8667E@t-online.de>
Abigail wrote:
>
> Day (reui@fdd.ff) wrote on MMDV September MCMXCIII in
> <URL:news:8kdm15$iho$9@sunce.iskon.hr>:
> ,,
> ,, What for exactly is this news group?
>
> To discuss the effect of broken beaks on the sexlife of woodpeckers.
I thought we're talking about camels here...
One never ends learning.
LOL
>
> Except for the red-tailed European woodpecker, who has its own subgroup.
>
> And the moderated group is for the R and X rated stuff.
>
> Abigail
Juergen
------------------------------
Date: Mon, 10 Jul 2000 19:46:01 -0700
From: vaton@postoffice.pacbell.net
Subject: Trouble Installing Modules
Message-Id: <396A8A69.44D7398E@postoffice.pacbell.net>
Help! I'm having a problem installing Perl modules dowloaded from CPAN
(specifically QT and Tk).For each file, when I type in these commands
(as directed in the INSTALL files):
perl Makefile.PL
make
make test
make install
,I get errors similar to these (from a compile attempt of TK):
IO.xs: In function `XS_Tk__IO_read':
IO.xs:170: `sv_undef' undeclared (first use in this function)
IO.xs:170: (Each undeclared identifier is reported only once
IO.xs:170: for each function it appears in.)
IO.xs: In function `XS_Tk__IO_readline':
IO.xs:217: `sv_undef' undeclared (first use in this function)
make[1]: *** [IO.o] Error 1
make: *** [subdirs] Error 2
And, when I try to run the associated examples (Perl scripts),
I get these errors:
Can't locate auto/Tk/autosplit.ix in @INC (@INC contains:
/usr/local/lib/perl5/5.6.0/i686-linux /usr/local/lib/perl5/5.6.0
/usr/local/lib/perl5/site_perl/5.6.0/i686-linux
/usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl .)
at /usr/local/lib/perl5/5.6.0/AutoLoader.pm line 133.
at Tk.pm line 12
Can't locate loadable object for module Tk in @INC (@INC contains:
/usr/local/lib/perl5/5.6.0/i686-linux /usr/local/lib/perl5/5.6.0
/usr/local/lib/perl5/site_perl/5.6.0/i686-linux
/usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl .)
at ./demos/widget line 22
Compilation failed in require at ./demos/widget line 22.
BEGIN failed--compilation aborted at ./demos/widget line 22.
Does anyone have any suggestions? ~Robert Shockley~
------------------------------
Date: Mon, 10 Jul 2000 20:13:43 -0700
From: vaton@postoffice.pacbell.net
Subject: Trouble Installing Modules
Message-Id: <396A90E7.C7A8E447@postoffice.pacbell.net>
Help! I'm having a problem installing Perl modules dowloaded from CPAN
(specifically QT and Tk).For each file, when I type in these commands
(as directed in the INSTALL file):
perl Makefile.PL
make
make test
make install
,I get errors similar to these (from a compile attempt of TK):
IO.xs: In function `XS_Tk__IO_read':
IO.xs:170: `sv_undef' undeclared (first use in this function)
IO.xs:170: (Each undeclared identifier is reported only once
IO.xs:170: for each function it appears in.)
IO.xs: In function `XS_Tk__IO_readline':
IO.xs:217: `sv_undef' undeclared (first use in this function)
make[1]: *** [IO.o] Error 1
make: *** [subdirs] Error 2
And, when I try to run the associated examples (Perl scripts),
I get these errors:
Can't locate auto/Tk/autosplit.ix in @INC (@INC contains:
/usr/local/lib/perl5/5.6.0/i686-linux /usr/local/lib/perl5/5.6.0
/usr/local/lib/perl5/site_perl/5.6.0/i686-linux
/usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl .)
at /usr/local/lib/perl5/5.6.0/AutoLoader.pm line 133.
at Tk.pm line 12
Can't locate loadable object for module Tk in @INC (@INC contains:
/usr/local/lib/perl5/5.6.0/i686-linux /usr/local/lib/perl5/5.6.0
/usr/local/lib/perl5/site_perl/5.6.0/i686-linux
/usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl .)
at ./demos/widget line 22
Compilation failed in require at ./demos/widget line 22.
BEGIN failed--compilation aborted at ./demos/widget line 22.
Does anyone have any suggestions? ~Robert Shockley~
------------------------------
Date: Tue, 11 Jul 2000 02:11:24 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: warning??
Message-Id: <396A82A0.96EDA550@rochester.rr.com>
>Marc Holder wrote:
>
> Does anybody know what the warning:
>
> print (...) interpreted as function at xasm.pl line 157.
>
> Is refering to when I run a perl script with the -w argument?
>
> for the line
> exists ($opcode{$op}) or print ("WRN<MAIN-parse1.$ln> opcode
>
> \`$op\' undefined => statement ignored\n"), next;
It means your parens would be better located as follows:
exists ($opcode{$op}) or (print "WRN<MAIN-parse1.$ln> opcode \`$op\'
undefined => statement ignored\n"), next;
You could learn more about what is potentially wrong with:
use diagnostics;
and maybe
perldoc -f print
In your case, Perl DWYW, so the warning could be ignored. In case the
above isn't clear to you after you look it up: An expression of the
form
... bareword (some-expression),bareword
*could* be interpreted two ways:
1. as a list operator followed by two arguments, the first of which is
enclosed in parens
or
2. as a function name followed by argument(s) inside parens followed by
a comma operator followed by an expression
The warning is to let you know that Perl chose option 2.
--
Bob Walton
------------------------------
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 3616
**************************************