[11582] in Perl-Users-Digest
Perl-Users Digest, Issue: 5182 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 19 18:07:41 1999
Date: Fri, 19 Mar 99 15:00:23 -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 Fri, 19 Mar 1999 Volume: 8 Number: 5182
Today's topics:
Re: $var$i or what? <tsawyer@telcom.lgb.cal.boeing.com>
Re: $var$i or what? (Greg Bacon)
Re: 9-3748fh*42-06815.831.2an (Larry Rosler)
Re: Algorithm to split words into "encyclopedia labels" (Tad McClellan)
Announcing GrandRapids.pm Lunch Gathering Friday, March joelm@poboxes.com
Re: Any idea to generate charts under Linux ? (John Stanley)
Re: Array-Sort (Larry Rosler)
Re: Bug with s/$pat/$sub/ (or not?) (Tad McClellan)
Re: Can't read a text file with weird characters in it. (Tad McClellan)
Re: Date Conversion <jglascoe@giss.nasa.gov>
dir command in perl? <josri@earthlink.net>
Re: Finding the size of a scalar (Tad McClellan)
getting keys of hashes of hashes <dwatanab@uci.edu>
Help with Perl's multithread!!! <ple@mitra.com>
Re: inserting large numbers into databases (Tad McClellan)
Re: more on & in a filename <zzhao@execulink.com>
Re: Mysterious Perl Bug (Abigail)
Re: Need help on a algorithm (Tad McClellan)
Re: Net::NNTP (Alastair)
PERl and Server Side Includes <sme@planetpod.com>
Re: Perl win32 <josri@earthlink.net>
Re: Please Help I'm an Idiot <ruedas@geophysik.uni-frankfurt.de>
Re: Please Help I'm an Idiot (Tad McClellan)
Re: Q: format and write <ebohlman@netcom.com>
question....@ISA /my @ISA bhaskaracharya@my-dejanews.com
Re: question....@ISA /my @ISA (Greg Bacon)
quick string match checks <dwatanab@uci.edu>
Re: rand() Performance (Abigail)
Re: Reading a file into a hash (Tad McClellan)
Searching binary file without slurping whole thing? (Chris Sherman)
Re: Substitution question (Tad McClellan)
Re: TCGREP in Perl Cookbook (Christian M. Aranda)
Re: The truth about the Pentium III chip and ID --- **b (Craig Dowell)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 19 Mar 1999 14:14:42 -0800
From: Tim Sawyer <tsawyer@telcom.lgb.cal.boeing.com>
Subject: Re: $var$i or what?
Message-Id: <36F2CC52.56E6B87A@telcom.lgb.cal.boeing.com>
Greg Bacon wrote:
> Then load them into a hash:
>
> my @var;
> for ($query->param) {
> if (/^var(\d+)$) {
> $var[$1] = $query->param($_);
> }
> }
>
Thanks, I like that idea.
>
> : I couldn't figure out how to get CGI.pm to keep the state of the form
> : checkboxes because unchecked boxes have no value. So if the user check
> : boxes 1 and 5, when the form reloaded checkboxes 1 and 2 would be
> : checked.
>
> Don't CGI.pm's sticky values address this problem?
>
Interesting idea... looking it up in Lincoln's book.
>
> : Perhaps this really was a CGI.pm question but you know how this group
> : flames those questions.
>
> That's an unfair characterization. I challenge you to provide
> evidence for your claim. CGI problems that are unrelated to Perl
> (i.e., a problem at the protocol level--independent of the language
> in which one is implementing the CGI application) may elicit flames,
> but that's only fair because there *is* ciwac, you know.
>
I didn't save the thread, but it did happen to me. But that was another time
and I'm grateful for the capable help I'm getting today.
>
> Greg
> --
> Why do people give each other flowers? To celebrate various important
> occasions, they're killing living creatures? Why restrict it to plants?
> "Sweetheart, let's make up. Have this deceased squirrel."
> -- Jerry Seinfeld
--
Tim Sawyer (562) 988-3722
IBM Global Services - Network Services
3300 E. Spring Street, Long Beach, CA 90806
Boeing Intranet - http://advweb.lgb.cal.boeing.com
------------------------------
Date: 19 Mar 1999 22:52:33 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: $var$i or what?
Message-Id: <7cukfh$6vr$1@info2.uah.edu>
In article <36F2CC52.56E6B87A@telcom.lgb.cal.boeing.com>,
Tim Sawyer <tsawyer@telcom.lgb.cal.boeing.com> writes:
: Greg Bacon wrote:
: > Then load them into a hash:
Errr.. s/a hash/an array/
: > my @var;
: > for ($query->param) {
: > if (/^var(\d+)$) {
: > $var[$1] = $query->param($_);
: > }
: > }
Argh... that for loop should be
for ($query->param) {
if (/^var(\d+)$/) {
$var[$i] = $query->param($_);
}
}
Sorry for any confusion I may have caused. No soup for me.
Greg
--
Democracy: Two wolves and a sheep voting on what's for dinner.
------------------------------
Date: Tue, 16 Mar 1999 21:09:06 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: 9-3748fh*42-06815.831.2an
Message-Id: <MPG.1158d8c67752a8b298976b@nntp.hpl.hp.com>
In article <10N6uy-0005aZ-00@drule.org> on 17 Mar 1999 03:22:56 -0000,
Anonymous <Use-Author-Address-Header@[127.1] >says...
<SNIP 1551 lines of bullshit>
What did the Perl newsgroup do to deserve this punishment? Please tell
us, lest we sin again and be punished again.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 19 Mar 1999 09:37:19 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Algorithm to split words into "encyclopedia labels"
Message-Id: <ventc7.981.ln@magna.metronet.com>
Paul J. Lucas (pjl@be-NOSPAM-st.com) wrote:
: In <QVnI2.170$rP1.6471@ptah.visi.com> sgrantz@visi.com (Steve Grantz) writes:
: OK, how about s simpler problem: what's an easy way in Perl to
: tell how much of two strings match?
: $a = 'Hello';
: $b = 'Helicopter';
: $c = f( $a, $b );
: where $c is 'Hel' without doing a lot of looling of checking
: character by character?
How's this?
-------------------
sub prefix {
my($s1, $s2) = @_;
if ( length $s1 > length $s2 ) # normalize to shortest length
{ substr($s1, length $s2) = '' }
else
{ substr($s2, length $s1) = '' }
while ( length $s1 ) {
return $s1 if $s1 eq $s2; # found a prefix
chop $s1;
chop $s2;
}
return ''; # no common prefix
}
-------------------
: >: E-mail replies preferred.
: >: it's a problem for my
: >: real day job.
: >OK, but I'm still not going to e-mail the response.
: And why not?
Maybe because there just might be others on the newsgroup
who want to see the answer too?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 19 Mar 1999 22:22:39 GMT
From: joelm@poboxes.com
Subject: Announcing GrandRapids.pm Lunch Gathering Friday, March 26th, 1999
Message-Id: <7cuimp$tb8$1@nnrp1.dejanews.com>
The Grand Rapids Perl Mongers next monthly lunch meeting will be held on
Friday, March 26th, 1999 at 11:30am at the Pizza Hut near the intersection of
the U.S. 131 expressway and 44th street in Wyoming, MI.
All are invited. If you plan to attend, please email Joel Meulenberg at
joelm@bigfoot.com.
The meeting agenda is as follows:
Grand Rapids Perl Mongers
Meeting Agenda For March 26, 1999
Meeting Place: Pizza Hut at 131 & 44th @ 11:30AM
I. Introductions
II. Old Business
A. GR.PM Web Page - Ed Eddington
B. Books from O'Reilly - Bill Gathen
C. Perl Training In West Michigan - Bill Gathen
D. Newsgroups and Advocacy - Joel Meulenberg
III. New Business
A. Perl Power Tools Project - Joel Meulenberg
B. CGI Application Contest - Matt Heusser
C. Meeting Format - Matt Heusser
D. Ideas - At-large
E. Next Meeting Place
--
+Joel Meulenberg
joelm@bigfoot.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 19 Mar 1999 21:36:29 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Any idea to generate charts under Linux ?
Message-Id: <7cug0t$69d$1@news.NERO.NET>
In article <7cttcs$bjh$1@imsp009a.netvigator.com>,
Y W Wong <ywwong_hk@hotmail.com> wrote:
>Any idea about what tools or language should be used ?
Gnuplot is good. Matlab is good. IDL would probably work. Plotxy is very
nice.
------------------------------
Date: Tue, 16 Mar 1999 21:21:04 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Array-Sort
Message-Id: <MPG.1158db9fcdfdbeae98976c@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <36EF2C3F.B61085B6@pyro.net> on Tue, 16 Mar 1999 23:14:55 -
0500, Michael C. Brittain <britts@pyro.net >says...
> I am wary of asking this question for fear of getting flamed as a moron,
> but what is a Schwartzian Transform anyway? I did look for refereneces to
> it in the camel, so please don't give me that...
You could have tried searching the Web or DejaNews before asking this
question! However...
Start with perlfaq4: "How do I sort an array by (anything)?".
If you are still interested, follow the hyperlink there to
<http://www.perl.com/CPAN/doc/FMTEYEWTK/sort.html>.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 19 Mar 1999 09:52:31 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Bug with s/$pat/$sub/ (or not?)
Message-Id: <fbotc7.981.ln@magna.metronet.com>
Olaf Seibert (rhialto@polder.ubc.kun.nl) wrote:
: #!/usr/bin/env perl
You are missing the -w switch there...
: This looks like a bug.
Looks can be deceiving :-)
It is doing what it is supposed to do.
: Is there a workaround?
Yes. Kinda. See below.
: use strict;
: my $line0 = 'AA';
: # This does not work, using expressions for pattern and substitution:
: my $pat = '(A)';
: my $sub = '-\1-';
: my $line = $line0;
: $line =~ s/$pat/$sub/g;
You asked for four characters to be substituted, so that
is what perl did.
If that is not what you want, then ask for something else.
You only get one round of interpolation in the replacement
string. It interpolates the value of $sub. You need another
round to interpolate the backreference contained in $sub.
: print "line = $line\n";
: # This does work, using hardcoded pattern and substitution:
: $line = $line0;
: $line =~ s/(A)/-\1-/g;
^^
^^ that should be $1, not \1
: print "line = $line\n";
my $sub = '"-$1-"';
...
$line =~ s/$pat/$sub/gee;
^^
^^ two rounds of evaluation. First expands
$sub, second expands $1
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 19 Mar 1999 09:56:35 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Can't read a text file with weird characters in it. Help.
Message-Id: <3jotc7.981.ln@magna.metronet.com>
Jason Stanley (jstanley@mmm.com) wrote:
: I am trying to read through the text file below, but when it hits the odd
: (ascii?) characters it won't read the rest of the file. How do I get it to
: ignore all the strange characters and read all the words.
If you are on a M$ "OS", then have a look at 'binmode'
in the perlfunc.pod.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 19 Mar 1999 16:25:55 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Jim Eichert <jim_eichert@jhuapl.edu>
Subject: Re: Date Conversion
Message-Id: <36F2C0E3.C318E1A9@giss.nasa.gov>
[courtesy copy of post sent to cited author]
Jim Eichert wrote:
>
> Does anyone know how to convert a date in YEAR, DAY-OF-YEAR format to
> YEAR, MONTH, DAY-OF-MONTH format? Thanks in advance.
perldoc -f localtime
perldoc Time::Local
use Time::Local;
use strict;
my $ep_secs = ($day_of_year - 1) * 24 * 60 * 60 +
timelocal(0,0,0,1,0,$year);
my ($year, $month, $day_of_month) = (localtime($ep_secs))[5,4,3];
"$month" ranges from (0..11). "$year" is the number of years since
1900. "$day_of_month" ranges from (1..31).
Jay Glascoe
--
"ping."
------------------------------
Date: Fri, 19 Mar 1999 14:20:34 -0800
From: josri <josri@earthlink.net>
Subject: dir command in perl?
Message-Id: <36F2CDB2.A024A42@earthlink.net>
hi
how can i run "dir" command with perl in windows?
I tried
$dir='dir';
------------------------------
Date: Fri, 19 Mar 1999 10:15:42 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Finding the size of a scalar
Message-Id: <umptc7.981.ln@magna.metronet.com>
Frank Hale (frankhale@worldnet.att.net) wrote:
: Say I want to have a scalar that stores a string and I don't want it to
: be larger than 256kb how can I get the size of it to test for this?
print "string is too large\n" if length $str > 256 * 1024;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 19 Mar 1999 14:19:08 -0800
From: =?iso-8859-1?Q?d=E1na?= watanabe <dwatanab@uci.edu>
Subject: getting keys of hashes of hashes
Message-Id: <36F2CD4C.DEB51BD3@uci.edu>
I'm trying to be incredibly lazy and avoid declaring (or 'my'ing) variables
for foreach statements by giving up on foreach altogether
and just using for (which gives you $_ which is a lot less work to type anyway)
But i've created a hash of a hash of a hash and was wondering if i could
'for' through it.
Three questions:
Is this possible?
Is this possible, but bad to do?
Is using for instead of foreach bad?
An example since i'm sure that description isn't clear:
$a{a}{b}{c}=1;
$a{a}{b}{d}=2;
$a{a}{b}{e}=3;
$a{c}{b}{e}=4;
$a{c}{d}{e}=5;
for (keys %a) {
for (keys %{$a{$_}}) {
for (keys %{$a{???}{$_}}) { <--- what to do here?
}
}
}
------------------------------
Date: Fri, 19 Mar 1999 16:26:53 -0500
From: Phuong Le <ple@mitra.com>
Subject: Help with Perl's multithread!!!
Message-Id: <36F2C11D.F842B6BE@mitra.com>
Hi
I am having a problem with Perl's multithread and I hope that someone
can help. First I would like to thank everyone in the newsgroup that
are trying to help.
Here my problem along with the perl code:
I am trying to start up two threads namely $t1 and $t2 and both of them
having access to the global variable $x which initialize to 0 at the
beginning. Thread $t1 can only proceed iff $x is not 0. What I am
trying to do is having thread $t1 wait on the variable $x and have
thread $t2 set the variable $x to 1 and unblock thread $t1. The
following is my code. Can somebody pointed out what I did wrong along
with suggestions. Once again many thanks.
Phuong Le
-----------------------------------------------------------
#!/bin/perl
use strict;
use Thread;
my $x = 0;
my $t1 = new Thread \&f1;
my $t2 = new Thread \&f2;
sub f1
{
lock $x;
print "t1 acquired lock\n";
if ( $x != 0 )
{
print "proceeding!!!\n";
}
else
{
while( 1 )
{
print "Waiting for x to become non zero\n";
lock $x;
print "t1 acquired lock\n";
Thread::cond_wait( $x );
print "Wait complete\n";
lock $x;
print "t1 acquired lock\n";
if ( $x != 0 )
{
print "proceeding!!!\n";
last;
}
#
# If I remove this sleep than everything seem to work
#
sleep 1;
}
}
}
sub f2
{
{
lock $x;
print "t2 acquired lock\n";
$x = 0;
print "About to send a signal\n";
Thread::cond_signal( $x );
print "Signal had been send\n";
}
sleep 1;
{
lock $x;
print "t2 acquired lock\n";
$x = 1;
print "About to send a signal\n";
Thread::cond_signal( $x );
print "Signal had been send\n";
}
}
---------------------------------------------------
Here is the ouptput:
t1 acquired lock
t1 acquired lock
Waiting for x to become non zero
t2 acquired lock
About to send a signal
Signal had been send
Wait complete
t1 acquired lock
t1 acquired lock
Waiting for x to become non zero
------------------------------
Date: Fri, 19 Mar 1999 10:18:16 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: inserting large numbers into databases
Message-Id: <orptc7.981.ln@magna.metronet.com>
chortik@my-dejanews.com wrote:
: Is it possible to prevent perl from casting a 17 digit long string into a
: double before it is inserted into a database. the field in the database
: table is set to recieve a 17 character string, but perl casts it into a
: double, chopping off the least significat digit. is there a way around this?
Treat the number as a string instead of as a number.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 19 Mar 1999 16:32:43 -0500
From: "Jerry Zhao" <zzhao@execulink.com>
Subject: Re: more on & in a filename
Message-Id: <7cufuk$rmm$1@goblin.uunet.ca>
It turns out that my problem has nothing to do with the '&' in the filename.
The new datafile I created did not follow the format required by my perl
program ...
Sorry about it! I need to start documenting my own codes
------------------------------
Date: 19 Mar 1999 21:09:24 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Mysterious Perl Bug
Message-Id: <7cuee4$47u$1@client2.news.psi.net>
Craig (cart@dansie.net) wrote on MMXXV September MCMXCIII in
<URL:news:36F14B76.111B161D@dansie.net>:
~~
~~ I have a large script about 200k running on Perl 5.00502. It gives an
~~ Internal Server Error when it comes to the second line listed below:
~~
~~ open(FILE,"$path");
~~ @lines = <FILE>;
~~ close(FILE);
~~
~~ The file located at $path does exist by the way. When I take the same
~~ three lines of code and run them in a smaller script, they work fine.
~~ Does anyone know why the second line of code causes a larger script to
~~ error out but not a smaller script?
No, and that's due to the fact you don't bother to check the return
value of open. Nor do you bother to look up any potential messages
in your server error log.
If you can't be bothered to do even to most basic work yourself, why
do you think asking here is appropriate?
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Fri, 19 Mar 1999 10:13:58 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Need help on a algorithm
Message-Id: <mjptc7.981.ln@magna.metronet.com>
Frank Hale (frankhale@worldnet.att.net) wrote:
: Okay I have a problem. I have a file which has records consisting of 5
: fields like so
: i:1
: n:John Smith
: e:me@somewhere.com
: d:19 Mar 1999
: s:some text here
: Okay there are multiple records. I have a hash which I store the index
: of the records to be deleted. I need to rewrite the file with only the
: records I want to keep.
Perl FAQ, part 5:
"How do I change one line in a file/
delete a line in a file/
insert a line in the middle of a file/
append to the beginning of a file?"
: I can't figure out the algorithm to do this.
Loop over all your records printing those you want to keep
to a temp file.
Move (rename) the temp file over the original file when you are done.
: **Okay here is a summary of my problem**
: I have a hash I store the indexes that need to be deleted which looks
: like so
: Say I had 5 messages
: 1=1
: 2=1
: 3=0
: 4=0
: 5=0
: This means records 1 and 2 need to be deleted and I need to rewrite the
: file so that 3,4,5 are the only records there.
: Could someone offer a psuedo-code algorithm on how to do this? I would
: greatly appreciate it.
open TEMP file
foreach record
print TEMP record unless $delete{$id} == 1;
rename TEMP file over original file
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 19 Mar 1999 22:30:45 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Net::NNTP
Message-Id: <slrn7f5k4i.5f.alastair@calliope.demon.co.uk>
Joao Luis Bonina - LEI <jlmab@students.si.fct.unl.pt> wrote:
> Hi!
> Please, where can I find a manual about this module?
Perldoc Net::NNTP
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Fri, 19 Mar 1999 14:44:40 -0800
From: Stewart Eastham <sme@planetpod.com>
Subject: PERl and Server Side Includes
Message-Id: <36F2D358.158D1088@planetpod.com>
I am trying to call a PERL script through a Server Side Include on an
HTML page. That part I have working fine. The next step is to have the
Server Side Include pass parameters to the script when it invokes it.
This I have not figured out how to do.
The code I'm using to run a script with no parameters is:
<!--#exec cmd="helloworld.cgi"-->
But I can't figure out, or locate on-line, how to pass parameters to
this script.
Any help would be greatly appreciated.
thank you
stewart
sme@planetpod.com
------------------------------
Date: Fri, 19 Mar 1999 14:08:30 -0800
From: josri <josri@earthlink.net>
Subject: Re: Perl win32
Message-Id: <36F2CADE.3195909E@earthlink.net>
Yes, you can!
There are many, but I like perl/tk
Martijn Schrier wrote:
> Does anybody know if it is possible to make a little GUI Program for
> Windows 95/98 with the Perl (Win32 edition) ??
>
> Tnx
>
> Martijn Schrier
>
> --
> OnderwijsGroep Haaglanden Afd. Technische Informatica
> Marcellus Emantslaan 19 - 2274 XL - Voorburg - The Netherlands
> Tel: +31(0)70-3009900 - Fax: +31(0)70-3009910
> Email: M.Schrier@ti.ogh.nl - Web: http://www.ti.ogh.nl
------------------------------
Date: Fri, 19 Mar 1999 21:57:48 +0100
From: Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de>
To: Michael Stow <thurlow@clara.co.uk>
Subject: Re: Please Help I'm an Idiot
Message-Id: <36F2BA4C.167E@geophysik.uni-frankfurt.de>
>How can I get forms to run perl scripts without the browsers attempting
>to download them?
I'm not sure if I understand you right, but your question doesn't seem
to address a perl programming problem, but a problem of web authoring (a
topic which this NG is not dedicated to).
Your HTML file containing the form should contain a line similar to the
following:
<form method="get" action="cgi-bin/yourscript.pl">
as the beginning of the form; method could also be "post" (depends on
server conf). Maybe comp.infosystems.www.authoring.cgi is more
appropriate for your question.
HTH,
--
--------------------------------------------
Thomas Ruedas
Institute of Meteorology and Geophysics,
J.W. Goethe University Frankfurt/Main
Feldbergstrasse 47 D-60323 Frankfurt/Main, Germany
Phone:+49-(0)69-798-24949 Fax:+49-(0)69-798-23280
e-mail: ruedas@geophysik.uni-frankfurt.de
http://www.geophysik.uni-frankfurt.de/~ruedas/
--------------------------------------------
------------------------------
Date: Fri, 19 Mar 1999 10:49:23 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Please Help I'm an Idiot
Message-Id: <3mrtc7.je1.ln@magna.metronet.com>
Michael Stow (thurlow@clara.co.uk) wrote:
: Subject: Please Help I'm an Idiot
^^^^^
You are in luck!
There is a FAQ with your name in it :-)
Here are some snippets from the Perl FAQs to get you started:
http://www.perl.com/perl/faq/idiots-guide.html
http://www.perl.com/perl/faq/perl-cgi-faq.html
ftp://rtfm.mit.edu/pub/usenet/news.answers/www/cgi-faq
http://hoohoo.ncsa.uiuc.edu/cgi/interface.html
http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
-----
=head2 Where can I learn about CGI or Web programming in Perl?
For modules, get the CGI or LWP modules from CPAN. For textbooks,
see the two especially dedicated to web stuff in the question on
books. For problems and questions related to the web, like ``Why
do I get 500 Errors'' or ``Why doesn't it run from the browser right
when it runs fine on the command line'', see these sources:
WWW Security FAQ
http://www.w3.org/Security/Faq/
Web FAQ
http://www.boutell.com/faq/
CGI FAQ
http://www.webthing.com/page.cgi/cgifaq
HTTP Spec
http://www.w3.org/pub/WWW/Protocols/HTTP/
HTML Spec
http://www.w3.org/TR/REC-html40/
http://www.w3.org/pub/WWW/MarkUp/
CGI Spec
http://www.w3.org/CGI/
CGI Security FAQ
http://www.go2net.com/people/paulp/cgi-security/safe-cgi.txt
: I want to learn Perl for developing Web applications.
: I'm using Active Perl api509e (should I be?)
: I run Windows 98 (ditto)
: How can I get forms to run perl scripts without the browsers attempting to
: download them?
You need to install an HTTP server.
There are some free ones available.
See also:
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Good luck!
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 19 Mar 1999 22:38:59 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Q: format and write
Message-Id: <ebohlmanF8v5L0.J44@netcom.com>
Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de> wrote:
: #!/usr/local/bin/perl5
Missing -w.
Missing 'use strict'.
: # analyze web access logfile
: @srchstr=("geophys","ruedas");
: foreach (@srchstr) { $hits{$_}=0; }
Unnecessary--hash elements get initialized to zero when created.
: $acclog="/usr/local/etc/httpd/logs/access_log";
: unless (-e $acclog || -r $acclog) { die "No file $acclog \b.\n"; }
: open (ACCLOG,"$acclog");
You still need to check this for success.
: open (ACCHIT,">access.hits");
And this too
: $total=0;
: while ($line = <ACCLOG>) {
: ++$total;
: foreach (@srchstr) {
: if ( $line =~ /$_/ ) {
: ++$hits{$_};
: print ACCHIT $line;
: }
This will get rather slow if you have multiple things to search for. See
"how can I efficiently match many regular expressions at once" in perlfaq6.
: }
: }
: close(ACCLOG);
: close(ACCHIT);
: open(ACCRES,">access.results");
Check your result.
: print ACCRES "Total number of requests: $total\n";
: format ACCRES_TOP =
: Web Access Log
: file/dir req. % of tot.req.
: --------------------------------------------
: .
A format is terminated by a line containing *only* a period, *not* a
space followed by a period.
: $^='ACCRES_TOP';
: print "$srchstr[0],$srchstr[1],\n"; ##!!!!!
: foreach (@srchstr) {
: $hitperc=100.*$hits{$_}/$total;
You haven't considered the possibility that $total is zero.
: format ACCRES =
: @<<<<<<<<<<<<<<< @||||| @##.##
: $_, $hits{$_}, $hitperc
: .
Once again, terminate your format properly.
: $~='ACCRES';
: write ACCRES;
: }
: close(ACCRES);
: print "Results written to access.results; hits written to
: access.hits.\n";
: exit;
Your problem is most likely due to the improperly-terminated formats.
------------------------------
Date: Fri, 19 Mar 1999 21:29:18 GMT
From: bhaskaracharya@my-dejanews.com
Subject: question....@ISA /my @ISA
Message-Id: <7cufiq$pbq$1@nnrp1.dejanews.com>
hi
i have a simple package, i always get an error ISA not defined global package
now error goes away if i define @ISA::A or my @ISA. But i don't seem to have
error for other packages nor have i seen such behaviour?
Could somebody explain?
thanks
package A;
use strict;
require 5.000;
use Exporter;
@ISA = qw(Exporter); # @ISA::A or my @ISA works
$VERSION = "1.00" ;
@EXPORT = qw( );
@EXPORT_OK = qw();
sub new {
..
...
}
1;
now in another file say b.pl
use lib '/local/A.pm';
use A;
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 19 Mar 1999 22:59:54 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: question....@ISA /my @ISA
Message-Id: <7cukta$6vr$2@info2.uah.edu>
[long lines reformatted--please limit lines to 72 columns or so]
In article <7cufiq$pbq$1@nnrp1.dejanews.com>,
bhaskaracharya@my-dejanews.com writes:
: i have a simple package, i always get an error ISA not defined global
: package now error goes away if i define @ISA::A or my @ISA.
The diagnostics pragma will often offer enlightenment in situations like
this. However, keep this statement from perlobj in mind:
There is a special array within each package called @ISA, which says
where else to look for a method if you can't find it in the current
package.
That means @ISA must be a package variable (i.e., in the symbol table
(i.e., not a lexical (my) variable!)). You enabled the strict pragma,
so be sure to read the documentation for the strict pragma (paying
careful attention when you come to the section about `strict vars').
Greg
--
Kenny: hmm-hmm hmm hmm hmm hmm hmm-hmm!
Stan: Dude, how'd you know she has a cat?
------------------------------
Date: Fri, 19 Mar 1999 14:27:40 -0800
From: =?iso-8859-1?Q?d=E1na?= watanabe <dwatanab@uci.edu>
Subject: quick string match checks
Message-Id: <36F2CF4C.A43F788F@uci.edu>
When using AUTOLOAD, i like to make sure that the function being called
is one that i allow, so i do something like:
%functions = qw ( func1 1 funct2 1 funct3 1 );
if ($functions{$AUTOLOAD}) {
if (@_) {
$table->{$AUTOLOAD}=shift;
} else {
return $table->{$AUTOLOAD};
}
} else {
die "$AUTOLOAD not defined\n";
}
I was wondering if there was a better/lazier way to do this?
I'm not sure if better is the right word, but a possibly lazier means
comes to mind with:
$functions = 'funct1 funct2 funct3';
if ($functions=~/\b$AUTOLOAD\b/) ...
Are there any other ways to do this?
------------------------------
Date: 19 Mar 1999 21:14:49 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: rand() Performance
Message-Id: <7cueo9$47u$2@client2.news.psi.net>
William H. Asquith (asquith@macconnect.com) wrote on MMXXIV September
MCMXCIII in <URL:news:7cn4rn$1ns3@enews1.newsguy.com>:
__ I need advice or confirmation about the rand() function.
__ I'm performing statistical simulations and I need a fairly
__ good random number generator. I'm lazy and don't want to port
__ tested generators from Numerical Recipes in FORTRAN. Can I
__ use the rand() function and be assured that for simulations
__ lengths (calls to rand()) on the order of 10**6 and statistically
__ independent?
Perl uses a rand function from your system libraries. If that's good,
rand() is good. If it's bad, Perl's rand() is bad.
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: Fri, 19 Mar 1999 10:01:35 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Reading a file into a hash
Message-Id: <fsotc7.981.ln@magna.metronet.com>
Frank Hale (frankhale@worldnet.att.net) wrote:
: Is there a way to read a file into a hash which the fields extend over
: multiple lines?
Yes.
: I can do it but I have to strip off newline characters and this f's up
: the formatting of the data.
Why do you "have to"?
Newlines in hash values are not a problem.
: Here is the code I have so far but it will only read fields if they
: don't have newline characters in them. In other words it will mess up as
: soon as it hits a newline character messing the data up in each field.
: #!/usr/bin/perl
You are missing the -w switch there.
: @fieldList = qw(Index Message);
: open(FILE, "<data.dat");
You forgot to check the return value there.
: foreach $line (<FILE>) {
^^^^^^^^^^^^^
If you don't want to process line-by-line then don't process
line-by-line :-)
If you tell us how to identify the end of the multi-line records
we might be able to help you get it into a hash.
Got some sample data to show us?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 19 Mar 1999 19:42:49 GMT
From: sherman@unx.sas.com (Chris Sherman)
Subject: Searching binary file without slurping whole thing?
Message-Id: <F8uxFD.780@unx.sas.com>
I would like to search a binary file without slurping in the
whole thing. Is this possible?
For example, I want to search for, say, "version=\d+\.\d+" in
a 25 Meg binary file.
I can do it like this:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
#!/usr/local/bin/perl5 -w
use strict;
my $file=$ARGV[0] || "/tmp/huge_binary_file";
open FIN,"<$file" or die "Could not open $file: $!\n";
undef $/;
if (<FIN> =~ /version=(\d+\.\d+)/) {
print "version is $1\n";
}
close(FIN);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Unfortunately, perl grows to 25M in size for a 7M file before it
finds the answer (which, unfortunately, can be anywhere in the
file).
Ok, so I could also do it like this (taking 100K chunks at a time)...
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
#!/usr/local/bin/perl5 -w
use strict;
my $file=$ARGV[0] || "/tmp/huge_binary_file";
open FIN,"<$file" or die "Could not open $file: $!\n";
undef $/;
$|=1;
my $seg="";
my $sseg=""; # just in case search string sits on a boundary
while (read(FIN,$seg,131072)) {
if ("${sseg}${seg}" =~ /version=(\d+\.\d+)/) {
#if (<FIN> =~ /SAS_=(\d+\.\d+)/) {
print "\nversion is $1\n";
last;
}
$sseg=substr $seg, -50;
print ".";
}
close(FIN);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
But this second version is slow and complicated.
Just wondering if anyone had any ideas. Thanx!!!
--
____/ / / __ / _ _/ ____/
/ / / / / / / Chris Sherman
/ ___ / _/ / /
_____/ __/ __/ __/ _\ _____/ _____/ sherman@unx.sas.com
------------------------------
Date: Fri, 19 Mar 1999 11:03:10 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Substitution question
Message-Id: <ufstc7.je1.ln@magna.metronet.com>
Scratchie (upsetter@ziplink.net) wrote:
: zerokey@my-dejanews.com wrote:
: : I thought a simple $name=s/\@SOMPLACE.COM// would do it, but alas, it does
: : not.
: Also, the backslash is unneccesary before the @ in a regex.
The backslash is necessary before the @ in double quotish strings.
Regex patterns are double quotish.
The backslash is necessary.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 19 Mar 1999 23:16:52 GMT
From: christianarandaOUT@OUTyahoo.com (Christian M. Aranda)
Subject: Re: TCGREP in Perl Cookbook
Message-Id: <36f2da95.8182926@news.bmc.com>
On 18 Mar 1999 20:10:57 GMT, gbacon@itsc.uah.edu (Greg Bacon) wrote:
>Try running
>
> % mytest -quux
>
>Greg
Thanks Greg. Once I posted that message, I realized what was going on
with the script. I planned on canceling the message, but plain old
forgot.
Thanks for the help, tho.
------------------------------
Date: 19 Mar 1999 21:57:09 GMT
From: cmd@eskimo.com (Craig Dowell)
Subject: Re: The truth about the Pentium III chip and ID --- **boycott info**
Message-Id: <7cuh7l$sap$1@eskinews.eskimo.com>
Bill Anderson <banderson@boi.hp.com> wrote:
[...]
>> The POINT here is that it is exactly as easy to embed my unique MAC address
>> in an Internet transaction as it is to embed my unique Pentium-III CPU ID
>> in an Internet transaction. Any software which will go to the trouble to
>> fetch the unique CPU identifier and send it over the network to identify me
>> could just as easily be written TODAY to use a MAC address for exactly the
>> same purpose. The CPU identifier is not significantly different in concept
>> from the MAC address, and yet there has not been a hue and cry to boycott
>> NIC manufacturers.
>
>Ho wmany home users ar LAN connected to the internet?
>oh, yeah, that's right, they dial up with a modem; no getting a MAC
>address from a machine that does not have one.
Why would you need a hardware ID to do any of the things that some of you
folks are objecting to? If I generated a random number large enough such
that the probability of duplication was below some reasonable threshold
and stored that number as the ID, what would be the real difference?
I've got lots of pseudorandom numbers pointing at me in precisely that way.
I don't think the end of the world is nigh because of it, though. Where's
the hue and cry about social security numbers, BTW? Or is that just a
paranoid redneck issue, while CPU IDs are an enlightened thinking man's
issue? Is it because the good government controls what is done with
social security numbers, but evil corporations are using CPU IDs?
Really. What's the big deal? Other than giant conspiracies by
multinational corporations to sap and impurify all of our precious bodily
fluids, of course.
------------------------------
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 5182
**************************************