[18202] in Perl-Users-Digest
Perl-Users Digest, Issue: 370 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 27 18:11:09 2001
Date: Tue, 27 Feb 2001 15:10:21 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983315421-v10-i370@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 27 Feb 2001 Volume: 10 Number: 370
Today's topics:
Re: libnet and Net::SMTP config.pm is wrong <gerard@NOSPAMlanois.com>
Re: libnet and Net::SMTP config.pm is wrong <gerard@NOSPAMlanois.com>
Newbie - CGI Errors when sending HTML Mail <stiroff@elsitech.com>
nvi-1.79 + perl interpreter <#bc23@gatewest.net#>
Re: nvi-1.79 + perl interpreter (Ilya Zakharevich)
Re: Perl on a shell account: how to use UNIX commands i <donkan7@yahoo.com>
Re: Perl on a shell account: how to use UNIX commands i <donkan7@yahoo.com>
Re: Perl program review request <iltzu@sci.invalid>
Re: Perl program review request <flavell@mail.cern.ch>
Re: Perl program review request (Bill Feidt)
Re: Perl program review request <bmb@ginger.libs.uga.edu>
Re: Perl program review request <uri@sysarch.com>
Perl/DBD Question - Suppressing error messages for "nor <bill_border@agilent.com>
Re: Please Help with 10 line programm -- beginner quest <thoren@southern-division.com>
Re: Please Help with 10 line programm -- beginner quest <iltzu@sci.invalid>
Re: Please Help with 10 line programm -- beginner quest <thoren@southern-division.com>
Re: PWS and Perl <Gary.Karcz@nau.edu>
Registry Entries - Help <kev@kdpsoftware1.nospmrs.demon.co.uk>
Re: Registry Entries - Help <godzilla@stomp.stomp.tokyo>
Search results by filename <chris002@nc.rr.com>
Re: sending to sockets <dennis.kowalsk@daytonoh.ncr.com>
Re: Sorting by date <godzilla@stomp.stomp.tokyo>
statement for(list); <joepepin@att.com>
Re: statement for(list); (Greg Bacon)
Subject=Re: Creating string of values ignoring empty (Thomas Wolfmaier)
Re: Subject=Re: Creating string of values ignoring empt <joe+usenet@sunstarsys.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Feb 2001 11:10:57 -0800
From: Gerard Lanois <gerard@NOSPAMlanois.com>
Subject: Re: libnet and Net::SMTP config.pm is wrong
Message-Id: <u1yskaqm6.fsf@NOSPAMlanois.com>
Alan Pettigrew <alan1.pettigrew1@fox1-europe1.com> writes:
> I have just installed libnet (1.06) with PPM on 2 NT machines.
> ...
> I amended my config.pm and all is well, but I would like to know if I
> did something wrong in the configuration, or whether there is a bug in
> the installation.
>
> I did repeat the installation with all defaults for the configuration
> and got exactly the same problem.
>
> Can anyone shed some light on this?
You did nothing wrong. In fact, it was very astute of you to
find and fix the problem on your own.
The Config.pm from activestate is corrupted, as you unfortunately
found out.
The best thing to do is install from scratch, using the libnet .tar.gz
file. WinZip understands and can unpack .tar.gz files.
You can use Microsoft's free nmake utility from
ftp://ftp.microsoft.com/softlib/mslfiles/nmake15.exe
Then you can do the classic installation sequence (after unpacking
the archive):
nmake Makefile.PL
nmake
nmake test
nmake install
-Gerard
http://www.lanois.com/perl/
------------------------------
Date: 27 Feb 2001 11:15:28 -0800
From: Gerard Lanois <gerard@NOSPAMlanois.com>
Subject: Re: libnet and Net::SMTP config.pm is wrong
Message-Id: <uy9us9bu7.fsf@NOSPAMlanois.com>
Alan Pettigrew <alan1.pettigrew1@fox1-europe1.com> writes:
> I have just installed libnet (1.06) with PPM on 2 NT machines.
By the way the latest libnet is 1.0703
http://www.cpan.org/authors/id/GBARR/libnet-1.0703.tar.gz
-Gerard
http://www.lanois.com/perl/
------------------------------
Date: Tue, 27 Feb 2001 15:31:14 -0600
From: "Sharon Weis" <stiroff@elsitech.com>
Subject: Newbie - CGI Errors when sending HTML Mail
Message-Id: <EBF56D79C6BE9938.1D1A41A8D360FFC4.14CEDE79AC80EC63@lp.airnews.net>
Hi, I am new to Perl CGI and I am trying to send mail in HTML format. I am
using ActivePerl on a Windows NT box. I am using the MIME::Lite and
Net::Config packages. I am able to send
mail successfully. However, it is printing the following errors on my CGI
form. I have never modified, let alone opened the
Domain.pm. Am I suppose to modify this file and if so what am I suppose to
modify?
Errors:
Use of uninitialized value in scalar assignment at
E:/Perl/site/lib/Net/Domain.pm line 204.
Use of uninitialized value in scalar assignment at
E:/Perl/site/lib/Net/Domain.pm line 204.
Use of uninitialized value in pattern match (m//) at
E:/Perl/site/lib/Net/Domain.pm line 228. Use of uninitialized value in split
at E:/Perl/site/lib/Net/Domain.pm line 235.
I've included the code in which the errors point:
Domain.pm
----------------------------------------------------------------------------
-------
# Look for environment variable
$domain ||= $ENV{LOCALDOMAIN} ||= $ENV{DOMAIN} || undef; #line 204
if(defined $domain) {
$domain =~ s/[\r\n\0]+//g;
$domain =~ s/(\A\.+|\.+\Z)//g;
$domain =~ s/\.\.+/\./g;
}
sub domainname {
return $fqdn
if(defined $fqdn);
_hostname();
_hostdomain();
# Assumption: If the host name does not contain a period
# and the domain name does, then assume that they are correct
# this helps to eliminate calls to gethostbyname, and therefore
# eleminate DNS lookups
return $fqdn = $host . "." . $domain #line 228
if($host !~ /\./ && $domain =~ /\./);
# For hosts that have no name, just an IP address
return $fqdn = $host if $host =~ /^\d+(\.\d+){3}$/;
my @host = split(/\./, $host);
my @domain = split(/\./, $domain); #line 235
my @fqdn = ();
# Determine from @host & @domain the FQDN
my @d = @domain;
Thanks,
Sheri
------------------------------
Date: Tue, 27 Feb 2001 14:17:17 -0800
From: Joseph <#bc23@gatewest.net#>
Subject: nvi-1.79 + perl interpreter
Message-Id: <t9o2rl1jtfo923@corp.supernews.com>
I'm trying to build a perl 5 interpreter into nvi 1.79. There's a
problem that arises when a macro, incgv, referred to in file
perl_api/perl.xs is processed when using perl 5.005; gcc spits out an
error akin to:
in file included in perl.xs:
'unkown identifier 'incgv'...
This can be made to work by changing it to PL_incgv, but I'm looking for
a solution that is more universal from the perspective I'm building an
rpm: needed is a patch that'll allow nvi-perl5 to be build whether 5.003
or 5.005+ is on build machine. I've tried several variations of
preprocessor macros; they all pretty solid from the outset, but failed
when a new version of perl was installed. To make things worse, I'm not
all that familiar with the C programming language.
It would also help to know at where in perl's development the new naming
conventions took hold. I'm at my wit;s end.
------------------------------
Date: 27 Feb 2001 22:13:08 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: nvi-1.79 + perl interpreter
Message-Id: <97h8pk$pqa$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Joseph
<#bc23@gatewest.net#>],
who wrote in article <t9o2rl1jtfo923@corp.supernews.com>:
> I'm trying to build a perl 5 interpreter into nvi 1.79. There's a
> problem that arises when a macro, incgv, referred to in file
> perl_api/perl.xs is processed when using perl 5.005; gcc spits out an
> error akin to:
> in file included in perl.xs:
> 'unkown identifier 'incgv'...
Do not remember all the details, but some of the problems may be
solved with #define PERL_POLLUTE; some others with #include
"perlport.h" (which you need to get - from CPAN?).
Ilya
------------------------------
Date: Tue, 27 Feb 2001 09:58:17 -0800
From: "Dick" <donkan7@yahoo.com>
Subject: Re: Perl on a shell account: how to use UNIX commands in a perl script?
Message-Id: <3a9beabb$1_2@huge.aa.net>
<egwong@netcom.com> wrote in message
news:9787h9$u1s$1@newssvr06-en0.news.prodigy.com...
> Dick <donkan7@yahoo.com> wrote:
> >
> > "Gregory Toomey" <gtoomey@usa.net> wrote in message
> > news:ePLl6.2456$v5.8161@newsfeeds.bigpond.com...
> >> Try someting like $var=system('uptime').
> >> You may need to use substr to get the value you need.
> >
> > $var=system('uptime');
> > print $var, "\n";
> >
> > gets me what I want, e.g.
> > "3:32am up 130 days, 58 min, 3 users, load average: 0.01, 0.04,
0.01".
> > Thanks very much.
> >
> > But I also get a "0" on the next line. What's that, and how can I get
rid of
> > it?
>
> This is excellent! I'm sure a lot of us made a similar mistake
> when we started out too.
>
> What's happening is that the "uptime" line is being printed when
> system calls uptime -- it's *not* being captured by perl into the
> variable $var. That's why $var prints out as "0" in the second
> line. To see what I mean, compare these two from the command line:
>
> perl -e 'my $var=system("uptime");'
> perl -e 'my $var=`uptime`;'
>
> Only in the second line (which uses the backticks) is the output
> from uptime captured by perl. That's why adding a "print $var"
> to the first line is essentially a no-op, whereas adding it to
> the second line will actually print what you want. As has been
> previously mentioned, see "Quote and Quote-like Operators" in
> the perlop manpage.
>
> I'm glad to hear that you're using strict. You're starting off
> right :) What you need to do is to declare your package (global)
> variables with 'use vars' or "our" (if you're using perl 5.6+),
> or, declare the variables as a lexical with "my", as I did above
> (see the strict, vars and perlfunc manpages).
>
> HTH,
> Eric
Sorry to not have replied earlier -- my usual news server was/is screwed up,
and I'm now using a different one.
Thanks very much for clearing up my confusion about that "0". Your
explanation is very clear. I now realize I should have guessed that the "0"
was the value of $var.
I'm guessing you really meant the test that succeeds to be:
perl -e 'my $var=`uptime`; print $var;'
Dick
------------------------------
Date: Tue, 27 Feb 2001 10:05:31 -0800
From: "Dick" <donkan7@yahoo.com>
Subject: Re: Perl on a shell account: how to use UNIX commands in a perl script?
Message-Id: <3a9bec6d$1_3@huge.aa.net>
<Michael Vilain <michael@NOSPAM.vilain.com>> wrote in message
news:michael-58BE97.00241826022001@corp.supernews.com...
> In article <9787h9$u1s$1@newssvr06-en0.news.prodigy.com>,
> egwong@netcom.com wrote:
>try
>
> open (UP,"uptime|");
> @uptime = <UP>;
> close UP;
>
> @uptime should be a 1 element array with an embedded \n
Yes! Another way to do it! Don't understand this yet, but it works, and I
will. Thanks.
>
> --
> Michael Vilain
> Certified Advanced Rolfer(r)
> rolfer@vilain.com
> http://www.vilain.com
------------------------------
Date: 27 Feb 2001 20:45:28 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Perl program review request
Message-Id: <983305871.26196@itz.pp.sci.fi>
In article <x7u25gez56.fsf@home.sysarch.com>, Uri Guttman wrote:
>
>today i wrote the classic skip a blank line as:
> next if $line =~ /^\s*$/ ;
>this reads poorly to me:
> $line =~ /^\s*$/ and next ;
Alan would probably say it should be:
$line !~ /^\s*$/ or next;
..or rather:
$line =~ /\S/ and next;
Me, I'd probably do it like you except for the condition:
next unless $line =~ /\S/;
>but i do opens like:
> open( FOO, 'bar' ) || die "flaming death" ;
So do I, and I can even state my reasons for it -- I want to put the
(main) action of the statement first. The pattern match isn't an
action, it's just an assertion. The conditional die() _is_ an action,
but not as significant as the open(), so it goes last.
I _might_ write "die unless open" if I was just checking to see that
the file could be opened, and had no intention of using the opened
filehandle for anything. But I've never felt a need to do that.
(This horse seems rather dead to me, but I wanted to give it one last
flog. I'll let it rest in peace now unless it shows signs of life.)
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"I've yet to see an advert for an IT gig where a general awareness (let alone
an ability to discuss sensibly or to even participate in) anal sex would be
something one would include on one's CV." -- Matt McLeod in the monastery
Please ignore Godzilla / Kira -- do not feed the troll.
------------------------------
Date: Tue, 27 Feb 2001 22:11:15 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Perl program review request
Message-Id: <Pine.LNX.4.30.0102272149150.3744-100000@lxplus003.cern.ch>
On 27 Feb 2001, Ilmari Karonen wrote:
> Uri Guttman wrote:
> >today i wrote the classic skip a blank line as:
> > next if $line =~ /^\s*$/ ;
> >this reads poorly to me:
Funnily enough, I was quite happy with that; probably (gut-feeling)
the difference between on the one hand a normal and desired outcome of
the test, and on the other hand a parachute-out on an unintended error
situation.
Now, let me try to be even-handed about this: I was lectured once by a
real-time programmer (I think they're particularly acute to this
issue) to the effect that one should treat ALL outcomes with the same
degree of care and attention, rather than just parachuting out and
hoping for some system-dependent error recovery to occur. Under that
philosophy, there are _no_ "error" situations, by definition: all
situations are normal outcomes of program execution and have to be
processed in a clean and disciplined fashion.
So I guess he would never say "die", or would overload it with some
sophisticated handling of his own, that would conscientiously sweep
the floor of any broken glass before calmly continuing the processing.
Which in a real-time system makes a lot of sense, 'cause you can't go
blue-screening the airliner just as it's coming in to land...
> (This horse seems rather dead to me,
Well, pardon me, yet it's been a short but fascinating insight into
some differing views. I've appreciated the discussion, thanks.
------------------------------
Date: 27 Feb 2001 16:16:26 -0500
From: wfeidt@his.com (Bill Feidt)
Subject: Re: Perl program review request
Message-Id: <9055A177Dwfeidthiscom@216.200.68.12>
wfeidt@his.com (Bill Feidt) wrote in <90555FD99wfeidthiscom@216.200.68.12>:
>Program:
>
> http://www.cpcug.org/dialup/shdisk.txt
Thanks to all who responded. Your advice was very much
appreciated and has been, in large measure, incorporated
into my code.
A few of the concepts you suggested are new to me and I
will need to do some tinkering to get them implemented.
In case you're interested, the core of the code now looks
like this:
HEAD();
foreach my $object (@elements) {
my $prevpct;
open (INFIL, "/homec/wfeidt/tbin2/diskts.ts") or die "Could not open
diskts.ts for read: $!";
while ( my $line = <INFIL> ) {
if ( $line =~ /$object/ ) {
chomp $line;
my ($date2, $volume, $percent) = split (/\|/, $line);
$percent =~ /(\d+)/ or die "'$percent' contains no digit chars!";
my $percent_digits = $1;
if ( $percent_digits > 89 ) {
$percent = "<span class=\"emph\">$percent_digits</span>%";
}
elsif ( $percent_digits > 84 ) {
$percent = "<strong>$1</strong>%";
}
if ( $prevpct && $percent_digits - $prevpct > 2 ) {
$percent .= " [<strong>!</strong>]";
}
my $shim = " " x ( 12 - length($volume) );
$line = $date2." ".$volume.$shim.$percent;
$prevpct = $percent_digits;
print OUTFIL "$line\n";
}
}
print OUTFIL "\n";
}
FOOT();
Again, thanks for your help.
Bill
Bill@ng3k.com
------------------------------
Date: Tue, 27 Feb 2001 17:03:15 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Perl program review request
Message-Id: <Pine.A41.4.21.0102271644060.12736-100000@ginger.libs.uga.edu>
On 27 Feb 2001, Bill Feidt wrote:
> In case you're interested, the core of the code now looks
> like this:
>
> HEAD();
The all-caps convention in Perl usually indicates something magical that
perl does for you, e.g. BEGIN, END, AUTOLOAD, etc. An obvious exception
is the common use of all-caps for filehandle names. I would rename those
head() and foot() (though I would probably say header() and footer()).
> open (INFIL, "/homec/wfeidt/tbin2/diskts.ts") or die "Could not open
> diskts.ts for read: $!";
Just to be nit-picky, INFIL and OUTFIL look like typos to me, and cause me
to do a double take. I would spell them INFILE and OUTFILE (or just IN
and OUT) to avoid the mental speed bump.
> $line = $date2." ".$volume.$shim.$percent;
> $prevpct = $percent_digits;
> print OUTFIL "$line\n";
$line = "$date2 $volume$shim$percent";
... is more Perlish. However, in this case, I think it's bad form to
modify the variable you're using for input if there is not a good reason
to do so. Instead you could simply
print OUTFIL "$date2 $volume$shim$percent\n";
Regards,
Brad
------------------------------
Date: Tue, 27 Feb 2001 22:07:46 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl program review request
Message-Id: <x7r90jg4pa.fsf@home.sysarch.com>
>>>>> "BF" == Bill Feidt <wfeidt@his.com> writes:
BF> foreach my $object (@elements) {
BF> my $prevpct;
BF> open (INFIL, "/homec/wfeidt/tbin2/diskts.ts") or die "Could not open
BF> diskts.ts for read: $!";
BF> while ( my $line = <INFIL> ) {
BF> if ( $line =~ /$object/ ) {
as others have said, there are ways to speed up multiple regex matches.
BF> chomp $line;
you should do this before the previous if, in most cases.
BF> my ($date2, $volume, $percent) = split (/\|/, $line);
BF> $percent =~ /(\d+)/ or die "'$percent' contains no digit chars!";
BF> my $percent_digits = $1;
BF> if ( $percent_digits > 89 ) {
BF> $percent = "<span class=\"emph\">$percent_digits</span>%";
eeww. if you have to escape ", then pick a different delim with qq{}.
BF> }
BF> elsif ( $percent_digits > 84 ) {
BF> $percent = "<strong>$1</strong>%";
why use $1 here when you assigned it to $percent_digits?
BF> }
and what if $percent_digits <= 84? you don't set $percent in that case.
BF> if ( $prevpct && $percent_digits - $prevpct > 2 ) {
BF> $percent .= " [<strong>!</strong>]";
BF> }
BF> my $shim = " " x ( 12 - length($volume) );
BF> $line = $date2." ".$volume.$shim.$percent;
don't reuse line here, it confuses things. better to use another var or
even no var at all:
BF> print OUTFIL "$line\n";
print OUTFIL "$date2 $volume$shim$percent\n" ;
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: Tue, 27 Feb 2001 14:29:35 -0700
From: "Bill Border" <bill_border@agilent.com>
Subject: Perl/DBD Question - Suppressing error messages for "normal" errors
Message-Id: <983309396.777333@goodnews.cos.agilent.com>
Hi All,
I am working on a DBD program where I insert a row into an Oracle table
with a unique index. It is normal for this call to get a SQL error when
there
is a duplicate row. I do handle the error after the call with $dbh->err;
Here
is my question: how do I prevent this error:
DBD::Oracle::db do failed: ORA-00001: unique constraint (DBAMON.HISTORY_X1)
violated (DBD ERROR: OCIStmtExecute) at /opt/dbamon/lib/histCreate.pl line
28.
from displaying on STDOUT???
TIA,
Bill
------------------------------
Date: Tue, 27 Feb 2001 20:20:01 +0100
From: Thoren Johne <thoren@southern-division.com>
Subject: Re: Please Help with 10 line programm -- beginner questions
Message-Id: <MPG.15061ba0d7058bbc9898ca@news.btx.dtag.de>
In article <slrn99m8td.gdp.tjla@thislove.dyndns.org>, Gwyn Judd aka
tjla@guvfybir.qlaqaf.bet says...
> I was shocked! How could Thoren Johne <thoren@southern-division.com>
> say such a terrible thing:
> >In article <3A9ACCD1.C1DEA364@ll.mit.edu>, Shane McDaniel aka
> >shanem@ll.mit.edu says...
> >
> >> Cool. It's points like these that I like to tell people that "Every
> >> programming language will let you shoot yourself in the foot, however
> >> with perl you're using an automatic."
> >
> >yeah - and logo is no shooting, but bondage ;)
>
> While Java is like having someone nail a loaded gun to your foot.
i allways thought that it's java if you only can shoot your own knees and
parts above because it's impossible to aim your feet ;)
--
# Thoren Johne - 8#X - thoren@southern-division.com
# Southern Division Classic Bikes - www.southern-division.com
END{print@=and&X&&print'','8#X'}sub X{eval(reverse'######" Hackern\ "
esrever=,$')}BEGIN{$,=32.65.110.111.116.104.101.114.32=>@==qw/Just Perl/}
------------------------------
Date: 27 Feb 2001 21:00:09 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Please Help with 10 line programm -- beginner questions
Message-Id: <983307036.27224@itz.pp.sci.fi>
In article <MPG.15061ba0d7058bbc9898ca@news.btx.dtag.de>, Thoren Johne wrote:
>
>i allways thought that it's java if you only can shoot your own knees and
>parts above because it's impossible to aim your feet ;)
Based on my experience with Java, it's quite possible to shoot pretty
much anything you want with it. First, however, you need to construct
your own gun from the supplied Lego(tm) blocks.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
". . . compare your Visor with a hand grenade and you'll notice that the
grenade is much bigger." -- Juergen Nieveler in the monastery
Please ignore Godzilla / Kira -- do not feed the troll.
------------------------------
Date: Tue, 27 Feb 2001 23:48:26 +0100
From: Thoren Johne <thoren@southern-division.com>
Subject: Re: Please Help with 10 line programm -- beginner questions
Message-Id: <MPG.15064d28aa7083309898cb@news.btx.dtag.de>
In article <983307036.27224@itz.pp.sci.fi>, Ilmari Karonen aka
iltzu@sci.invalid says...
> In article <MPG.15061ba0d7058bbc9898ca@news.btx.dtag.de>, Thoren Johne wrote:
> >
> >i allways thought that it's java if you only can shoot your own knees and
> >parts above because it's impossible to aim your feet ;)
>
> Based on my experience with Java, it's quite possible to shoot pretty
> much anything you want with it. First, however, you need to construct
> your own gun from the supplied Lego(tm) blocks.
trying to cope with that problem you might fit an anger - shooting both
knees at once with an incomplete, brocken java.foot.shoot.blaster(tm)
--
# Thoren Johne - 8#X - thoren@southern-division.com
# Southern Division Classic Bikes - www.southern-division.com
END{tie$@=>X=>and$@=42=>print"$@8#X"}eval(reverse(q?}esrever{HCTEF::A bus
;>=101010>>42;}"JAPHn\"=_${EROTS::A bus}'A'>=@$\sselb{RALACSEIT::X bus?))
------------------------------
Date: Tue, 27 Feb 2001 14:34:30 +0700
From: "Gary E. Karcz" <Gary.Karcz@nau.edu>
Subject: Re: PWS and Perl
Message-Id: <97h6h6$2nh$1@usenet.nau.edu>
Mark
Unless you really want to stay with the PWS, why not grab yourself a copy
of Apache for win32 and install that? The Perl cgi goodies work quite
will under the win32 Apache distribution.
http://www.apache.org/dist/binaries/win32
Hope this helps!
--Gary
In article <t9np14jgve9jea@corp.supernews.com>, "Mark"
<mark_shutt@hotmail.com> wrote:
> I am trying to run MS Personal Web Server on Win98 and run Perl CGI
> scripts. I have my registry correct to execute Perl, but it still isn't
> working. I am getting a "the page cannot be displayed" error. I am
> browsing the directory so it is definately there..and the script
> executes fine (a simple print statement with HTML headers) on a
> different web server. Does anyone know what may be missing? What needs
> to be done to ensure proper installation of MS PWS and ActivePerl?
>
> Thanks.
>
> Mark
>
> --
> Posted via CNET Help.com http://www.help.com/
------------------------------
Date: Tue, 27 Feb 2001 20:54:54 -0000
From: "KevinP" <kev@kdpsoftware1.nospmrs.demon.co.uk>
Subject: Registry Entries - Help
Message-Id: <983307099.23861.0.nnrp-09.d4e43253@news.demon.co.uk>
What do I put in the registry to map scripts to the "appropriate
interpreter.
I am using W98 and PWS to work with.
TIA
Kev
------------------------------
Date: Tue, 27 Feb 2001 13:38:01 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Registry Entries - Help
Message-Id: <3A9C1E39.2D5C5B8C@stomp.stomp.tokyo>
KevinP wrote:
> What do I put in the registry to map scripts to the
> "appropriate interpreter.
> I am using W98 and PWS to work with.
Don't use abbreviations in written text
unless they are very well known, such
as Mr. Ms. Esq. Jan Feb and the such.
W98 I can assume means Windows 98, any edition.
PWS may very well mean Puny Windows Shit.
Never edit your Windows Registry unless you have
exceptional expertise in doing this. You can
easily leave yourself with a machine which cannot
boot into Windows. This is almost always the case
for those lacking excellent skills at this.
A presumption is made you are referring to perl core
lacking any clarity on your part.
Use Windows 3.1 old but very powerful File Manager.
Starting at your desktop task bar,
Select START
Select RUN
winfile.exe
OK
Windows 3.1 File Manager will pop up.
Find a directory containing a script you wish
to associate with your perl core. Highlight
this script. Pull down FILE from your top
menu bar. Select ASSOCIATE, then follow
File Manglers simple instructions. My
presumption is you wish to associate
an unknown script type with perl.exe
or perl560.exe both of which should be
available via a scroll in your associate
pop up window. If these are not available
via this scroll box, STOP and correctly
install Perl or investigate why perl core
is not listed, before doing anything else.
If you are feeling lucky, you may locate
your Perl install, then type into the
appropriate associate box entry field,
a path leading to your perl core executable.
This is no guarantee your scripts will run,
however. There are other configuration needs,
hopefully addressed when you installed Perl.
This only associates perl core with whatever
extension is used for your selected script,
in your Windows registry.
Godzilla!
------------------------------
Date: Tue, 27 Feb 2001 21:07:55 GMT
From: "Chris" <chris002@nc.rr.com>
Subject: Search results by filename
Message-Id: <LGUm6.948$__6.177850@typhoon.southeast.rr.com>
Hello,
I am trying to locate a perl script (that runs on NT - I have one for UNIX)
that will allow a web based search of a directory (plus all of it's
subdirectories) and all its files based solely on the filenames (not the
content) of the files located in the
document root (and subdirs of root.) For example, if I have a file named
Beach Pictures.Zip in my document root and a (contains) search is performed
on the keyword 'pictures' I would like to return a URL named Beach Pictures
(or something similar to the name of the file would work fine) and have it
point to the file Beach Pictures.Zip. Then the only thing the user has to
do is click on the URL and it will download the file. FTP won't work I am
required to use https.
If anyone can point me in the direction of a script that can perform this
function I would be most appreciative.
Thanks for your help....
Chris -- very new to scripting with perl.
------------------------------
Date: Tue, 27 Feb 2001 14:37:03 -0500
From: "Dennis Kowalski" <dennis.kowalsk@daytonoh.ncr.com>
Subject: Re: sending to sockets
Message-Id: <3a9c01de$1@rpc1284.daytonoh.ncr.com>
I would suspect that the ^M* stuff at the beginning of you output is a 2 or
4 byte binary vli indicating the length of the message on the socket.
If it is, you need to read 2 or 4 bytes from the socket, thenn unpack it
with the "n" (i.e. $vli = unpack("n",vlibin);
Then depending on wether the vli values includes the vli bytes or not, read
the data portion next.
For example
2 byte vli value has the vli 2 bytes counted.
If vli = 50, read the next 48 bytes to get the message.
Hope this helps
Ted Fiedler <tfiedler@zen.moldsandwich.com> wrote in message
news:Pine.LNX.4.21.0102270650150.18443-100000@zen.moldsandwich.com...
> Ive been working on this for several hours and CANNOT seem to figure out
> what im doing wrong - all I want to do is get the output from the socket
> and write it to a file. any help is appreciated.
>
> use strict;
> use IO::Socket;
>
> ######################################################
> # Configs go here #
> ######################################################
> #
> #
> my ($remote_host);
> my ($remote_port);
> my ($protocol);
> #
> # $protocol="udp";
> $protocol="tcp";
> $remote_port="23"; # or whatever
> $remote_host="rainmaker.wunderground.com"; # this should usually be the
> same???
> ######################################################
> # End user configs #
> ######################################################
>
>
>
> ######################################################
> # constants #
> ######################################################
> #
> my ($socket);
> my ($awnser);
> #
> ######################################################
> # End of Constants #
> ######################################################
>
> open(WEATHERFILE, ">weather.dat") || die "couldnt open weather.dat";
>
> $socket = IO::Socket::INET->new(PeerAddr => $remote_host,
> PeerPort => $remote_port,
> Proto => $protocol,
> Type => SOCK_STREAM);
> sleep 5;
> print $socket "\r";
> sleep 10;
> $awnser=<$socket>;
> print WEATHERFILE "$awnser";
> print $socket "bgm\r";
> $awnser=<$socket>;
> print WEATHERFILE "$awnser";
> sleep 3;
> print $socket "x";
> sleep 2;
> print $socket "\r";
> close ($socket);
> close WEATHERFILE;
>
> ******FYI -- This is the out put that I get in weather.dat ******
> --------------------------------------------------------------------------
----
> ^M* Welcome to THE WEATHER UNDERGROUND telnet
> service! *
>
>
> Thanks in advance
>
> Ted
>
------------------------------
Date: Tue, 27 Feb 2001 12:15:06 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Sorting by date
Message-Id: <3A9C0ACA.3ADC67F9@stomp.stomp.tokyo>
Brian J wrote:
> I'm writing a forum where each topic is stored as a .txt file,
> and would like to know if there is a way to sort or read the files
> into the order they were last modified so that they could be
> displayed in such a way.
> I'm currently using -
> @topics = grep (/^.+\.txt$/, readdir (TOPICS));
> - to make a list of the files, but this stores them in the order in
> which the files were created.
Below my signature you will read a test script which is
basic and written in Plain English as much as possible
for easier reading and comprehension.
This script will provide you with basic fundamentals
upon which you can build a script to attain your goal.
Finger walking through my script,
$file_ext = ".pl";
This statement above determines what file type
you want, by extension. You may change this
to .txt, .exe, .gif and other extensions,
individually, as needed.
opendir (DIRECTORY, ".");
My code snippet above opens your
current directory. This, of course,
can be modified to open any directory
path you specify.
if ($filename =~ /[\w+]$file_ext$/)
This snippet parses your return data for
only the extension you want and, removes
all 'directory' return data. It will also
remove extensions like .pl.bak to avoid
backup files and other double extensions.
This snippet is based on a presumption
your file name contains alpha-numeric
characters followed by an extension.
$modified = (stat ($filename)) [9];
Above is a snippet to pull last modified
date in epoch seconds. Information on
the stat () function is available via
Perl documentation and other resources.
After this, simple code to create an array,
sort this array, then split and print per
filename and last modified date.
There are ample examples in documentation
to convert epoch seconds to standard date
format if needed. If not, you can simply
not return or not print the last modified
date, after a sort of your array, obviously.
You have not specified if you want last
modified dates but rather only a sort
based on last modified date.
Godzilla!
--
TEST SCRIPT:
____________
#!perl
print "Content-type: text/plain\n\n";
$file_ext = ".pl";
opendir (DIRECTORY, ".");
while (defined ($filename = readdir (DIRECTORY)))
{
if ($filename =~ /[\w+]$file_ext$/)
{
$modified = (stat ($filename)) [9];
$filename = "$modified:$filename";
push (@Array, $filename);
}
}
@Array = sort (@Array);
foreach $element (@Array)
{
($modified, $filename) = split (/:/, $element);
print "Filename: $filename\n ",
"Last Modified: $modified\n\n";
}
exit;
PRINTED RESULTS:
________________
Filename: test2.pl
Last Modified: 982904446
Filename: test3.pl
Last Modified: 983028406
Filename: test1.pl
Last Modified: 983155072
Filename: test5.pl
Last Modified: 983245630
Filename: test4.pl
Last Modified: 983302502
------------------------------
Date: Tue, 27 Feb 2001 14:09:43 -0500
From: "Joe Pepin" <joepepin@att.com>
Subject: statement for(list);
Message-Id: <97gt8i$qk97@kcweb01.netnews.att.com>
I'm curious about the "statement for(list);" construct. I've seen it used,
and yet I can't find anything about it in the docs (maybe I'm not looking in
the right places). Did this come in in 5.6.0?
------------------------------
Date: Tue, 27 Feb 2001 20:50:06 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: statement for(list);
Message-Id: <t9o4nuirb3js79@corp.supernews.com>
In article <97gt8i$qk97@kcweb01.netnews.att.com>,
Joe Pepin <joepepin@att.com> wrote:
: I'm curious about the "statement for(list);" construct. I've seen it
: used, and yet I can't find anything about it in the docs (maybe I'm
: not looking in the right places). Did this come in in 5.6.0?
The 5.5.30 perlsyn manpage contains
Any simple statement may optionally be followed by a SINGLE modifier,
just before the terminating semicolon (or block ending). The possible
modifiers are:
if EXPR
unless EXPR
while EXPR
until EXPR
foreach EXPR
In Perl, for and foreach are synonyms. I'm not sure when for became a
legal modifier, but I think it was somewhere in 5.004.
Greg
--
When a man is more right than his neighbor, that constitutes a majority of
one.
-- Thoreau
------------------------------
Date: 27 Feb 2001 21:29:05 +0100
From: twolfmaier@acm.org (Thomas Wolfmaier)
Subject: Subject=Re: Creating string of values ignoring empty
Message-Id: <3.0.2.32.20010227153204.00711eb8@interlog.com>
Thanks for everyone's responses and my apologies for the mistakes in my
sample code. I will be more careful the next time.
As you pointed out, the map block in my original posting was incomplete:
map { ACCESS_PERMISSION->{$_}->{$lang} }
I had actually tried:
map { $record->{$_} ? ACCESS_PERMISSION->{$_}->{$lang} : undef }
Strangely, this now gives me an 'Use of uninitialized value' warning in my
test script, while it still runs without a warning in my original script. I
use both -w and use strict in both scripts. I need to investigate.
As you suggested, replacing undef with () does the trick:
map { $record->{$_} ? ACCESS_PERMISSION->{$_}->{$lang} : () }
That was the missing piece I was looking for.
I also tried Joe's alternative suggestion:
>Alternately, you might consider just building a single
>access array at the beginning of script
>
> my @access = map { ACCESS_PERMISSION->{$_}->{$lang} } qw ...
>
>and then do a
>
> join ', ', grep { $record->{$_} } @access
It did not look right to me, but I tried it anyway:
my @access = map { ACCESS_PERMISSION->{$_}->{$lang} }
qw(hasSection1AccessPermission hasSection2AccessPermission
hasSection3AccessPermission);
my $access_permissions = join ', ', grep { $record->{$_} } @access;
It didn't work. Did I miss something?
Thanks again for your help,
Thomas
-----------------------------------------------------
Thomas Wolfmaier
Human-Computer Interaction Resource Network (HCIRN)
25 Bucks Green Road, Thornhill, ON, Canada, L3T 4G1
Tel: +1-905-881-7095
Email: twolfmaier@acm.org
Web: www.hcirn.com
-----------------------------------------------------
--
Posted from bretweir.total.net [154.11.89.176]
via Mailgate.ORG Server - http://www.Mailgate.ORG
------------------------------
Date: 27 Feb 2001 16:49:06 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Subject=Re: Creating string of values ignoring empty
Message-Id: <m3u25f23vx.fsf@mumonkan.sunstarsys.com>
twolfmaier@acm.org (Thomas Wolfmaier) writes:
> I also tried Joe's alternative suggestion:
>
> >Alternately, you might consider just building a single
> >access array at the beginning of script
> >
> > my @access = map { ACCESS_PERMISSION->{$_}->{$lang} } qw ...
> >
> >and then do a
> >
> > join ', ', grep { $record->{$_} } @access
>
> It did not look right to me, but I tried it anyway:
You're braver than I was- I didn't try it out before posting
it. It's certainly wrong, though- thanks for catching my error.
Very sorry about that (damned commutative diagrams)!
> my @access = map { ACCESS_PERMISSION->{$_}->{$lang} }
> qw(hasSection1AccessPermission hasSection2AccessPermission
> hasSection3AccessPermission);
>
> my $access_permissions = join ', ', grep { $record->{$_} } @access;
>
> It didn't work. Did I miss something?
No, it doesn't work- but here's a way to fix it if you still
want to try it out (tested this time):
#!/usr/bin/perl -w
use strict;
use constant ACCESS_PERMISSION => {
'hasSection1AccessPermission' => {
'en' => 'Section 1',
'de' => 'Bereich 1'
},
'hasSection2AccessPermission' => {
'en' => 'Section 2',
'de' => 'Bereich 2'
},
'hasSection3AccessPermission' => {
'en' => 'Section 3',
'de' => 'Bereich 3'
}
};
{
my $lang = "en";
my @access_keys = qw( hasSection1AccessPermission
hasSection2AccessPermission
hasSection3AccessPermission );
my @access = map { ACCESS_PERMISSION->{$_}->{$lang} } @access_keys;
sub fetch_permissions {
my $record = shift;
my $n = 0;
return join ', ', grep { $record->{ $access_keys[$n++] } } @access;
}
}
my $record = { hasSection1AccessPermission => 1,
hasSection3AccessPermission => 1,
};
my $access_permissions = fetch_permissions($record);
print $access_permissions;
__END__
Output:
Section 1, Section 3
Since this solution is somewhat obfuscated, I doubt it's of much value to
you; but I figured I should follow-up anyway.
Thanks again.
--
Joe Schaefer "Anyone who has never made a mistake has never tried anything
new."
--Albert Einstein
------------------------------
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 V10 Issue 370
**************************************