[12178] in Perl-Users-Digest
Perl-Users Digest, Issue: 5777 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 25 16:07:26 1999
Date: Tue, 25 May 99 13:00:24 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 25 May 1999 Volume: 8 Number: 5777
Today's topics:
Re: $var =~ s/string/pattern/i does not work... <jdporter@min.net>
Re: $var =~ s/string/pattern/i does not work... (Greg Bacon)
...SOLVED, but questions (LONG) (Daniel Parish)
Re: anyone knows if theres any bug with my code? (Larry Rosler)
Re: Baffled by regexp behaviour <cassell@mail.cor.epa.gov>
Re: Baffled by regexp behaviour (Larry Rosler)
Re: Can't use string as a hash ref... (Daniel Parish)
Re: Changing <STDIN> (Greg Bacon)
CodeMagic or Pete aka David Grove <jd.elliott@fmr.com>
Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe bshair@unixmail.cmi.itds.com
Help experts!!!: SEMAPHORE question <Bouty_Bouty@juno.com>
Re: Ho to get started with Tk on Win32? <kbw@negia.net>
leeches, compilers, and perl, oh my (all mine?) <gbartels@xli.com>
Re: leeches, compilers, and perl, oh my (all mine?) <*@qz.to>
More Oraperl pain <jhecker@iago.nac.net>
mySQL books available NOW?? <hotister@hotmail.com>
Re: need an anti-leech script <jeromeo@atrieva.com>
Re: need an anti-leech script (John Stanley)
Re: Need expert scrutiny :) (Kevin Reid)
Re: Open a textfile with a cgi-programm (Larry Rosler)
Re: Perl "constructors" <emschwar@rmi.net>
Re: Perl "constructors" (Andrew Allen)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 25 May 1999 18:15:54 GMT
From: John Porter <jdporter@min.net>
Subject: Re: $var =~ s/string/pattern/i does not work...
Message-Id: <7iepcn$7p4$1@nnrp1.deja.com>
In article <7iem39$50n$1@nnrp1.deja.com>,
lpacania@my-dejanews.com wrote:
> $line =~ $rule; <------- this does not work...
>
> I step through the debugger and PERL picks up the rule and the line
> fine but does not do anything with the $line =~ $rule. I remember
when
> I used to code in awk you had to enclose strings that were to be
> interpreted as commands some way. Is this the same for perl?
eval:
perldoc -f eval.
--
John Porter
Put it on a plate, son. You'll enjoy it more.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 25 May 1999 18:46:49 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: $var =~ s/string/pattern/i does not work...
Message-Id: <7ier6p$s5r$1@info2.uah.edu>
In article <7iem39$50n$1@nnrp1.deja.com>,
lpacania@my-dejanews.com writes:
: I've got my substitution patterns in a seperate file, I read that file
: as an input file.
:
: $rule = <RULEFILE>;
: $line = <INFILE>;
:
: while ($rule ne"") {
: while ($line ne "");
: $line =~ $rule; <------- this does not work...
: print ($line);
: print OUTFILE ($line);
: $line = <INFILE>;
: }
:
: RULEFILE CONTENTS: (1,000 rules)
: s/auto(?!motive)/automotive/i
: s/dlr/dealers/i
The problem with your code is that you have Perl code that you want perl
to evaluate, but you aren't telling perl to evaluate that Perl code!
Here's a naive version:
my @rules = <RULEFILE>; # assuming you've already opened it
while (<INFILE>) {
foreach my $rule (@rules) {
eval $rule;
}
print;
print OUTFILE;
}
This code will probably run pretty slowly (especially if you have a
lot of rules) because you have to recompile all the substitutions
for each line in the input.
It would probably be better to compile them just once:
#! /usr/bin/perl -w
use strict;
my $rules = "rules";
open RULES, $rules or die "$0: failed open $rules: $!\n";
my $input = "input";
open IN, $input or die "$0: failed open $input: $!\n";
my $output = "output";
open OUT, ">$output" or die "$0: failed open >$output: $!\n";
my @rules;
while (<RULES>) {
my $code = eval "sub { \$_[0] =~ $_ }";
die "$0: $rules:$.: bad rule: $@\n" if $@;
push @rules, $code;
}
while (<IN>) {
foreach my $rule (@rules) {
$rule->($_);
}
print;
print OUT;
}
I say probably because for few lines of input and few rules, it's likely
that you won't notice the difference in execution times.
Hope this helps,
Greg
--
Fenster: Treat me like a criminal, I'll end up a criminal.
Hockney: You are a criminal.
Fenster: Why you gotta go and do that? I'm trying to make a point.
------------------------------
Date: 25 May 1999 11:35:10 -0700
From: danielp@best.com (Daniel Parish)
Subject: ...SOLVED, but questions (LONG)
Message-Id: <7ieqgu$1ni$1@shell13.ba.best.com>
Thanks for the response Steven. Your suggestion has provided the
needed solution, albeit after a bit of fumbling on my part. The
following are the details of what I am attempting to do, followed
by a question.
In this simplified example, I am reading a large number of files
that look like this:
### File contents: nk2.2-1.04-A-PAW.rofit ###
RO-01-1832#000 0.76593
RO-01-2939#000 2.14072
### File contents: nk2.2-1.04-RA-A-PAW.rofit ###
RO-01-2102#000 0.892761
RO-01-2939#000 1.31886
and wish to output a tab-delimited row for each RO# containing the
values, if they exist, contained in each of the files above.
RO# nk2.2-1.04-A nk2.2-1.04-RA-A
RO-01-1832/000 0.76593
RO-01-2102/000 0.892761
RO-01-2939/000 2.14072 1.31886
My original script was:
#!/usr/sbin/perl -w
use strict;
use diagnostics;
my ($i, $ro, $fitvalue, $lookup );
my @filelist = qw( nk2.2-1.04-A nk2.2-1.04-RA-A );
foreach $i (@filelist) {
open (FITFILE, "$i-PAW.rofit") ||
die "Could not open file $i-PAW.rofit; $!";
while ( <FITFILE> ) {
chomp $_;
($ro, $fitvalue) = split(" ", $_);
$$i{$ro} = $fitvalue; <== XXX
}
close FITFILE;
}
open (INFILE, "testing" ) ||
die "could not open file testing $!";
### Print headers
print "RO#";
foreach $i (@filelist) {
print "\t$i";
}
print "\n";
### Print body
while ( <INFILE> ) {
chomp $_;
$lookup = $_;
$lookup =~ s:/:\#:g;
print "$_";
foreach $i (@filelist) {
print "\t$$i{$lookup}"
if exists($$i{$lookup});
}
print "\n";
}
It does what it is supposed to, but gives the dreaded 'Can't use
string ("nk2.2-1.04-A") as a HASH ref while "strict refs" in use ' on
line XXX. Without 'strict refs' it works without warnings.
The corrected script (ala Steven), which works without error is:
#!/usr/sbin/perl -w
use strict;
use diagnostics;
my ($i, $ro, $fitvalue, $lookup );
my %all_files = ();
my @filelist = qw( nk2.2-1.04-A nk2.2-1.04-RA-A );
### Stuff data
foreach my $i (@filelist) {
my %file_contents = ();
$all_files{$i} = \%file_contents;
open (FITFILE, "$i-PAW.rofit") ||
die "Could not open file $i-PAW.rofit; $!";
while ( <FITFILE> ) {
chomp $_;
($ro, $fitvalue) = split(" ", $_);
$file_contents{$ro} = $fitvalue;
}
close FITFILE;
}
open (INFILE, "testing" ) ||
die "Could not open file testing; $!";
### Print headers
print "RO#";
foreach my $i (@filelist) {
print "\t$i";
}
print "\n";
### Print body
while ( <INFILE> ) {
chomp $_;
$lookup = $_;
$lookup =~ s:/:\#:g;
print "$_";
foreach my $i ( @filelist ) {
print "\t$all_files{$i}{$lookup}"
if exists($all_files{$i}{$lookup});
}
print "\n";
}
Question: What are the potential pitfalls of using symbolic references
to hashes?
In my opinion the original script is easier to read and does
what it is supposed to in a logical manner, while the 'corrected' script
seems to add an unneccessary level of convolution just for the sake of
formalism. Am I missing something obvious here?
Thanks again,
Daniel
<danielp@best.com>
------------------------------
Date: Tue, 25 May 1999 10:55:35 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: anyone knows if theres any bug with my code?
Message-Id: <MPG.11b483eea81c0eb1989aed@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7ie737$pek$1@nnrp1.deja.com> on Tue, 25 May 1999 13:03:35
GMT, smnayeem@my-dejanews.com <smnayeem@my-dejanews.com> says...
> i am trying to implement the lcs (longest common subsequence) algorithm
> using perl, but perl seems to be acting strangely in some cases. If
> anyone can let me know if theres anything i might have overlooked.
There are many things you overlooked, the most important of which are
not using the '-w' flag and not using 'use strict;', each of which would
have revealed serveral serious errors.
> heres my code :
>
> # usage lcs \@A, \@B
> # returns the count of matched operators.
> # this function compares two strings and returns the resultant sequence
> # match
> sub lcs {
> local ($A, $B) = @_; #$A and $B are the two arrays to be compared.
You should use 'my' almost always instead of 'local'.
> my $i, $j, @X, @Y;
The list of variables for 'my' must be enclosed in parentheses.
> my $m = $#$A; $n = $#$B;
my ($m, $n) = ($#$A, $#$B);
> for ($i = $m; $i >= 0; $i--) {
> for ($j = $n; $j >= 0; $j--) {
> if ($$A[$i+1] eq $$B[$j+1])
The line above accesses elements that are one past the end of the
arrays. '-w' would have told you this.
> {$X[$j] = 1 + $Y[$j+1];}
> else
> {$X[$j] = max($Y[$j],$X[$j+1]);}
> }
> @Y = @X;
> }
> return $X[0];
> }
>
> # returns the maximum of two values.
> sub max {
> return $_[0] ge $_[1] ? $_[0] : $_[1];
> }
The huge error is in the line above. You are comparing numbers as if
they were strings. Use '>=' instead of 'ge'.
> # this function takes in two arrays of strings and returns a percentage
> # (1-100)
> # representing the difference between the two strings.
> sub percent {
> local ($A, $B) = @_;
Use 'my'.
> $lenA = $#$A+1;
$lenA = @$A;
> $lenCommon = lcs(\@A, \@B);
This refers to the global variables @A and @B, not to the arguments to
the subroutine.
$lenCommon = lcs($A, $B);
> print $lenCommon,"\n";
> return (1-($lenCommon/$lenA))*100
> }
>
> ##### BEGIN #####
> @A = split(//," this file isnt working nicely 21/06/1999");
> @B= split(//,"this file isnt working nicely 21/06/1999");
> $percent = percent(\@A, \@B);
> print $percent;
> # this will print the percentage of difference between the two files.
>
> if you try to remove the leading space from the @A array and make some
> modification further into the program it gives a more accurate output.
> by the way heres the link i got the algorithm from :
> http://www.ics.uci.edu/~eppstein/161/960229.html
>
> please let me know if possible, where i might have gone wrong thanks :)
I haven't looked into the algorithm, or why you start out accessing past
the ends of the arrays. But what you have above should let you proceed
further.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 25 May 1999 11:48:59 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Baffled by regexp behaviour
Message-Id: <374AF09B.2C2474AB@mail.cor.epa.gov>
simon@whitestar99.demon.co.uk wrote:
>
> Hi,
>
> I have some text from a file which is slurped into string and I am
> trying to remove some lines off the end. Now I have got a solution but
> I am unsure as to why the first idea failed.
>
> Take the following where I want to lose everything after and including
> the last occurence of 'SIMON':
>
> $string = 'aaaaaaSIMONbbbbbbSIMONccccccc';
> $string =~ s/SIMON.*?$//;
>
> After this $string is 'aaaaaa', not what I want so I have resorted to
> doing:
>
> $string =~ s/(.*)SIMON.*?$/$1/;
>
> Which gives 'aaaaaaSIMONbbbbbb' which is what I want.
>
> I can't understand why the first example didn't choose the 2nd of the
> two possible matches as then the '.*?' has matched as little as
> possible.
It's because regexen match *leftmost* first, then get greedy
(if you ask them to). The first regex essentially does this:
[1] finds the first occurrence of 'SIMON'
[2] then checks to see if the rest of the regex can be matched
If [2] occurs, as it does here, then the regex is done.
Otherwise, it moves on down the string and tries again.
Your second regex works because the (.*) is greedy and matches
absolutely everything, then backtracks to the last occurrence
of 'SIMON' where it can be greedy while still allowing the
rest of the regex to match something.
> Or am I just being stupid!?
No, just inexperienced. Regexes require experimenting with
until you grok their behoavior.
And you might want to consider using a non-regex approach
here. If you really have a fixed value and you want the
last occurrence of it in your string, you probably want to
use rindex() to find the location, and substr() to cut
the rest of the string out.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 25 May 1999 11:21:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Baffled by regexp behaviour
Message-Id: <MPG.11b48a037e2d3f88989aef@nntp.hpl.hp.com>
In article <slrn7klh6a.ljm.sholden@pgrad.cs.usyd.edu.au> on 25 May 1999
15:42:02 GMT, Sam Holden <sholden@pgrad.cs.usyd.edu.au> says...
> On Tue, 25 May 1999 15:16:06 GMT, simon@whitestar99.demon.co.uk wrote:
...
> >$string = 'aaaaaaSIMONbbbbbbSIMONccccccc';
> >$string =~ s/SIMON.*?$//;
> >
> >After this $string is 'aaaaaa', not what I want so I have resorted to
> >doing:
> >
> >$string =~ s/(.*)SIMON.*?$/$1/;
> >
> >Which gives 'aaaaaaSIMONbbbbbb' which is what I want.
...
> If SIMON is always a literal string with no regex meta characters then you
> could use rindex() to find the string and substr() to chop off the end
> of the string...
If you are looking for a string with regex metacharacters, then you
could use negative look-ahead:
$string = 'aaaaaaSIMPLEbbbbbbSIMONccccccc';
$string =~ s/SI[A-Z]+(?!.*SI[A-Z]+).*//;
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 25 May 1999 11:38:48 -0700
From: danielp@best.com (Daniel Parish)
Subject: Re: Can't use string as a hash ref...
Message-Id: <7ieqno$2o6$1@shell13.ba.best.com>
Thanks for the response Ala, but I was unable to get your suggestion
to work. If you are interested in how it was solved, please see my
response to Steven.
Daniel
<danielp@best.com>
In article <x3yiu9m1n0n.fsf@tigre.matrox.com>,
Ala Qumsieh <aqumsieh@matrox.com> wrote:
>
>danielp@best.com (Daniel Parish) writes:
>
>> 'Can't use string ("nk2.2-1.17-RA") as a HASH ref while
>> "strict refs" in use at test.pl line 16, <FITFILE> chunk 1.'
>
>> $$i{$ro} = $fitvalue;
>
>From the piece of code you showed, the only advice I can give is to
>replace the above line with:
>
> ${$i{$ro}} = $fitvalue;
>
>You had a priblem with precedence.
>
>HTH,
>Ala
>
------------------------------
Date: 25 May 1999 18:30:08 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Changing <STDIN>
Message-Id: <7ieq7g$rs9$1@info2.uah.edu>
In article <7ieo20$se3$1@murrow.corp.sgi.com>,
davewal@echo.corp.sgi.com (David Walford) writes:
: When executing a script from a unix shell a line like;
: chomp ($dir = <STDIN>);
: will suspend the script and allow me to enter variables into the
: script from the command line.
:
: Could someone give me an example or point me in the right direction to
: redirect the <STDIN> to another input.
This is a function of your shell. For example:
[13:23] ettsn% cat try
#! /usr/bin/perl -w
use strict;
my $input;
while ( defined($input = <STDIN>) ) {
chomp $input;
print "I got: `$input'\n";
}
[13:23] ettsn% ./try <try
I got: `#! /usr/bin/perl -w'
I got: `'
I got: `use strict;'
I got: `'
I got: `my $input;'
I got: `while ( defined($input = <STDIN>) ) {'
I got: ` chomp $input;'
I got: `'
I got: ` print "I got: `$input'\n";'
I got: `}'
My shell happens to be tcsh. Yours may be another. Consult your
shell's documentation and look for redirection.
: For instance, after a script goes into a while
: loop, could I enter variables into it from over the network or from a
: webpage without re-executing the script?
Oh, sure:
[13:23] ettsn% GET http://www.w3c.org/ | ./try
I got: `<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"'
I got: ` "http://www.w3.org/TR/REC-html40/loose.dtd">'
I got: `<html>'
I got: `<head>'
I got: `<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'
I got: `<meta http-equiv="PICS-Label" content='(PICS-1.1 '
I got: `"http://www.classify.org/safesurf/" l gen true for "http://www.w3.org" by'
I got: `"philipd@w3.org" r (SS~~000 1 SS~~100 1))'>'
I got: `<meta http-equiv="PICS-Label" content='(PICS-1.1 '
I got: `"http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North'
[...]
GET is part of the LWP distribution (available on the CPAN).
Hope this helps,
Greg
--
Because you can't just make shit up and expect the computer to magically
know what you mean, Retardo!
-- mjd
------------------------------
Date: Tue, 25 May 1999 15:31:02 -0400
From: "JD Elliott" <jd.elliott@fmr.com>
Subject: CodeMagic or Pete aka David Grove
Message-Id: <mRC23.18$TS6.158@news-srv1.fmr.com>
I'm trying to download CodeMagic so that I can give it a try.
However, the site that contains the program has a LOT of broken
links. I can't even find a way to email the guy that runs it.
Does someone out there know this guy or know where I can
find CodeMagic on another server?
Is Pete aka David Grove out there somewhere?
Any clues would be appreciated.
Thanks, JD Elliott [jd.elliott@fmr.com]
------------------------------
Date: Tue, 25 May 1999 19:24:19 GMT
From: bshair@unixmail.cmi.itds.com
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <7ietcv$av5$1@nnrp1.deja.com>
In article <373bb442@cs.colorado.edu>,
perlfaq-suggestions@perl.com (Tom and Gnat) wrote:
> Does Perl have a year 2000 problem? Is Perl Y2K compliant?
>
> Short answer: No, Perl does not have a Year 2000 problem. Yes, Perl
> is Y2K compliant (whatever that means). The programmers you've
> hired to use it, however, probably are not.
>
> Long answer: The question belies a true understanding of the issue.
> Perl is just as Y2K compliant as your pencil--no more, and no less.
> Can you use your pencil to write a non-Y2K-compliant memo? Of
> course you can. Is that the pencil's fault? Of course it isn't.
>
Tom, your posting from the FAQ is, of course, entirely true.
I hope it doesn't mislead people into thinking that Perl programs
aren't likely to have Y2K problems.
I've worked for many years in the IBM mainframe environment, where
there's (of course) a useful acronym to describe such mistakes at
struct tm
Broken As Designed (BAD)
The problem has nothing to do with Perl, except insofar as Perl
uses the Unix standard struct tm (what else would it use?),
which is non-intuitive in the form of the year value it returns.
Since in Perl one need not cast the value from int to char before
printing it, the problem is perhaps even more likely to occur in
Perl programs than in C. It is, of course, a programming error,
rather than a language problem, and one which I've already seen
arise in real-world programs at at client's site.
(Sorry if you don't like my newsreader...)
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 25 May 1999 14:38:13 -0400
From: Jermaine Martin <Bouty_Bouty@juno.com>
Subject: Help experts!!!: SEMAPHORE question
Message-Id: <374AEE15.7E94EC19@juno.com>
What is the correct combination for the semaphore option?:
One process constantly runs and writes shared memory. It needs to lock
the semaphore and then release it. It should always be able to control
the semaphore state.
The second process only reads and can only do so when the semaphore is
not locked.
No need to specify the whole command, just the semaphore option before
and after will do... Thanks!!!
------------------------------
Date: Tue, 25 May 1999 15:35:18 -0400
From: Kevin Weinrich <kbw@negia.net>
Subject: Re: Ho to get started with Tk on Win32?
Message-Id: <374AFB75.FDA4FEB2@negia.net>
Try this (for a braindead example that will show you if you have things
installed properly):
======= ex1_1a.pl =========
#!/usr/bin/perl -w
#
use strict;
use Tk;
my $main = new MainWindow;
$main->Label(-text => 'Print file')->pack;
my $filename = $main->Entry(-width => 10);
$filename->pack;
MainLoop;
====================
Then run: perl ex1_1a.pl
Leon wrote:
> Hi,
>
> Can anyone point me to any examples of how to get started with Tk?
>
> I have all of the modules, but there don't seem to be any demo programs
> to try. Also, do I need to install any more software to get Tk to make
> windows Apps? Will a simple "hello world" type of program written in
> Perl using Tk fire up a Windows window?
>
> many thanks,
>
> Leon.
>
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 25 May 1999 14:17:44 -0400
From: Greg Bartels <gbartels@xli.com>
Subject: leeches, compilers, and perl, oh my (all mine?)
Message-Id: <374AE948.36C5EE05@xli.com>
there's a thread on this group with the subject:
"need an anti-leech script"
the gist of it being a guy has a website with
publicly accessible images, and other sites are
linking to his images, slowing down his server
as the other sites use his hardware.
There's another thread on this group with the subject:
"Perl compiler.. if or when"
the gist of that was a guy who wanted to compile
his software as a means to protect his perl script.
Both threads have been going on for some time now,
and everyone is dancing around the same issue.
the issue is "how do I protect what is mine?"
actually, its even more basic than that. the
arguments all dance around the definition of
"mine".
if anyone can point me to a good website
that answers the questions around open source,
copyrights, proprietary software, intellectual
property, etc, in a clear succinct manner,
these threads could end, simply by referring
to that URL.
lacking that, here's my take on it:
----
1) you cannot own knowledge.
you cannot copyright ohms law and license the
equation. you cannot patent the pythagorean
theorem, you cannot own knowledge.
2) you can patent a specific physical device
that didn't exist before. while you can't patent
ohm's law, you can invent a new type of computer
using ohms law and patent that design.
3) you can copyright a specific expression of
knowledge. a particular sequence of words
can create a story, a poem, or a computer program.
specific images in sequency can form a movie.
----
these 3 points approximate the current
paradigm we live in today. the reason there
are divisions is because of the levels
of "natural enforcement".
patent laws, for the most part, enforce themselves.
we do not go around building a copy of a
Toyota Tercel because its just too much work.
If someone were to invent a Star Trek
style replicator, then patent laws would
be going through the same upheaval that
copyright laws are going through now.
centuries ago, knowledge itself was owned,
and held within the control of a chosen few.
this didn't change until the printing press
made knowledge in the form of books easily
distributed.
Copyright laws have been going through
shifts lately as technology makes
"soft" copies easier and easier to do.
I support the open source movement. I've
contributed source code to CPAN which
is given away.
the reason I was looking for that web page
that gives a clear argument for open source
is that we are in the paradigm I described
above. namely, that people can copyright software.
and if we want that to change, we've
got to tell other people what we want the
new paradigm to look like.
if someone comes here asking for a compiler
to protect his code, and you blow him off,
you will achieve nothing. or it could even
worsen the divide between "open-sources" and
"copyrighters"
here's an open source paradigm:
__start_paradigm__
The advent of inexpensive and widespread
computers and internet connections is bringing
the notion of software copyright to an end.
Global internet connectivity brings together
a wealth of individuals willing apply their
knowledge to developing programs that others
can use. This knowledge will accumlate over
time, as demonstrated by the expansion of
the CPAN modules. being open-source, these
programs can evolve and adapt to meet the
changes of computer hardware.
At some point in the not too distant future,
many of the most popular software applications
will be available as open-source, operating
systems, GUI interfaces, text-editors, word
processors, filing systems, databases, mail tools,
internet browsers. In fact, most are already
available, but may simply not yet be up to
the level of sophistication of commercial
applications.
The open-source paradigm is a fact, it is
happening now. Software companies will
have to eventually alter their notion of
software or go out of business. The market
will become one where the only place left
for commercial software companies is in
areas so specific or transient that no one
has gotten around to writing some open-source
code for it yet.
This isn't a judgement of what's happening,
rather a matter of describing what's happening.
As more people get computers and get connected,
and as more open-source code accumulates, it
is difficult to imagin that in fifty years,
there will not be any software that you need
that isn't available as open source. The body
of open-source contributers, over time, will
rival that of any currently existing software
company.
as this transistion occurs, you can still get
your copyrights, you can still license your
software, and the courts will support you,
and no one will try and stop you.
but be advised, its only a matter of time
before the concept of software companies as
they exist today will become simply a lesson
in history.
__end_paradigm__
Greg
------------------------------
Date: 25 May 1999 19:29:12 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: leeches, compilers, and perl, oh my (all mine?)
Message-Id: <eli$9905251522@qz.little-neck.ny.us>
In comp.lang.perl.misc, Greg Bartels <gbartels@xli.com> wrote:
> there's a thread on this group with the subject:
> "need an anti-leech script"
>
> the gist of it being a guy has a website with
> publicly accessible images, and other sites are
> linking to his images, slowing down his server
> as the other sites use his hardware.
>
>
> There's another thread on this group with the subject:
> "Perl compiler.. if or when"
>
> the gist of that was a guy who wanted to compile
> his software as a means to protect his perl script.
>
>
> Both threads have been going on for some time now,
> and everyone is dancing around the same issue.
> the issue is "how do I protect what is mine?"
Yes, but unless I skimmed the 'anti-leech' one too
fast, the 'what is mine' thing there was bandwidth, while
the other was intellectual property and one of those
has a much higher per-unit cost than the other.
It is quite easy to restrict access to images to only
people who have visited some previous page on a site
first. I would argue that it is reasonable for the
administrator of a web site to configure the server
to serve things underwhat ever conditions the
administrator wants. Similarlly I am free to not use
said server if I do not agree to the conditions (eg,
I have so far refused to register with the New York
Times to see their online edition).
Elijah
------
if you have some source of free bandwidth, please tell me
------------------------------
Date: Tue, 25 May 1999 19:08:11 GMT
From: Jared Hecker <jhecker@iago.nac.net>
Subject: More Oraperl pain
Message-Id: <vyC23.28$m4.259@nntp1>
Hi, all -
Given the following snippet of code, I expected to retrieve all records
(up to 8 ) in the 'instance_name' and 'password' fields of the table
'sid'. Instead, all I get back is the first record. Can anyone point me
to what I am doing wrong?
#################
eval 'use Oraperl; 1' ||die $@ if $] >= 5;
$ENV{TWO_TASK} = 'EMAN';
$lda = &ora_login('EMAN','username','password');
$csr2 = &ora_open($lda,'select instance_name from sid',8);
@sid = &ora_fetch($csr2);
&ora_close($csr2);
$csr = &ora_open($lda,'select password from sid',8);
@pw = &ora_fetch($csr);
&ora_close($csr);
&ora_logoff($lda);
##################
TIA -
Regards,
jh
--
Jared Hecker | HWA Inc. - Oracle architecture and Administration
jared@hwai.com | ** serving NYC and New Jersey **
------------------------------
Date: Tue, 25 May 1999 14:03:36 -0500
From: "Thom Lee" <hotister@hotmail.com>
Subject: mySQL books available NOW??
Message-Id: <7ierth$nf$1@jetsam.uits.indiana.edu>
Hi, after searching on the web and the local bookstore, I only found that
O'Reilly will publish a mySQL book called:
Mysql And Msql
by Yarger, Randy Jay (Joint Author: King, Tim Joint Author: Reese, George)
but it won't be available until this Fall (August or so).. is there any
other mySQL books available NOW or will be out in a couple of weeks? I found
the mysql.com and other online websites only provide some "piece by piece"
information and I guess I need to get a better "whole picture" from a book
or a specialized website.. is there such a thing right now? Thanks!
if possible, could you please also cc me a email of your reply? Many thanks!
------------------------------
Date: Tue, 25 May 1999 11:40:31 -0700
From: Jerome O'Neil <jeromeo@atrieva.com>
Subject: Re: need an anti-leech script
Message-Id: <374AEE9F.E0C05629@atrieva.com>
Tom Christiansen wrote:
> In comp.lang.perl.misc,
> John Porter <jdporter@min.net> writes:
> :> I don't believe in the whole "stealing" notion.
> :Tom, you're starting to make me think you don't believe in
> :intellectual property. :-)
>
> No, I'm referring uniquely to the situation of people clicking
> on your public web pages. If you didn't want them to do that,
> you wouldn't make it public. Since you have, you can't complain
> when the web extends strands in your direction.
If one were to use, say, an image of a camel off of some publisher's web
site, you wouldn't have a problem with that?
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
Date: 25 May 1999 19:39:43 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: need an anti-leech script
Message-Id: <7ieu9v$j7v$1@news.NERO.NET>
In article <374ae319@cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
> [courtesy cc of this posting mailed to cited author]
>
>In comp.lang.perl.misc,
> John Porter <jdporter@min.net> writes:
>:> I don't believe in the whole "stealing" notion.
>:Tom, you're starting to make me think you don't believe in
>:intellectual property. :-)
>
>No, I'm referring uniquely to the situation of people clicking
>on your public web pages.
Unfortunately, the person who started this thread wasn't.
There is a difference between people clicking on your web pages, and
other people's web pages loading your graphics from your system when
someone clicks on them.
------------------------------
Date: Tue, 25 May 1999 15:24:18 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Need expert scrutiny :)
Message-Id: <1dsbhix.vavcnxepxbiN@[192.168.0.1]>
Tad McClellan <tadmc@metronet.com> wrote:
> 1 while s/(.*?href.*?)($re)/$1$subst{$2}/i;
Question: why doesn't adding /o make this run faster?
#!/usr/bin/perl -w
use strict;
my %subst = (
'?' => 'uuu',
'=' => 'vvv',
'%' => 'xxx'
);
my $re = join '|', map $_=quotemeta($_), keys %subst;
$_ = "hehehehe%=?<HREF=\"http:agni.com?idunno=nothing%and=none\">";
use Benchmark;
timethese(10000, {
'once' => sub {
$_ = "hehehehe%=?<HREF=\"http:agni.com?idunno=nothing%and=none\">";
1 while s/(.*?href.*?)($re)/$1$subst{$2}/io;
},
'orig' => sub {
$_ = "hehehehe%=?<HREF=\"http:agni.com?idunno=nothing%and=none\">";
1 while s/(.*?href.*?)($re)/$1$subst{$2}/i;
},
});
print "$_\n";
__END__
Benchmark: timing 10000 iterations of once, orig...
once: 6 secs ( 6.28 usr 0.00 sys = 6.28 cpu)
orig: 6 secs ( 5.90 usr 0.00 sys = 5.90 cpu)
hehehehe%=?<HREF="http:agni.com?idunno=nothing%and=none">
Benchmark: timing 10000 iterations of once, orig...
once: 6 secs ( 5.77 usr 0.00 sys = 5.77 cpu)
orig: 6 secs ( 5.87 usr 0.00 sys = 5.87 cpu)
hehehehe%=?<HREF="http:agni.com?idunno=nothing%and=none">
Benchmark: timing 10000 iterations of once, orig...
once: 6 secs ( 5.68 usr 0.00 sys = 5.68 cpu)
orig: 6 secs ( 5.88 usr 0.00 sys = 5.88 cpu)
hehehehe%=?<HREF="http:agni.com?idunno=nothing%and=none">
--
Kevin Reid: | Macintosh:
"I'm me." | Think different.
------------------------------
Date: Tue, 25 May 1999 12:31:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Open a textfile with a cgi-programm
Message-Id: <MPG.11b49a7925315142989af0@nntp.hpl.hp.com>
In article <374ACD4F.ECA54343@atrieva.com> on Tue, 25 May 1999 09:18:23
-0700, Jerome O'Neil <jeromeo@atrieva.com> says...
> Hans Bolte wrote:
> > why does the following code in my cgi-programm not open the textfile
> > "statistik.dat"?
> >
> > open(DAT, "<statistik.dat") || print "Error: Could not open
> > statistik.dat\n";
>
> Because you aren't asking perl to tell you. Check the $! variable for
> the answer.
Yes. And it will probably say "no such file or directory". As has been
posted several times this morning alone (!), there is no assurance that
your concept of the current directory and the web server's concept of
the current directory are the same. It's imperative to use an absolute
pathname, or to chdir to an absolutely-named directory and go relative
from there.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 25 May 1999 12:23:51 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Perl "constructors"
Message-Id: <xkf4sl1gg94.fsf@valdemar.col.hp.com>
John Porter <jdporter@min.net> writes:
> This is the difference between *catching* an exception and
> *dealing with* an exception. eval catches everything. dealing with
> whatever eval caught is up to the programmer.
But eval is supposed to be analogous to "try", isn't it? It makes more
sense if you look at it as
try {...}
catch (Exception e) {}
But that's not too helpful for real exception handling. At least Perl
lets you continue to use that Exception object (okay, $@) after the
try/catch block is over, which most other exception-handling languages
don't.
Yes, I understand that eval/die is not really analogous to try/catch;
this was kinda my whole point-- that they're okay for approximating
exception handling, but they're not a substitute for the real thing.
They're as close as Perl lets you get, though.
> One of things you might do is re-throw (i.e. propagate), but this
> does not happen automatically.
Right; because a die isn't really an exception (or eval isn't really
try, take your pick); it's just a reasonably close first approximation of
one.
-=Eric
------------------------------
Date: 25 May 1999 19:19:25 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Perl "constructors"
Message-Id: <7iet3t$3c5$1@fcnews.fc.hp.com>
Eric The Read (emschwar@rmi.net) wrote:
: But eval is supposed to be analogous to "try", isn't it? It makes more
: sense if you look at it as
: try {...}
: catch (Exception e) {}
: But that's not too helpful for real exception handling. At least Perl
: lets you continue to use that Exception object (okay, $@) after the
: try/catch block is over, which most other exception-handling languages
: don't.
: Yes, I understand that eval/die is not really analogous to try/catch;
: this was kinda my whole point-- that they're okay for approximating
: exception handling, but they're not a substitute for the real thing.
: They're as close as Perl lets you get, though.
But perl's benefit is its flexibility (or is its flexibility its
benefit?) If we take the code from perlsub, we can make one simple
change to make it auto-rethrow if the catch phrase returns false:
sub try (&@) {
my($try,$catch) = @_;
eval { &$try };
if ($@) {
local $_ = $@;
die $@ unless &$catch; # CHANGED FROM: &$catch
}
}
sub catch (&) { $_[0] }
try {
die "phooey";
} catch {
/phooey/ and (print "unphooey\n"),return 1; # ADDED return 1;
};
The great thing about this is you can at run-time determine whether
you're going to handle the exception, instead of relying on some
cumbersome class hierarchy.
: > One of things you might do is re-throw (i.e. propagate), but this
: > does not happen automatically.
It's as automatic as you make it ;)
: Right; because a die isn't really an exception (or eval isn't really
: try, take your pick); it's just a reasonably close first approximation of
: one.
Exactly. But "try" can be a creature of your own creation, instead of
the built-in "eval".
Andrew
------------------------------
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 5777
**************************************