[13755] in Perl-Users-Digest
Perl-Users Digest, Issue: 1165 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 24 09:05:20 1999
Date: Sun, 24 Oct 1999 06:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940770308-v9-i1165@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 24 Oct 1999 Volume: 9 Number: 1165
Today's topics:
Re: CGI script to start a perl script in the background <qajurria@qajurria.cx>
Re: Comments in Perl (Abigail)
Re: E-Mail via script Perl ? flamencoman@earthlink.net
Re: How can I make to print the times that I input wor <gellyfish@gellyfish.com>
Re: linux perl editor? (Arved Sandstrom)
Re: numbers only, no text <r28629@email.sps.mot.com>
Re: Perl vs. REBOL (Martien Verbruggen)
Re: Perl vs. REBOL (Michel Dalle)
Re: Picking 5 items from a random list (Abigail)
Re: Picking 5 items from a random list (Abigail)
Re: Reference challenge (Abigail)
Re: Regular Expression...to remove last Field!!!! <r28629@email.sps.mot.com>
Re: Request style comments (code included - longish) <gellyfish@gellyfish.com>
Re: Script Path value for Active Perl on Win32 <gellyfish@gellyfish.com>
Re: Security on the web with Perl (Martien Verbruggen)
Re: Security on the web with Perl <qajurria@qajurria.cx>
Re: Something like DEFINE?? (Martien Verbruggen)
Re: To all: How to sell Perl Scripts <gellyfish@gellyfish.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 24 Oct 1999 11:16:28 GMT
From: QaJurria <qajurria@qajurria.cx>
Subject: Re: CGI script to start a perl script in the background.
Message-Id: <7uupqc$h2i$1@enterprise.cistron.net>
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> Of course in a CGI environment the child process will need to close its
> STDOUT otherwise the server will keep the browser connection open in
> the expectation of more output to send.
True :)
Jurriaan
--
/ Perl, PHP, Lite, SQL, MySQL, mSQL; / Jurriaan Kamer |
/ HTML, DHTML, JavaScript, Webdesign; / aka. QaJurria |
| Holy: / Security Consultancy. / qajurria@qajurria.cx |
| perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
------------------------------
Date: 24 Oct 1999 06:08:26 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Comments in Perl
Message-Id: <slrn815q4j.fji.abigail@alexandra.delanet.com>
Bart Lateur (bart.lateur@skynet.be) wrote on MMCCXLV September MCMXCIII
in <URL:news:3817d08d.2942606@news.skynet.be>:
%% Abigail wrote:
%%
%% >~~ > One byte less on Unix, same amount of bytes on Windows.
%% >~~
%% >~~ Only in a file. :)
%% >
%% >I assume you're not going to comment out stuff for things you
%% >type interactively....
%%
%% I guess Martien ment that on Windows, CRLF is converted to LF when
%% reading from a text file, and back to CRLF when writing to it. So, in
%% memory, it's the same amount of bytes, likely even the same bytes, as on
%% Unix.
Oh, really?
I assume that when the program is compiled, comments are gone.
So, the "in memory" doesn't make sense. Of course I'm talking about
the programming text. Which, if there are comments is very likely
to be in a file, and not something interactively typed with -e or
on stdin.
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())))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sun, 24 Oct 1999 12:14:27 GMT
From: flamencoman@earthlink.net
Subject: Re: E-Mail via script Perl ?
Message-Id: <3813f467.3723703@news.earthlink.net>
I've been using the following format in my Unix perl script to
automatically e-mail various people. The $subject variable holds the
mailer subject and the $email variable holds the recipients e-mail
address. $your_email_name is the sender's e-mail address. The @NAME
array holds a list of names that are targeted for e-mail. The @EO
array holds a list of numbers. $date holds the date when a response is
due. $first_name is the sender's friendly handle.
Originally, I was using the example that came in the Perl Cookbook
that used sendmail but the results were not good, so I started using
mailx which would send the mail message out right away. I was using
the following code in a for loop which kept changing the $email
variable each time the counter was incremented. This snippet is part
of a larger perl script that I wrote that does a few other things
besides sending out e-mail.
If some one know how to send mail from Windows NT using Outlook or
Netscape please chime in.
Hope this helps.
open(MAIL, "| mailx -s '$subject' $email");
print MAIL <<EOF;
To: $email
CC: $your_email_name
The following EO's do not have a valid EO number. Please complete
the correct EO number on or before $date.
EO Engineer's name: $NAME[$I]. List of EOs:
$EO[$I]
Thanks,
$first_name
EOF
close(MAIL);
------------------------------
Date: 24 Oct 1999 12:02:33 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How can I make to print the times that I input word ?
Message-Id: <7uusgp$g37$1@gellyfish.btinternet.com>
On Sun, 24 Oct 1999 19:16:44 +0900 Yeong Mo/Director Hana co. wrote:
>
> Marcel Grunauer ÀÌ(°¡) ¸Þ½ÃÁö¿¡¼ ÀÛ¼ºÇÏ¿´½À´Ï´Ù...
>>On Sat, 23 Oct 1999 20:15:31 +0900, "Yeong Mo/Director Hana co."
>><hmaster@factory.co.kr> wrote:
>>
>>[snip code]
>>
>>> There is little of your misunderstanding;
>>> I want print only one aaa and bbb....
>>> and when I try aaa or bbb again from the from method
>>> I don't want it to be printed again like;
>>> aaa
>>> bbb
>>> bbb
>>> aaa
>>>
>>> I hope it to be printed
>>> aaa|2
>>> bbb|2
>>
>>Well, that's what the code I posted earlier does.
>>
>>HTH. HAND.
>>
>>
>>--
>>Marcel, Perl Padawan
>>sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;
>
>
> Thank you Marcel Grunauer
>
> I am talking about not html output page, but data.db file.....
I dont see anywhere in Marcel's snippet that would indicate that he is
outputting an HTML page - he is simply outputting data in the format
you describe based on the input that you describe - that is some word
followed by a count of the number of times it has occurred. That he
hasnt shown how to output this to any particular file and is for convenience
printing to STDOUT should not be a problem - you will simply open the
filehandle as appropriate and print to that instead.
>
> See ===> print FILE "$mID\n";
> open(FILE, ">>data.db") || die "I can't open data.db file \n";
> flock (FILE, 2) or die "can't lock data file\n";
> print FILE "$mID\n";
> close(FILE);
>
I have this feeling that you have not accurately described what it is you
are trying to achieve. In consultation with my psychic assistant Doris
I have come up with this analysis of your problem:
You have a file that consists of records containing a word and a count
of the number of times that it has occurred separated by a solidus ('|').
You want to input some data (possibly from STDIN).
Based on this input you want to update your data file with the new count
of words.
If this is an accurate analysis then this is one way to do it:
#!/usr/bin/perl -w
use strict;
use Fcntl qw(:flock);
my %data;
open(DATA,'data.db') || die "Can't open data.db - $!\n";
# flock file in shared mode as we dont want to read from it
# if someone else is writing at the same time
flock(DATA,LOCK_SH) || die "Can't flock data.db in shared mode - $!\n";
# Load data from file into the hash as word/count pairs
while(<DATA>)
{
chomp;
my ($word,$count) = split /\|/;
$data{$word} = $count;
}
close DATA;
# Input words one per line from STDIN
# if there are to be more than word per line then further processing will
# be required - that is left as an exercise to the reader.
while(<STDIN>)
{
chomp;
$data{$_}++;
}
# open file in read/write mode so as not to clobber file before
# getting an exclusive lock
open(DATA,'+<data.db') || die "Can't open data.db for read/write - $!\n";
# now get exclusive lock on file
flock(DATA,LOCK_EX) || die "Can't get exclusive lock for data.db - $!\n";
# Having exclusive lock we can safely clobber the file
truncate(DATA,0) || die "Can't truncate data.db - $!\n";
# now write out the updated data from the hash
foreach ( keys %data )
{
print DATA "$_|$data{$_}\n";
}
close DATA;
Of course the only difference between this and Marcel's example is that
this populates the hash from the file first and then writes back to the
same file.
It really does help if you are more explicit about your problem.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 24 Oct 1999 08:30:47 -0300
From: Arved_37@chebucto.ns.ca (Arved Sandstrom)
Subject: Re: linux perl editor?
Message-Id: <Arved_37-2410990831180001@192.75.95.30>
In article <slrn815lq1.fji.abigail@alexandra.delanet.com>,
abigail@delanet.com wrote:
> Elaine -HFB- Ashton (elaine@chaos.wustl.edu) wrote on MMCCXLI September
> MCMXCIII in <URL:news:380DDDB5.647B3D86@chaos.wustl.edu>:
> `` Kent Perrier wrote:
> `` > I like echo.
> ``
> `` Real men use ed :)
>
> Pfff. ed is for wussies. Real (wo)men toggle front panels.
>
I'm sort of trying to get into this mindset on the UNIX side... :-) For
someone who demands ultimate performance from text editors over in MacOS
and Windows, I have been schizophrenic to also have happily continued to
use (nay, power-use) 'vi' on UNIX. Probably this dates from when I started
programming, when editing meant throwing punched card A into the trash and
replacing it with punched card B. :-)
I started messing around with emacs again. Some people I respect use it
and swear by it, so I'll see how it goes. I looked at it once many moons
ago, and I guess it suffered by comparison when I really really needed to
get things done fast and had to go back to 'vi'. No reflection on 'emacs'
- just my state of knowledge at the time. I was favourably impressed, I
must admit, by the state of integration of RCS into emacs, which is
important for me. So I'll give it a shot.
Some bright kids I know use 'joe' and 'pico'. Any thoughts on these?
Still, there are good reasons to maintain 'vi'/'ex' knowledge. When that
Linux system barfs, and fsck says 'Whoa', and you ain't starting up at the
runlevel you'd like to, 'vi' might be your friend. :-)
Arved Sandstrom
------------------------------
Date: Sat, 23 Oct 1999 22:53:21 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: numbers only, no text
Message-Id: <381282B1.A81ECBCE@email.sps.mot.com>
Joe Zelwietro wrote:
> ...
> This line contains the number 1234
> ...
>
> My first attempt to deal with this was to use the substr function. That
> is, have the script place the final 4 bytes of the line into the variable.
> Such as:
> push (@allNunbers, substr($_-4)."\n";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... and you have tried this ? what did you get?
------------------------------
Date: 24 Oct 1999 11:46:58 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: Perl vs. REBOL
Message-Id: <slrn815sei.fk5.mgjv@wobbie.heliotrope.home>
[Your newsreader seems to have a chronology problem. Your reply to my
post come before the quoted text. Please reverse the clock on your
machine]
[fixed format]
On Sat, 23 Oct 1999 23:49:27 -0400,
Billy Zhao <bz9t@yahoo.com> wrote:
> Martien Verbruggen <mgjv@wobbie.heliotrope.home> wrote in message
> news:slrn813cue.dii.mgjv@wobbie.heliotrope.home...
> > On Fri, 22 Oct 1999 23:05:48 -0400, Billy Zhao <bz9t@yahoo.com> wrote:
> > > Hi,
> > >
> > > I'm working on a project for my programming languages class. Given as
> > > how REBOL is still relatively new and there're not too many
[snip of rest of post, quoted in entirity, including signature]
> Martien,
>
> "Keep in mind that it is intended to help inform newcomers." That's in the
> email from Nathan Torkington.
Yes? I read that. And?
> I count myself as a newcomer. If you feel
So do I.
> If you feel
> like patronizing me, email the reponse to me, there's no need to post
> sarcastic comments to the group. If you don't feel like helping, don't.
I don't at all feel like patronising you. Not at all. I've got better
things to do. I was just pointing out to you that posts about language
comparisons are considered evil, and that posts asking newsgroups to do
_your_ work are considered lazy. Yours falls in both categories.
If that isn't helping to prevent you making the same mistake when you
need to know the respective strengths of Basic vs. C or Pythin s. tcl,
then I don't know any more.
Besides that, I wasn't using sarcasm. Just information.
> But please keep your mean spirited arrogance to yourself.
`mean' implies intent.
`spirit' implies the belief in something ethereal.
`arrogance' implies more than two syllables.
I feel thoroughly rebuked. Thank you.
Martien
--
Martien Verbruggen |
Interactive Media Division | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd. | from a rich salesperson.
NSW, Australia |
------------------------------
Date: Sun, 24 Oct 1999 12:23:56 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Perl vs. REBOL
Message-Id: <7uutop$fds$1@xenon.inbe.net>
In article <slrn815sei.fk5.mgjv@wobbie.heliotrope.home>, mgjv@comdyn.com.au wrote:
>On Sat, 23 Oct 1999 23:49:27 -0400,
> Billy Zhao <bz9t@yahoo.com> wrote:
<snip>
>> But please keep your mean spirited arrogance to yourself.
>
>`mean' implies intent.
>`spirit' implies the belief in something ethereal.
>`arrogance' implies more than two syllables.
Hmm, what version of English are you using ? This doesn't compile
in ActiveEnglish build 5.19 !?
I always get the following error message : "Too many ('s"
Internal urp in regexp at /%s/,
Michel.
------------------------------
Date: 24 Oct 1999 07:42:54 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Picking 5 items from a random list
Message-Id: <slrn815vlm.fji.abigail@alexandra.delanet.com>
Larry Rosler (lr@hpl.hp.com) wrote on MMCCXLV September MCMXCIII in
<URL:news:MPG.127bedced31a447598a10d@nntp.hpl.hp.com>:
__
__ Populate a hash with five random integers as keys, then use the keys as
__ an array slice.
__
__ #!perl -w
__ use strict;
__
__ my @items = ("Item1","Item2","Item3","Item4","Item5",
__ "Item6","Item7","Item8","Item9","Item10");
__
__ my %hash;
__ $hash{int rand @items}++ until keys %hash == 5;
__
__ my @out = @items[keys %hash];
__
__ print "@out\n";
__ __END__
__
__
__ There is another, shorter approach using splice, but it destroys the
__ input and is quadratic in behavior. The approach above is far superior.
Really? Then do prove its correctness.... ;-)
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 24 Oct 1999 07:50:43 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Picking 5 items from a random list
Message-Id: <slrn81604c.fji.abigail@alexandra.delanet.com>
AcCeSsDeNiEd (dillon_rm@magix.com.sg) wrote on MMCCXLIV September
MCMXCIII in <URL:news:38123b44.2152336@news.magix.com.sg>:
() Hi,
()
() I have a list of 10 items. I know how to pick one item at random. It
() goes like this:
()
()
() @items =
() ("Item1","Item2","Item3","Item4","Item5","Item6","Item7","Item8","Item9","Item10");
()
() srand(time ^ $$);
() $num = rand(@items); # Pick a Random Number
()
() # Print Out Random Item
() print "Random Item picked is: $items[$num]\n";
()
()
() My question is, how do I pick 5 items at one time randomly from the
() list?
() I could do a while loop, but then the 5 times picked will surely have
() duplicates.
() Any hints?
It's basically the same as shuffling, just that you can finish sooner.
# First argument of pick is the number of things to pick,
# rest is a list of things to pick from.
# Precondition: number of things to pick <= number of things to pick from.
sub pick ($@) {
my ($number, @list) = @_;
my $max = @list;
my @out = (0) x $number;
foreach (0 .. $number - 1) {
$out [$_] = $list [my $i = int rand $max --];
$list [$i] = $list [$max];
}
@out;
}
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 24 Oct 1999 08:02:43 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Reference challenge
Message-Id: <slrn8160qr.fji.abigail@alexandra.delanet.com>
Sean McAfee (mcafee@waits.facilities.med.umich.edu) wrote on MMCCXLIV
September MCMXCIII in <URL:news:ubpQ3.516$4G.101917@news.itd.umich.edu>:
??
?? perlfunc guarantees only that ref() returns FALSE if its argument is not a
?? reference. Sure, ref() returns "" *now* if passed a non-reference, but
?? suppose a future version of Perl returned 0 instead? Your code would
?? break.
Oh, comeon. Be realistic. You've never encountered the p5p compability
police. It's more likely to win the state lotto twice in a row, without
buying a ticket, than that something in Perl changes behaviour. ;-)
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sat, 23 Oct 1999 22:46:51 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Regular Expression...to remove last Field!!!!
Message-Id: <3812812A.B5F27C38@email.sps.mot.com>
Govindaraj wrote:
> R:|6||3EB-04-24190||CLAMP||2||||||||2501
> R:|6||3EB-04-24190||CLAMP||2||||||||test2501
>
> How can I remove the last field (i.e |2501 and |test2501) from the
> above line with the Reqular expression. I don't want to use
> the Array/split options for this one... I really want to achieve this
> with our great Regular Expersion.
I'll leave the great Regular Expersion to regex guru, but for what you
want, substr() might be faster, if you care:
substr($line, rindex($line,'|')) = '';
-TK
----
use Benchmark;
$org = 'R:|6||3EB-04-24190||CLAMP||2|||||||x|test2501';
timethese(100000, {
regex => sub {
$line = $org;
$line =~ s/\|[^|]+$//;
},
substr => sub {
$line = $org;
substr($line, rindex($line,'|')) = '';
},
});
__END__
Benchmark: timing 100000 iterations of regex, substr...
regex: 4 wallclock secs ( 2.85 usr + 0.00 sys = 2.85 CPU)
substr: 1 wallclock secs ( 0.93 usr + 0.00 sys = 0.93 CPU)
------------------------------
Date: 24 Oct 1999 12:58:44 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Request style comments (code included - longish)
Message-Id: <7uuvq4$g43$1@gellyfish.btinternet.com>
On Sun, 24 Oct 1999 08:38:13 GMT Carrie Duffy wrote:
> Hello,
>
> I've been working on a program to do several ftp sessions and average
> the throughput to test our LFN performance (this compiles fine, BTW). I
> know it's in no way portable (only Linux), but I noticed that my
> variable declaration list tends to get huge, and my coding style seems
> rather, well, verbose. Can anyone offer some tips to help make my code
> easier to parse (for humans, that is :P). Thanks!
>
> #!/usr/bin/perl -w
> use strict;
> use diagnostics;
>
I would leave out diagnostics in production code as it is quite big
and is really only any use in development.
> my ($session, $date, $iter, $current, $rate, $total, $average, $index,
> @nums,
> $rcvbufdef, $rcvbufmax, $xmtbufdef, $xmtbufmax, $through, $pingrun,
> $ping,
> $ms, $rtt, $host );
>
For eye ease I would put these on separate lines all lined up but thats
a matter of personal taste - I really hate to see long lists. Also the
widely used idiom is to use my on the variables at the time of its first
definition or at the beginning of the block in which it is used.
> #log it all, or I don't get paid
> open (LOG, ">>ftplog") or die "Can't open logfile: $!";
>
> #log who we are
> $host = `hostname`;
You could/should use Sys::Hostname for this - though it might use hostname
anyhow.
You could for instance have left $host out of the 'my' list back there
and said:
my $host = `hostname`;
instead.
> chomp ($host);
>
> $current = 1;
>
> #do 5 pings and average them to get the RTT
> $pingrun = 5;
>
> while ($pingrun < 6) {
> $ping = `ping cairhien -c 1`;
>
There is a Net::Ping module that might work for you instead.
> #regex matches the # before decimal
>
> $ping =~ /time=(\d+).+/;
> $ms += $1;
> ++$pingrun;
> }
> $rtt = ($ms / 5);
>
>
> #set timestamp once to mark session start
> $date = `date '+%x %X'`;
Oof! most people would prefer to use localtime and POSIX::strftime or
format the date themselves using sprintf rather calling an external
program.
> chomp ($date);
>
>
> #log our buffer sizes, so we know if window scaling will occur
> $rcvbufdef= `cat /proc/sys/net/core/rmem_default`;
> chomp ($rcvbufdef);
> $rcvbufmax = `cat /proc/sys/net/core/rmem_max`;
> chomp ($rcvbufmax);
> $xmtbufdef = `cat /proc/sys/net/core/wmem_default`;
> chomp ($xmtbufdef);
> $xmtbufmax = `cat /proc/sys/net/core/wmem_max`;
> chomp ($xmtbufmax);
>
Useless use of 'cat' and backticks : you could open these files directly
in Perl and read them straight in - probably setting $/ to undef to
slurp the entire contents.
{
local $/;
opem(RMEMDEF,'/proc/sys/net/core/rmem_default' ) || die " ... - $!\n";
chomp($rcvbufdef = <RMEMDEF>);
close RMEMDEF;
# etc ...
}
>
> # get number of test runs from the user
> print "Number of iterations?: ";
> $iter = (<STDIN>);
> chomp ($iter);
>
> # log date, all buffer sizes, and RTT
> print LOG "\n\n############################################\n\n";
> print LOG "New testing session begun on $date, $iter iterations
> requested.\n\n";
> print LOG "Hostname is $host.\n";
> print LOG "Default receive buffer size is $rcvbufdef bytes.\n";
> print LOG "Maximum receive buffer size is $rcvbufmax bytes.\n";
> print LOG "Default transmit buffer size is $xmtbufdef bytes.\n";
> print LOG "Maximum transmit buffer size is $xmtbufmax bytes.\n";
> print LOG "Average RTT is $rtt milliseconds.\n\n";
> print LOG "Results as follows:\n\n";
>
Personally as soon as I see more than two consecutive print()s I immediately
reach for the 'here doc'
print LOG <<EOLOG;
#########################################################
New testing session begun on $date, $iter iterations requested.
Hostname is $host
blah blah
EOLOG
> #loop through number of test runs, capture throughput
> until ($current > $iter) {
> $session = `ftp caemlyn`;
>
You might want to examine the possibility of using Net::FTP. again you might
not ;-}
> #regex matches the # ftp returns
> $session =~ /(\d+)(\sKbytes\/sec)/;
> $date = `date '+%x %X'`;
You already did that - again use localtime and format whowever you prefer.
> chomp ($date);
>
> #multiply to get kbits
> $through = ($1 * 8);
>
Ouch. you used $1 without testing whether the pattern match was successful.
Hope that helps
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 24 Oct 1999 11:05:41 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Script Path value for Active Perl on Win32
Message-Id: <7uup65$g0q$1@gellyfish.btinternet.com>
On Sun, 24 Oct 1999 12:00:10 +1300 Adam Ratcliffe wrote:
>
> I have just installed Active Perl on my Win 95 machine, running Personal
> Webserver 4.0. The Perl interpreter works fine from a DOS Window however
> when I seek to execute a script from within my browser it still directs the
> output to a terminal window rather than the Browser window.
>
> I have checked the Script Path key in the Registry and this has no value
> currently assigned to it although I selected the option for Active Perl to
> map to PWS.
>
> My best guess is that I need to edit the Script Path value, any comment on
> this would be most appreciated!
>
This is described in the Win32 Specific FAQ that is distributed with
ActivePerl - you will find this under the Active Perl shortcut in your
start menu. There is an entire section dedicated to configuring various
Web Servers of which PWS is one.
Alternatively I have got the appropriate part of the IIS 3 documentation
at <http://www.btinternet.com/~gellyfish/docs/map.html> - although this
shouldnt be taken as an excuse not to read the FAQ.
Further questions regarding the configuration of PWS should addressed to
the group comp.infosystems.www.servers.ms-windows.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 24 Oct 1999 11:22:50 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: Security on the web with Perl
Message-Id: <slrn815r18.fk5.mgjv@wobbie.heliotrope.home>
On Sat, 23 Oct 1999 23:59:26 -0500,
Jim <jkrogerDONCHA_SPAM_ME@earthlink.net> wrote:
>
>
>
> Hi, I have a question about Perl security on the web.
Security and Web => HTTPS
Has nothing to do with Perl. perl is unrelated to the web.
> I want to do a web site that takes info from a form, feeds it to a
> program, takes the output from the program, and puts it back on the
> website for the reader to see.
yep, sounds more like a HTTPS job to me already.
> The program will be a compiled C program, but as far as I know the way you
> feed info between the web page and the program is using CGIs, which are
> Perl.
Not at all. CGI != Perl, Perl != CGI. CGI is an Interface, Perl is a
language, just like C or Python. If your language can do all the things
that the CGI spec wants, then you can implement the interface.
> If I'm not mistaken those have to be text files which the Perl
> interpreter reads.
Very much in the same way that C code is text that the compiler reads.
> So what is to stop somebody from stealing my program,
> and my Perl scripts?
What is there to stop anyone from reverse engineering your C code or
Java code, and using that? (Just as an illustration: Sybase was so
bloody slack fixing a problem with their JConnect jdbc drivers that we
reverse engineered it, and sent them the patch ourselves)
If you believe that compiling things into bytecode gives you any
protection, you might as well believe that the planets have an influence
on your life.
You may be very interested in reading the Perl FAQ, particularly part 3,
the quesiton entitled 'How can I compile my Perl program into byte code
or C?' If you believe that merely compiling something into bytecode is
better than a copyright statement, then go ahead, compile your perl
stuff.
What I wonder about, really, is whether it's worth stealing the scripts
of somone who doesn't know this already.
> The program alone would not help them, because
> without the scripts it wouldn't make sense, but with the scripts they
> could basically steal the
Wait.. The program alone... without the scripts.. What is the difference
between a program and a script?
> entire engine driving my site (let's say it's a horiscope program). Also,
> the Perl scripts are useful themselves, and they can just read them.
A horiscope program? Is that a horizontal periscope? Or did you mean
horoscope?
> How do I protect my stuff? Should I try to use all C instead of Perl? They
> can still steal it though.
You protect your stuff by having a good copyright notice, and a lawyer
if necessary.
Martien
--
Martien Verbruggen |
Interactive Media Division | I took an IQ test and the results
Commercial Dynamics Pty. Ltd. | were negative.
NSW, Australia |
------------------------------
Date: 24 Oct 1999 12:25:21 GMT
From: QaJurria <qajurria@qajurria.cx>
Subject: Re: Security on the web with Perl
Message-Id: <7uutrh$kkp$1@enterprise.cistron.net>
Martien Verbruggen <mgjv@wobbie.heliotrope.home> wrote:
>> The program alone would not help them, because
>> without the scripts it wouldn't make sense, but with the scripts they
>> could basically steal the
>
> Wait.. The program alone... without the scripts.. What is the difference
> between a program and a script?
>
See the section "Is it a Perl program or a Perl script?" at the Perlfaq on Perl.com
(http://www.perl.com/pub/doc/manual/html/pod/perlfaq1.html#Is_it_a_Perl_program_or_a_Perl_s)
:)
Jurriaan
--
/ Perl, PHP, Lite, SQL, MySQL, mSQL; / Jurriaan Kamer |
/ HTML, DHTML, JavaScript, Webdesign; / aka. QaJurria |
| Holy: / Security Consultancy. / qajurria@qajurria.cx |
| perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
------------------------------
Date: 24 Oct 1999 11:08:55 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: Something like DEFINE??
Message-Id: <slrn815q74.fk5.mgjv@wobbie.heliotrope.home>
On Sun, 24 Oct 1999 19:11:28 +1000,
Stephen J Whitfield <rwhitfie@speedlink.com.au> wrote:
> Hi,
>
> Is there something in Perl similar to DEFINE in C?? I haven't seen
> anything in the documentation.
There is no such thing as DEFINE in C. Are you talking about #define
preprocessor directives? Check out the -P flag to Perl. And check out
the constant pragma, if that is what you really need.
# perldoc perlrun
# perldoc constant
Or, if you're on a real OS, you should be able to use man.
Martien
--
Martien Verbruggen |
Interactive Media Division | Can't say that it is, 'cause it
Commercial Dynamics Pty. Ltd. | ain't.
NSW, Australia |
------------------------------
Date: 24 Oct 1999 12:33:25 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: To all: How to sell Perl Scripts
Message-Id: <7uuual$g3b$1@gellyfish.btinternet.com>
On Sun, 24 Oct 1999 04:40:00 GMT Jesse A wrote:
>
> Hi everyone,
> After months of hard work, I've made very powerful CGI script that can
> automate many parts of a web site. Well, now its up for sale but I haven't
> gotten too many requests b/c of the steep pricetag.
>
Maybe this should suggest that you are asking too much for the program - if
it is truly as useful as you think it is to a large target market then
people will be prepared to pay for it what they think its worth to them.
If however people think that they can achieve what your program does
without significant outlay then they are unlikely to purchase it.
Have you identified a target market and researched the cost of competitive
solutions ?
> Is there a more effective way I could sell it? I was thinking of making it
> open source and accepting donations but I wouldn't get even close to what
> its worth.
I would go for giving it away. Whatever you might think of your program
you will never have put into it as much work as has gone into Perl itself,
or Apache, or Linux - all open source, all free.
If your program is as good as you think it is then people will use it and
you will probably be able to make more by offering value-added services.
This kind of business model is beginning to emerge in the open source world
there are a number of companies that are becoming succesfull on the back
of open source products.
> I also thought about making a watered-down version for free or
> maybe a semi-full version script with ads to my site in all of its output.
>
Dont do that - everyone will hate you and no-one will use the program - by
all means offer a fully working free version and then offering extra
facilities at a price: better integration with other systems for instance.
People are unlikely to use something that makes them look like cheapskates
and thus the advert thing is likely to backfire - of course if you release
it as open source and then *ask* people to place a link to your pages
then, if they like the product, they are likely to do so.
Having typed this I am beginning to think that this is probably not the
best place to be discussing this - I have a feeling that it will degenerate
into a flamefest as there are people who have stronger feelings on these
things than I.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 1165
**************************************