[10924] in Perl-Users-Digest
Perl-Users Digest, Issue: 4525 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 31 16:07:15 1998
Date: Thu, 31 Dec 98 13:00:21 -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 Thu, 31 Dec 1998 Volume: 8 Number: 4525
Today's topics:
Re: **Need Help**: Newbie To PERL <gellyfish@btinternet.com>
Re: [Q] How use Cookie? <gellyfish@btinternet.com>
Re: a better way? <gellyfish@btinternet.com>
Re: Absolute Yuck (Abigail)
Re: Absolute Yuck (Abigail)
Re: Absolute Yuck (Abigail)
Re: CGI.pm abnormal end <off-duty@entheosengineering.com>
Re: command line arguments on NT jfreedman@securitydynamics.com
Re: command line arguments on NT <gellyfish@btinternet.com>
Re: Copy a file in NT? <gellyfish@btinternet.com>
Re: dmake not GNU compliant? Anybody confirm or deny t (Charles Wilt)
fetch pages <wclui@virtue.csis.hku.hk>
file::copy and paths (Slick!)
Re: file::copy and paths <gellyfish@btinternet.com>
Re: file::copy and paths <jdf@pobox.com>
Re: help <wclui@virtue.csis.hku.hk>
How to change NTFS permissions odinjon@my-dejanews.com
Re: Need sample TCP code <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: Newbie: string terminator (Matthew Bafford)
Optimizing if...elsif...else when there are tons of the <design@spam_raincloud-studios.com>
Re: Perl equivalent of 'C' #include <gellyfish@btinternet.com>
Re: Perl equivalent of 'C' #include <Brett.Diamond@lmco.com>
Re: Please help will generating biased random numbers. (Gregory Snow)
Re: Please help will generating biased random numbers. (Randal L. Schwartz)
Re: Problem with Net::SMTP under NT <gellyfish@btinternet.com>
Re: Problem with Win32API::Net::UserEnum (Gareth Jones)
Re: Retrospective on comp.lang.perl.moderated? (John Stanley)
Re: Retrospective on comp.lang.perl.moderated? (John Stanley)
Re: Thanks! and happy new year! <gellyfish@btinternet.com>
win32 registry keys for Perl <cs2400@hotmail.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 31 Dec 1998 17:57:40 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: **Need Help**: Newbie To PERL
Message-Id: <76gduk$9g$1@gellyfish.btinternet.com>
On Thu, 31 Dec 1998 14:39:34 GMT Iskandar D <thekrow@iname.com> wrote:
> hi there,
> i'm very keen to learn abt PERL. where do i start? any
> good sites for beginners?
>
I'd start at <URL:http://www.perl.com/> - Yoou might also find the
documentation and the FAQ that ship with Perl useful.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 31 Dec 1998 17:56:07 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: [Q] How use Cookie?
Message-Id: <76gdrn$9b$1@gellyfish.btinternet.com>
On Thu, 31 Dec 1998 23:25:13 +0900 HongMo <HongMo@netsgo.com> wrote:
> Example please.........
>
> ^^;
If you are using the module CGI.pm then there are examples in the
documentation for the module. Otherwise you might be better put asking
in comp.infosystems.www.authoring.cgi or rather in the CGI FAQ in the
first place. Perl in itself has nothing to do with cookies and infact
the essentials of cookie handling are the same whatever language you
are using.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 31 Dec 1998 19:11:44 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: a better way?
Message-Id: <76gi9g$bp$1@gellyfish.btinternet.com>
On Thu, 31 Dec 1998 00:49:04 -0600 tavi367@ibm.net wrote:
> I have this little piece of code...
>
> $fileContents =~ s!(^.*<title>)([\w|\W]*)(<\/title>.*$)!$2!gis;
> $fileContents =~ s![\W\s]+! !gis;
>
> It returns the text between <TITLE> and </TITLE>, and it works fine, if the
> passed string contains both sub-strings.
>
> How can I get this to give me an empty string if either of my 2 conditions
> are not true (besides placing them in an IF conditional)?
>
I think that you would really be better off using HTML::Parser to achieve this
- there have been a number of examples posted on this group in recent times
which should give you a start.
Even if you insist on using a regular expression to do this then I dont
think this is the right way to it because you could wind up with
$fileContents unchanged without knowing it (without doing a comparison).
If you must you probably want to do something like:
if($fileContents =~ m!^.*<title>([\w|\W]*?)</title>.*$!is)
{
$fileContents = $1;
$fileContents =~ s![\W\s]+! !gis;
}
else
{
# $fileContents is unchanged
}
Of course that should in no way be construed as encouragement to use
anything other than HTML::Parser (or similar) to do this kind of thing.
>
> PS: Please cc my e-mail on any replies.
>
Oops too late
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 31 Dec 1998 18:55:54 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Absolute Yuck
Message-Id: <76ghbq$r5t$2@client3.news.psi.net>
Daniel Grisinger (dgris@moiraine.dimensional.com) wrote on MCMXLVIII
September MCMXCIII in <URL:news:m3r9tgkb4j.fsf@moiraine.dimensional.com>:
++ JTJ <elssa09@erase.callisto.si.usherb.ca> writes:
++
++ > This is silly ... I can do this, can't I?
++
++ No.
++
++ > I get this error message:
++ > Modification of a read-only value attempted at postcard.pl line 23.
++ >
++ > 23: $1 = @inputData;
++
++ You must assign $1 to another variable before you can modify it.
But that wouldn't help, would it? He doesn't want to modify $1....
(which is undef anyway).
Abigail
------------------------------
Date: 31 Dec 1998 18:56:55 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Absolute Yuck
Message-Id: <76ghdn$r5t$3@client3.news.psi.net>
bhoylma@uswest.com (bhoylma@uswest.com) wrote on MCMXLVIII September
MCMXCIII in <URL:news:76faak$7e4$1@nnrp1.dejanews.com>:
++ In article <368AE152.5F89@erase.callisto.si.usherb.ca>,
++ elssa09@erase.callisto.si.usherb.ca wrote:
++ > This is silly ... I can do this, can't I?
++ >
++ [...]
++ > Modification of a read-only value attempted at postcard.pl line 23.
++ >
++ > 23: $1 = @inputData;
++ >
++
++ No, '$1' is a perl reserved variable. Use another variable as the lvalue for
++ the above assignment statement.
No, not really. He doesn't care about the number of lines the text has.
He should read the manual. And probably you too.
Abigail
------------------------------
Date: 31 Dec 1998 18:54:50 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Absolute Yuck
Message-Id: <76gh9q$r5t$1@client3.news.psi.net>
JTJ (elssa09@erase.callisto.si.usherb.ca) wrote on MCMXLVIII September
MCMXCIII in <URL:news:368AE152.5F89@erase.callisto.si.usherb.ca>:
++ This is silly ... I can do this, can't I?
++
++ --------------------------------------------------------------------
++ &ReadParse;
++ open(HTMLFILE,"<$datafile");
++ @inputData=<HTMLFILE>;
++ close(HTMLFILE);
++ $1 = @inputData;
++ $1 =~ s/[TypeOfCard]/$in{'TypeOfCard'}/go;
++ --------------------------------------------------------------------
++
++ I get this error message:
++ Modification of a read-only value attempted at postcard.pl line 23.
++
++ 23: $1 = @inputData;
++
++ I want to substitute the text "[TypeOfCard]" for what I input from html
++
++ Thanks in advance ... it's screen stare and lack of a manual ... :-)
That's your problem. If you have Perl, you have the manual.
"man perl" should give you a start.
Abigail
------------------------------
Date: Thu, 31 Dec 1998 11:50:39 -0600
From: Rich Grise <off-duty@entheosengineering.com>
Subject: Re: CGI.pm abnormal end
Message-Id: <368BB96F.5840FB87@entheosengineering.com>
Erik van Roode wrote:
>
> Paul Farber wrote:
> > script seems to close the files/end properly.... and perl -c ran clean, I
>
> > have use strict and use diagnostics... the thing runs clean but end
> > normally...
see http://www.cpan.org/doc/FAQs/cgi/idiots-guide.html - it sounds like
you're
not printing any Content-type header.
--
Rich Grise
off-duty@entheosengineering.com
(No need to futz with my e-mail: I have a "delete" button!)
------------------------------
Date: Thu, 31 Dec 1998 19:03:56 GMT
From: jfreedman@securitydynamics.com
Subject: Re: command line arguments on NT
Message-Id: <76ghqr$5m9$1@nnrp1.dejanews.com>
In article <slrn78mu66.5l.alastair@calliope.demon.co.uk>,
alastair@calliope.demon.co.uk wrote:
> jfreedman@securitydynamics.com <jfreedman@securitydynamics.com> wrote:
> >I am a perl newbie ( and a sort of NT newbie). I am running Perl 5 on NT 4.0
> >using MSK shell windows and straight MS-DOS command windows. I can not get
> >the command line arguments - getopts gives me nothing and when I printot
> >$#ARGV I get -1. I am doing something wrong but what? Jerry Freedman,Jr
>
> Show us the code that doesn't work and someone might be able to help.
>
> --
>
> Alastair
> work : alastair@psoft.co.uk
> home : alastair@calliope.demon.co.uk
>
This code, when run as
test.pl -F oops ( test.pl is the name of the perl file)
produces this
"-1ERROR - Missing -F option"
use Getopt::Std;
print $#ARGV;
getopts('F:');
print $opt_F;
if (!$opt_F)
{
print "ERROR - Missing -F option\n";
}
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 31 Dec 1998 20:41:39 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: command line arguments on NT
Message-Id: <76gni3$hk$1@gellyfish.btinternet.com>
On Thu, 31 Dec 1998 19:03:56 GMT jfreedman@securitydynamics.com wrote:
>
> This code, when run as
>
> test.pl -F oops ( test.pl is the name of the perl file)
> produces this
>
> "-1ERROR - Missing -F option"
>
> use Getopt::Std;
> print $#ARGV;
>
> getopts('F:');
> print $opt_F;
> if (!$opt_F)
> {
> print "ERROR - Missing -F option\n";
> }
>
Are you running this with a file association from ASSOC and FTYPE ? There is
some anecodtal evidence that this might monkey with the parameters in some
why inimical to the good working of the Perl command line ...
Have you tried running this as:
c:\> perl test.pl -F blah
?
As an added point you probably want to test the return of getopts - I dont
find it obviously documented anywhere but if you do something like:
getopts('F:') || die "Bad options \n";
You will get a chance to do something before it all goes wrong later in the
program (if you do something other then 'die' that is )
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 31 Dec 1998 17:51:15 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Copy a file in NT?
Message-Id: <76gdik$96$1@gellyfish.btinternet.com>
On 31 Dec 1998 13:47:00 GMT Ian Blake <iblake@kodak.com> wrote:
<snip>
> Basically what I'm asking is, does PERL have a built in copy
> command? Thanks
There is no built in copy *function* as such but there is a module
File::Copy that is part of the distribution.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 31 Dec 1998 20:22:48 GMT
From: charles.0272@worldnet.no.spam.att.net (Charles Wilt)
Subject: Re: dmake not GNU compliant? Anybody confirm or deny this?
Message-Id: <MPG.10f5aad6a896d8379896b0@netnews.worldnet.att.net>
In article <slrn78n8lq.nlj.randy@theory.uwinnipeg.ca>,
randy@theory.uwinnipeg.ca says...
>
> Hello,
> ActiveState uses Microsoft's nmake (and VC++) by default, I believe.
> If you want to use dmake (or a different compiler), you have to
> change perl's Config.pm - look for a line that says make=... and
> change it to dmake. Similar changes would need to be done if you
> use a different compiler, along with the associated changes to
> the lib and include paths.
> You don't need to use a Unix-like make like from cygwin - either
> nmake or dmake work quite successfully. In fact, to use cygwin's
> make you'd probably have to recompile perl with the cygwin tools.
>
>
Yep, that did the trick. Thank you for your help.
--
Charles Wilt
Miami Luken, Inc.
e-mail: charles.0272@worldnet.no.spam.att.net
--->remove the no.spam.
------------------------------
Date: Fri, 1 Jan 1999 02:38:25 +0800
From: help <wclui@virtue.csis.hku.hk>
Subject: fetch pages
Message-Id: <Pine.GSO.4.03.9901010236010.21952-100000@virtue.csis.hku.hk>
Suppose I am connected to the Internet through PPP and I want to write a
perl script and run in my local machine.
Suppose I have a URL, say
http://xxx.com/xxx.jpg
How can I open a connection to the site and fetch the image?
N.B. I have to fetch the page through the proxy server, e.g. yyy.
Thank You.
------------------------------
Date: Thu, 31 Dec 1998 19:04:34 GMT
From: slick@dick.com (Slick!)
Subject: file::copy and paths
Message-Id: <368bca05.7276082@news.shreve.net>
Sorry for another rudimentry question, but once again I'm baffled.
This works fine:
use File::Copy;
copy("argvtest.pl", "argvtest.pl.bak")||die "Can't copy file $!";
This dosen't work at all
use File::Copy;
copy("argvtest.pl", "H:\temp\argvtest.pl.bak")||die "Can't copy file
$!";
It gives this error:
Can't copy file Invalid argument at copytest.pl line 3.
So how can I make File::Copy copy to a different directory?
"Active Perl" Build 508, Win32 (NT4 SP4)
TIA!
------------------------------
Date: 31 Dec 1998 19:58:07 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: file::copy and paths
Message-Id: <76gl0f$f5$1@gellyfish.btinternet.com>
On Thu, 31 Dec 1998 19:04:34 GMT Slick! <slick@dick.com> wrote:
> Sorry for another rudimentry question, but once again I'm baffled.
>
>
>
>
> This works fine:
> use File::Copy;
>
> copy("argvtest.pl", "argvtest.pl.bak")||die "Can't copy file $!";
>
> This dosen't work at all
> use File::Copy;
>
> copy("argvtest.pl", "H:\temp\argvtest.pl.bak")||die "Can't copy file
> $!";
>
> It gives this error:
> Can't copy file Invalid argument at copytest.pl line 3.
>
> So how can I make File::Copy copy to a different directory?
>
The \ character in Perl has special meaning - you will need to use two
backslashes for each one or even better you should use the forward slash
as per Unix - it is only the DOS command interpreter that cares which you
use. i.e. :
copy("argvtest.pl", "H:\\temp\\argv est.pl.bak")||die "Can't copy file
or
copy("argvtest.pl", "H:/temp/argvtest.pl.bak")||die "Can't copy file
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 31 Dec 1998 21:10:25 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: slick@dick.com (Slick!)
Subject: Re: file::copy and paths
Message-Id: <m3hfucyswe.fsf@joshua.panix.com>
slick@dick.com (Slick!) writes:
> copy("argvtest.pl", "H:\temp\argvtest.pl.bak")||die "Can't copy file $!";
^^ ^^
tab alarm
You can (and ought to) use forward slashes when making OS calls, even
in Win32. If you insist on using backwhacks, make sure you put them
in quotes that don't interpolate.
"H:/temp/argvtest.pl.bak"
'H:\temp\argvtest.pl.bak'
or even (but please don't)
"H:\\temp\\argvtest.pl.bak"
You should read perlop and study the section "Quote and Quote-like
Operators".
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Fri, 1 Jan 1999 01:56:29 +0800
From: help <wclui@virtue.csis.hku.hk>
Subject: Re: help
Message-Id: <Pine.GSO.4.03.9901010154210.20698-100000@virtue.csis.hku.hk>
Also, how about if I have to fetch the image through the proxy server?
On Fri, 1 Jan 1999, help wrote:
> Suppose I am connected to the Internet through PPP and I want to write a
> perl script and run in my local machine.
>
> Suppose I have a URL, say
> http://xxx.com/xxx.jpg
> How can I open a connection to the site and fetch the image?
>
> Thank You.
>
>
>
------------------------------
Date: Thu, 31 Dec 1998 18:45:37 GMT
From: odinjon@my-dejanews.com
Subject: How to change NTFS permissions
Message-Id: <76ggoh$4qv$1@nnrp1.dejanews.com>
Hi,
Do you know of a way to change NTFS file permissions, without shelling out
with `cacls`?
I'm trying to automate our NT account creation process, but don't want to use
`cacls`.
TIA,
Odin
--
Odin.Anderson@TDSTelecom.Com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 31 Dec 1998 19:34:05 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Need sample TCP code
Message-Id: <83k8z85ffm.fsf@vcpc.univie.ac.at>
Re: Need sample TCP code, David
<dharris@dlconsulting.com> said:
David> I would really appreciate some help on this
David> one. I'm trying to find some sample code to
David> allow me to make an http request from within
David> a PERL script and then process the results.
David> I imagine I need to open up a TCP connection
David> on port 80 to the host. I would appreciate
Yes, but let a module take the strain...
David> it if someone could show me some sample code
David> on how to do this. Thanks.
perldoc LWP
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Thu, 31 Dec 1998 15:01:31 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Newbie: string terminator
Message-Id: <MPG.10f5a227131f6ff9989771@news.scescape.net>
In article <368dad3a.782022@news.skynet.be>, bart.lateur@skynet.be
says...
=> Damian Hughes wrote:
=>
=> >I've got the following syntax error with a perl script ....Can't find
=> >string terminator '"' anywhere before EOF at line 792.... I've trawled
=> >the web for a solution but the replies are at least confusing, at best
=> >misleading. Although I don't know Perl, looking at line 792, there
=> >appears to be nothing untoward.
=>
=> In addition to what others already said about this...
=>
=> Search for the very last occurence of '"' in your script. If it's
=> preceded with a backslash, search the one just before that... etc....
=> until you find the start of the string.
=>
=> Hmm... Wouldn't Perl's error messgaes be more helpful if they mentioned
=> the line where this unterminated string starts, instead of where the end
=> of the file is?
=>
=> Bart.
=>
Actually, it does.
Take this for example:
1: #!/usr/bin/perl -w
2:
3: my $cow = "Hello, World!;
4: A
5: B
6:__END__
Can't find string terminator '"' anywhere before EOF at test.pl line 3.
It just isn't very clear about it.
--Matthew
------------------------------
Date: 31 Dec 1998 18:55:19 GMT
From: "Charles R. Thompson" <design@spam_raincloud-studios.com>
Subject: Optimizing if...elsif...else when there are tons of them
Message-Id: <76ghan$gbr@bgtnsc02.worldnet.att.net>
Ok, I'll admit there is probably a much better way to handle this, but here
goes...
I have completed, and am now optimizing a Perl script which contains quite a
few subroutines that are invoked by clicking 'image' buttons in forms.
(doing the button.x test)...
Thing is, for the entire system, there are about 20 buttons and I need to
check for which one was clicked, run a sub within that (with error checking)
then deliver a page. I want to make sure I am doing this as optimized as
possible... Can somebody give this example snippet a quick look?
if ($form_data{'load_main.x'} ne ""){
&load_main();
}
elsif ($form_data{'load_admin_center.x'} ne ""){
&load_admin_center();
}
elsif ($form_data{'load_client_login.x'} ne ""){
&load_client_login();
}
elsif ($form_data{'funct_client_login.x'} ne ""){
if (&verifyclient() eq
s'){
&reset_database_parameters();
&showprojects();
}
else {
print "invalid passkey";
}
}
elsif ($form_data{'load_admin_login.x'} ne ""){
&load_admin_login();
}
<SNIP> about 15 or so more elsif statements
else{
print qq~No or undefined method specified for this module. Exiting Script.~;
&load_footer();
exit;
}
I wonder... and this is a total shot in the dark... Is it possible to name my buttons much like an array btn1 btn2 btn3 btn4 then do some type of loop .. I dunno.. I'm starting to get confused again. Signing off...
CT
------------------------------
Date: 31 Dec 1998 18:01:04 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Perl equivalent of 'C' #include
Message-Id: <76ge50$9l$1@gellyfish.btinternet.com>
On Thu, 31 Dec 1998 15:55:54 -0000 Richard Gordon <abc@abc.com> wrote:
> I am new to perl and wonder if there an equivalent of 'C' #include in perl.
> I am trying to do something like the following
>
> #prog1.pl
>
> $VAR1 = 1 ;
> $VAR2 = 2 ;
>
> #include "prog2.pl"
This is entirely possible.
You might want to look at the perlfunc documenation for 'require' or 'use' and
look at the perlmod manpage perhaps.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Thu, 31 Dec 1998 14:18:45 -0500
From: Brett Diamond <Brett.Diamond@lmco.com>
Subject: Re: Perl equivalent of 'C' #include
Message-Id: <368BCDFD.B57AC3CF@lmco.com>
The built-in Perl do command will read in a file and execute it. You can also
use the -P switch, sending your script through the c preprocessor, which would
be very happy doing those nasty "#include"s for you.
I'm not going to ask WHY you'd want to do this...
Brett Diamond
Brett.Diamond@lmco.com
Richard Gordon wrote:
> I am new to perl and wonder if there an equivalent of 'C' #include in perl.
> I am trying to do something like the following
>
> #prog1.pl
>
> $VAR1 = 1 ;
> $VAR2 = 2 ;
>
> #include "prog2.pl"
------------------------------
Date: 31 Dec 1998 17:20:23 GMT
From: snow@biostat.washington.edu (Gregory Snow)
Subject: Re: Please help will generating biased random numbers.
Message-Id: <76gbon$rig$1@nntp6.u.washington.edu>
In article <76dnr2$s2$1@nnrp1.dejanews.com>, <chad@vcn.net> wrote:
>
>
>
>Hi,
>
>Ok ... I've read the perlcook book concerning this and the doc on
>Math::Random, 'randdom_uniform_integer()' and I still can't seem to get it.
>Can someone please put this in simple terms for me. Of course what I want to
>do is randomly pick a banner based on weighted values (and I don't even
>really know what that means). Can some one point me in the right direction?
>
>-chad
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
try some variation on this:
#!/usr/local/bin/perl -w
use strict;
srand 123;
my @banners = qw(a beta 3 IV);
my @weights = (10, 20, 30, 40);
my %seen;
my $sum;
my @cum_weights = map { $sum+= $_ } @weights ;
for ( @cum_weights ) { $_ /= $sum }
for (1..10000) {
$seen{ $banners[wrand(@cum_weights)] }++;
}
for ( @banners ) {
print "$_ : $seen{$_}\n";
}
sub wrand {
my $r = rand;
my $i=0;
$i++ while $r > $_[$i];
return $i
}
this outputs:
a : 1004
beta : 1944
3 : 3003
IV : 4049
Hope this helps
--
-------------------------------------------------------------------------------
Gregory L. Snow | Matter cannot be created or destroyed,
(Greg) | nor can it be returned without a receipt.
snow@biostat.washington.edu |
------------------------------
Date: 31 Dec 1998 10:05:29 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Please help will generating biased random numbers.
Message-Id: <m1lnjo9ogm.fsf@halfdome.holdit.com>
>>>>> "chad" == chad <chad@vcn.net> writes:
chad> Ok ... I've read the perlcook book concerning this and the doc on
chad> Math::Random, 'randdom_uniform_integer()' and I still can't seem to get it.
chad> Can someone please put this in simple terms for me. Of course what I want to
chad> do is randomly pick a banner based on weighted values (and I don't even
chad> really know what that means). Can some one point me in the right direction?
My Dec 96 Perl columns in WebTechniques (available online at
<URL:http://www.stonehenge.com/merlyn/WebTechniques/>) shows how to
select a random item based on weighted inputs, and probably is pretty
close even to what you wanted to do (random SSI).
Go check it out.
print "Just another random Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 31 Dec 1998 18:17:48 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Problem with Net::SMTP under NT
Message-Id: <76gf4c$a0$1@gellyfish.btinternet.com>
In comp.lang.perl.misc Marcel Beekmans <beekmans@iae.nl> wrote:
> The "Helo" part of the Net::SMTP module appears not to work under NT. It
> in fact hangs up the complete IIS server. I need the "Helo" command to
> make my application work, because the smtp-server of my provider is
> configured in (they say a secure) way, that it needs this command. How
> can I solve this problem?
>
I dont think that there is a problem 'per se' with the 'HELO' thing on
NT however I have experienced problems with the Net::SMTP module with
build 506 of ActivePerl - having gone to 508 the problem has gone away.
The problem you are experiencing however might actually be related to
something unconnected to perl or some module but might, for instance,
be to do with a bad DNS setup or some other network problem.
I would suggest that you try out some other mail client on your NT box
using the same SMTP server as you are attempting to use to see if the
problem lies there.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Thu, 31 Dec 1998 18:39:59 GMT
From: gareth@ibis.demon.co.uk (Gareth Jones)
Subject: Re: Problem with Win32API::Net::UserEnum
Message-Id: <368bc419.2752093@news.demon.co.uk>
gareth@ibis.demon.co.uk (Gareth Jones) wrote:
Doh. I've figured it out. You have to establish a null session before
calling the UserEnum function.
Gareth
>I'm having a problem with this bit of code:
------------------------------
Date: 31 Dec 1998 19:56:19 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Retrospective on comp.lang.perl.moderated?
Message-Id: <76gkt3$12h$1@news.NERO.NET>
In article <m31zlhkwov.fsf@moiraine.dimensional.com>,
Daniel Grisinger <dgris@moiraine.dimensional.com> wrote:
>> None of the lists I subscribed to did this. None of the lists from
>> which I receive spam (e.g. realmedia) does this. 0 out of 5 does not
>> support your claim of "most".
>
>The following lists require confirmation for subscription-
>
> All egcs lists ( 6 lists )
> All perl.org lists ( 30 lists )
> All debian.org lists ( 67 lists )
> All redhat.com lists ( 21 lists )
> All gnome.org lists ( 12 lists )
> All xemacs.org lists ( 8 lists )
Yes, you certainly proved me wrong. There certainly could not be more
than these 144 lists in the world. I guess the "lists of lists" that
show thousands of mailing lists are just wrong, and I guess all those
lists I subscribe to don't exist. I guess that all those lists not
listed in the list of lists don't exist.
>143 out of 148 is certainly sufficient to claim most.
No, one more than half of all lists in existance is sufficient to claim
"most". I think there are lots more than 148 lists operating in the
world. I have at least a half a dozen here. I subscribe to a
considerable number of lists from other places (none required
confirmation).
I count 144 lists you claim prove your point. Which of the 144 lists
that all require confirmation doesn't require confirmation, and where
do you get the 4 that don't?
>> Since most lists require just one email, yes, I'm sorry, it is harder to
>> make the first posting to .moderated.
>
>If most lists only required one mail this would be true.
Then you admit it is true. Thanks.
>No, it won't make any difference. People who don't bother to provide
>standards compliant mail and news articles certainly aren't going to
>change to do the right thing.
You can expect them to change what they are doing because you use
broken software, but you might have more success if you get better
software. Trn, for example, has no problems processing munged
addresses. What you are using now seems to have no problems following
up to articles with my address in them. What is it about other
addresses you cannot send mail to that breaks your newsreader, and how
does it exhibit this broken behaviour?
------------------------------
Date: 31 Dec 1998 20:14:57 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Retrospective on comp.lang.perl.moderated?
Message-Id: <76gm01$1g1$1@news.NERO.NET>
In article <76g65t$s2s$1@nnrp1.dejanews.com>, <dturley@pobox.com> wrote:
>I made my first post to clp.mod last week.
I made my first post to .moderated a few weeks after it was created. I
got nothing in response. No rejection, no registration request, no
article. A couple of weeks later, I tried again and it worked.
>I received the mail, hit reply and
>that was it. Didn't even take 2 seconds. If people don't like the rules
>established for the group, DON'T POST TO IT! and quit wasting bandwidth
>bitching about it. ____________________________________ David Turley
If you don't want to see a discussion about the group, don't read a
thread with the subject "Retrospective on comp.lang.perl.moderated?"
When someone starts a thread in .misc so people can pat each other on
the back for how well a different group is doing, those who don't agree
have every right to reply with their opinion. Unless you condemn those
who pat themselves on the back in an inappropriate forum, don't condemn
those who don't agree.
------------------------------
Date: 31 Dec 1998 18:03:23 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Thanks! and happy new year!
Message-Id: <76ge9b$9o$1@gellyfish.btinternet.com>
On 31 Dec 1998 16:54:49 GMT Gregg Silk <greggsilk@aol.com> wrote:
> Thanks to everyone so far. I am amazed at what a helpful and polite group this
> is. I have seen newgroups for other languages where it seems like some people
> spend their whole so-called lives flaming newbies and telling them to post
> elsewhere. Of course, I always took those flamers as an encouraging sign, since
> I figured I'd soon be beating them up and taking their lunch money. But it's
> also very encouraging to know there are lots of decent folks out there as
> well. Happy New Year!
>
Ah well at least the art of satire isnt dead ;-}
Perhaps we ought have this framed on the wall of the clp.misc bunker.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Thu, 31 Dec 1998 15:03:43 -0500
From: "c.s." <cs2400@hotmail.com>
Subject: win32 registry keys for Perl
Message-Id: <76glab$q3$1@remarQ.com>
hello,
I am having trouble getting Perl to work on my machine. I can run scripts
from the command line just fine, but invoking them via a web server causes
Perl to choke.
I have checked the FAQs, but I am somewhat new to this, so I may have missed
something.
My system:
Win98
Microsoft PWS.
The problem:
While installing perl (build 507 and 508), the installer complains several
times
that it "Cannot Access The IIS MetaBase.... continue installation ? y/n ".
I chose "yes" to continue all of the times. (It also suggested that I
restart the machine and try again, but this did not help.)
Perl was installed to c:\perl\bin. I was able to run all my scripts from
command line just fine, however the webserver did not seem to configured to
recognize perl yet.
At this point, I added the .pl(x) => "c:\perl\bin\perl.exe(perlIS.dll) %s
%s" keys to:
HKLM\System\CurrentControlSet\Services\W3SVC\Parameters\Script
Map
Now, the server seems to call Perl just fine, but one of two things will
happen when I
try to request a script via the web server.
When requesting a ".pl" file:
The server seems to stall, returning no information to the browser. Hitting
"Ctrl-Alt-Delete" reveals that there is a process by the name of "Perl"
running at the moment. Eventually, forcing this process to quit will cause
the server to send a generic CGI error to the browser. (it appears that the
perl process never supplied any output)
When requesting a ".plx" file": (perlIS.dll)
The server will return a page that says "One of the library files needed to
run this application cannot be found. "
Does perl require any additional / special registry settings for it to run
as a CGI? I don't think that it is the server's fault, since PHP3 works
perfectly.
Thank you for your time,
cs2400@hotmail.com
------------------------------
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 4525
**************************************