[18592] in Perl-Users-Digest
Perl-Users Digest, Issue: 760 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 25 09:05:31 2001
Date: Wed, 25 Apr 2001 06:05:09 -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: <988203908-v10-i760@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 25 Apr 2001 Volume: 10 Number: 760
Today's topics:
Counting number of chars in a line (part of reading mul ("Richard Lawrence")
Re: Counting number of chars in a line (part of reading (Martien Verbruggen)
DBM data stores <ericm@iol.ie>
Re: DBM data stores <eric@urbanrage.com>
developers? <dean@housefloors.co.uk>
Re: developers? (Tad McClellan)
How do I find the OS? <stumo@bigfoot.com>
Re: How do I find the OS? (Anno Siegel)
How to copy an entire directory <me@mikehogan.net>
Re: How to copy an entire directory <Laszlo.G.Szijarto@grc.nasa.gov>
Re: idiotic behaviour of the symboltable ( how to call nobull@mail.com
Re: idiotic behaviour of the symboltable ( how to call <bart.lateur@skynet.be>
Re: locale <dean@housefloors.co.uk>
looking for suggestions on record compression (James Weisberg)
Re: Lvalue (Tad McClellan)
perl variables problem (Sylvain Thevoz)
Re: perl variables problem <bop@mypad.com>
Re: perl variables problem <bop@mypad.com>
Re: perl variables problem <Laszlo.G.Szijarto@grc.nasa.gov>
Re: perl variables problem (Tad McClellan)
Re: perl variables problem (Anno Siegel)
Re: So what do YOU use Perl for? (Harri Haataja)
Re: use Filter::decrypt; How to encrypt source code fi (Anno Siegel)
user info <Koit Tomingas@mail.ee>
Re: user info (Martien Verbruggen)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 25 Apr 2001 11:21:30 +0000 (UTC)
From: ralawrence@my-deja.com ("Richard Lawrence")
Subject: Counting number of chars in a line (part of reading multiline CSV
Message-Id: <200104251121.EAA13062@mail6.bigmailbox.com>
Hi all,
I'm trying to read in and parse CSV files. I've used the solution suggested in the cookbook and it works well, apart from the fact that \n's in the fields cause the whole thing to break horribly.
So I figured that if I could count the number of "'s in the line (ignoring the ""'s) then I could work out whether or not the line below needed to be concatenated with the current line.
So I came up with this:
$string = 0;
while ($string =~ /"[^"]/g) { $count++ };
which works pretty well, except that 'hello""there' incorrectly returns 1 because although it ignores the first ", it counts the second.
so I changed it to this:
$count = 0;
while ($string =~ /[^"]"[^"]/g) { $count++ };
which now returns 'hello""there' correctly as 0, but unfortunately also incorrectly returns 0 for 'hello"""there' (this should be 1).
I'm stumped, can anyone suggest a regexp that will allow me to count the "'s in $string whilst ignoring any ""'s.
Alternativily, can anyone suggest a better way of handling CSV files with \n's in the fields?
Many thanks
Rich
------------------------------------------------------------
--== Sent via Deja.com ==--
http://www.deja.com/
--
Posted from [158.234.54.250] by way of mail6.bigmailbox.com [209.132.220.37]
via Mailgate.ORG Server - http://www.Mailgate.ORG
------------------------------
Date: Wed, 25 Apr 2001 22:14:43 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Counting number of chars in a line (part of reading multiline CSV
Message-Id: <slrn9edftj.hu4.mgjv@martien.heliotrope.home>
[Please, in the future, wrap your lines at less than 80 characters.]
On Wed, 25 Apr 2001 11:21:30 +0000 (UTC),
Richard Lawrence <ralawrence@my-deja.com> wrote:
> Hi all,
>
> I'm trying to read in and parse CSV files. I've used the solution
> suggested in the cookbook and it works well, apart from the fact that
> \n's in the fields cause the whole thing to break horribly.
The CSV format doesn't allow newlines in its fields. It's a
line-oriented format.
> So I figured that if I could count the number of "'s in the line
> (ignoring the ""'s) then I could work out whether or not the line
> below needed to be concatenated with the current line.
That means that now you are no longer working with CSV files, but with a
different format. I suggest changing the newlines to something else
before trying to parse the line. I'd also use a module, but that's just
me..
#!/usr/local/bin/perl -w
use strict;
use Text::CSV_XS;
my $csv = Text::CSV_XS->new();
my $buf = "";
my $nl_marker = "__NEWLINE__";
while (<DATA>)
{
chomp;
$buf .= $_;
my $status = $csv->parse($buf);
if (!$status)
{
$buf .= $nl_marker;
next
}
my @fields = $csv->fields;
s/$nl_marker/\n/g for @fields;
print "Got: [", join(":", @fields), "]\n";
$buf = "";
}
__DATA__
1,2,3,"a field"
3,4,5,"a field
with a newline"
5,"and
a newline
here","and
another one
here",5
If your format allows other newlines than between quotes, you'll have to
also count numbers of fields parsed.
Martien
--
Martien Verbruggen |
Interactive Media Division | The gene pool could use a little
Commercial Dynamics Pty. Ltd. | chlorine.
NSW, Australia |
------------------------------
Date: Wed, 25 Apr 2001 10:24:56 GMT
From: "Eric Mosley" <ericm@iol.ie>
Subject: DBM data stores
Message-Id: <YBxF6.28706$PF4.50092@news.iol.ie>
Hi,
We are looking at using a DBM store for our cgi routines on the web server.
The max amount of data will be about 10,000 name-value pairs.
But what I'm worried about is multiple instances of the perl cgi program all
reading/writing to the same DBM file - is lockin inherently built into the
DBM package or is there a work around?
Thanks for the help!
Eric
------------------------------
Date: Wed, 25 Apr 2001 07:24:45 -0500
From: eric <eric@urbanrage.com>
Subject: Re: DBM data stores
Message-Id: <3AE6C20D.A63CDB32@urbanrage.com>
Eric Mosley wrote:
> Hi,
>
> We are looking at using a DBM store for our cgi routines on the web server.
> The max amount of data will be about 10,000 name-value pairs.
>
> But what I'm worried about is multiple instances of the perl cgi program all
> reading/writing to the same DBM file - is lockin inherently built into the
> DBM package or is there a work around?
>
> Thanks for the help!
>
> Eric
I believe BerkeleyDB which is used with perl module DB_File supports locking.
Eric
------------------------------
Date: Wed, 25 Apr 2001 09:53:36 +0100
From: "Dean Wakerley" <dean@housefloors.co.uk>
Subject: developers?
Message-Id: <9c633v$h22$1@news7.svr.pol.co.uk>
All of the web presence relating to perl appears to be about using perl.
Where can I find information pertaining to the development of perl and
problems relating perl mis-behaving?
------------------------------
Date: Wed, 25 Apr 2001 07:35:06 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: developers?
Message-Id: <slrn9eddja.ubh.tadmc@tadmc26.august.net>
Dean Wakerley <dean@housefloors.co.uk> wrote:
>All of the web presence relating to perl appears to be about using perl.
>
>Where can I find information pertaining to the development of perl and
>problems relating perl mis-behaving?
http://bugs.perl.org/
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 25 Apr 2001 13:54:52 +0100
From: "Stuart Moore" <stumo@bigfoot.com>
Subject: How do I find the OS?
Message-Id: <%NzF6.651$vJ5.135479@news2-win.server.ntlworld.com>
How can I most easily find the OS from within a Perl script?
------------------------------
Date: 25 Apr 2001 13:04:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How do I find the OS?
Message-Id: <9c6i06$q0b$2@mamenchi.zrz.TU-Berlin.DE>
According to Stuart Moore <stumo@bigfoot.com>:
> How can I most easily find the OS from within a Perl script?
$^O. See perldoc perlvar.
Anno
------------------------------
Date: Wed, 25 Apr 2001 11:32:50 GMT
From: "Mike Hogan" <me@mikehogan.net>
Subject: How to copy an entire directory
Message-Id: <CByF6.10029$cF.213498@news1.nokia.com>
Hi,
Can somebody please tell me how to copy an entire directory in a portable
manner?
Many thanks,
Mike.
------------------------------
Date: Wed, 25 Apr 2001 08:15:50 -0400
From: "Laszlo G. Szijarto" <Laszlo.G.Szijarto@grc.nasa.gov>
Subject: Re: How to copy an entire directory
Message-Id: <9c6f55$h6g$1@sulawesi-fi.lerc.nasa.gov>
I think the easiest way -- on a Unix (bash) system would be --
$command = "cp -r [directory] [newdirectoryname]";
system($command);
------------------------------
Date: 25 Apr 2001 12:22:42 +0100
From: nobull@mail.com
Subject: Re: idiotic behaviour of the symboltable ( how to call a subroutine of an EXPLICIT package without an inherited one (from the ISA) ) ????
Message-Id: <u9hezdkyv1.fsf@wcl-l.bham.ac.uk>
"Murat Uenalan" <murat.uenalan@gmx.de> writes:
> I try to implement a code which calls a subroutine 'pre_init' (if it exists)
> for every package in an ISA array. But it is fatal for me if perl calls a
> parent 'pre_init' because its "inherited", i really just want the one of the
> package !!!!!
No problem, inheritance only applies in method call syntax.
> This code-snippet doesn't seem to work,
Looks OK to me. Do you have any evidence that it didn't work?
> because when tracking the symbol-table (at the end) it shows the
> misere -> perl just simply copies subroutine-symbolnames to the ISA
> packages (urghhhh...)
Why do you believe that this namespace pollution side-effect means
that your code did not do what you wanted?
> THAT SEEMS TO DRAG MY LEGS FROM THE GROUND -> HOW TO SOLVE MY
> PROBLEM ?
WHY DO YOU BELIEVE THAT YOU HAVE A PROBLEM?
Sure, it copies the symbol names into the packages. It creates an
emtpy GLOB in the package's symbol table. There's no {CODE} element
defined in that GLOB so this doesn't have any significant impact.
> if( defined *{ $parent.'::pre_init' }{CODE} )
OK a GLOB is not a hash but syntax and the semantics are similar and
what's going on here is accidental autovivification. As I said above
this autovivification is harmless but if you want to avoid it you can
do exactly the same as you would have done in the case of a hash:
if( defined *{ $parent.'::pre_init' } &&
defined *{ $parent.'::pre_init' }{CODE} )
My initial reaction was to try to simplify that to...
if ( defined &{"${parent}::pre_init"} )
...but then I realised that that wouldn't DWIM if pre_init() is an
AUTOLOADed method so then I thought wouldn't it be nice if I could
write...
if ( exists &{"${parent}::pre_init"} )
...and was pleasantly supprised to find this is implemented as of 5.6.
> *{ $parent.'::pre_init' }->( $this, $args );
I'd cut out the explicit mention of the GLOB here too:
"${parent}::pre_init"->( $this, $args );
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 25 Apr 2001 11:59:40 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: idiotic behaviour of the symboltable ( how to call a subroutine of an EXPLICIT package without an inherited one (from the ISA) ) ????
Message-Id: <ekedet0r9blsj6n970dkgonbtg4dqj9ms1@4ax.com>
Murat Uenalan wrote:
>I try to implement a code which calls a subroutine 'pre_init' (if it exists)
>for every package in an ISA array. But it is fatal for me if perl calls a
>parent 'pre_init' because its "inherited", i really just want the one of the
>package !!!!! This code-snippet doesn't seem to work, because when tracking
>the symbol-table (at the end) it shows the misere -> perl just simply copies
>subroutine-symbolnames to the ISA packages (urghhhh...) THAT SEEMS TO DRAG
>MY LEGS FROM THE GROUND -> HOW TO SOLVE MY PROBLEM ?
I'm not sure you've got everything straightened out. Note that a
difference between a class method and a plain func is that inheritance
doesn't come into play when calling as a function. So
Foo::func("Foo", @args); # no inheritance
Foo->func(@args); # inheritance
So you need to call it as a function, not as a class method.
> if( defined *{ $parent.'::pre_init' }{CODE} )
> {
> *{ $parent.'::pre_init' }->( $this, $args );
> }
I think your problem is here. That's not the proper way to chek if a
function exists. You need to check:
if(defined &Foo::func) {
Foo::func('Foo', @args);
}
Adding symbolic referencing is left as an exercise.
p.s. I have no clue if AUTOLOAD might eventually mess this up. My tests
indicate that it won't.
--
Bart.
------------------------------
Date: Wed, 25 Apr 2001 09:25:33 +0100
From: "Dean Wakerley" <dean@housefloors.co.uk>
Subject: Re: locale
Message-Id: <9c61fb$j1e$1@news6.svr.pol.co.uk>
> Perhaps should you recompile Perl. For another way of fixing your
> problem, look at the perllocale manpage, section on "Locale problems".
That's what I thought. I've compile both 5.6.0 & 5.6.1 they both exhibit the
same problem.
I was wondering if there is another library that perl depends upon that
needs upgrading.
------------------------------
Date: Tue, 24 Apr 2001 21:30:14 GMT
From: chadbour@wwa.com (James Weisberg)
Subject: looking for suggestions on record compression
Message-Id: <GfmF6.2551$DW1.122105@iad-read.news.verio.net>
Below I have two cooperating functions which pack/unpack what would normally
be a database record of some variable size. What I'm doing below is packing
each record as a string for storage and then re-assembling it as an array for
retrieval. Generally the values will be small; there are no natural negative
values in my dataset and so I am using -1 as an indicator for a undefined
value in a record field. The one tricky thing I am doing below is storing
the first 4 bytes as a long, which represents a reporting date (YYYYMMDD).
This value is available at the front for quick access and will be used to
determine if the record itself needs to be assembled.
Here is an example from the command line:
-> ./packit.pl 20000301 1 10 100 1000 10000 1000000 -1 -1 -1 99 10
[7] packstr: (c3S2Lc5)
packet is: (20000301,1,10,100,1000,10000,1000000,-1,-1,-1,99,10)
Now, I don't have a problem with either function. Rather, I'm wondering if
there are any suggestions for improving either the speed or the memory usage.
The records themselves contain the instructions for unpacking the actual
field values, but as you can see, dbrec_unpack() needs to call unpack() a
total of three times per record, which is expensive. I'm not very concerned
about the speed of packing records, as that is done rarely, but the data
retrieval should be as fast as possible without hogging too much memory
for potentially several hundred thousand records.
Anyone have suggestions on how these two functions might be improved?
#!/usr/local/bin/perl -w
$"=",";
my $record = dbrec_pack(@ARGV);
my @packet = dbrec_unpack($record);
print "packet is: (@packet)\n";
sub dbrec_pack {
my $ird = shift; # put ird before packing header for quick access
my $packstr;
for (@_) {
$_ = -1 if not defined $_;
if ( $_ < 128 )
{ $packstr .= 'c'}
elsif ( $_ < 65536 )
{ $packstr .= 'S'}
elsif ( $_ < 4294967296)
{ $packstr .= 'L'}
else { print "Field record $_ too large to pack.\n"; exit 1;}
}
$packstr =~ s/(([A-Za-z])\2+)/$2 . length $1/eg;
my $packlen = length($packstr);
print "[$packlen] packstr: ($packstr)\n";
return pack("lCa$packlen$packstr", $ird, $packlen, $packstr, @_);
}
sub dbrec_unpack {
my $packlen=unpack("x4C" , $_[0]); # skip 4 bytes for len
my $packstr=unpack("x5a$packlen" , $_[0]); # skip 5 bytes for str
return unpack("lxx$packlen$packstr", $_[0]); # return ird + rest
}
--
World's Greatest Living Poster
------------------------------
Date: Wed, 25 Apr 2001 07:43:01 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Lvalue
Message-Id: <slrn9ede25.ubh.tadmc@tadmc26.august.net>
Alf Salte <alf.salte@nextra.no.spam.com> wrote:
>Question is, is there any way the function whatever can figure out that it
>is given a variable that can be modified as opposed to a value it can't
>other than attempt it and freak out if it failed?
We discussed that here a couple of months ago (URL wrapped):
http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=
69047406007c843c&seekd=959961344#959961344
>I guess you can define this function in terms of doing an eval() and trap
>the error
That seemed to be the consensus.
>but that appears to me to be a very costly way of checking
>something that should be very quick and easy check so I am hoping there's a
>better way.
We didn't find one...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 25 Apr 2001 11:52:47 GMT
From: sylvain.thevoz@mcnet.ch (Sylvain Thevoz)
Subject: perl variables problem
Message-Id: <3ae6b87f.6743842@news.mcnet.ch>
I have a file which contents:
$a Mr. Smith, how do you do?
I have a perl file which contents:
$a = "good morning";
open(FILE, "file.lst");
while (<FILE>)
{
$out .= $_;
}
print $out;
My problem:
when I execute the perl file, it prints "$a Mr. Smith, how do you do?"
But I want to print "good morning Mr. Smith, how do you do?"
Thank you
Sylvain
------------------------------
Date: Wed, 25 Apr 2001 12:17:58 GMT
From: "flash" <bop@mypad.com>
Subject: Re: perl variables problem
Message-Id: <WfzF6.720086$JT5.19321275@news20.bellglobal.com>
why wouldn't it?
you didnt tell if other wise.
$out =~ s/\$a/$a/g;
that should work.
"Sylvain Thevoz" <sylvain.thevoz@mcnet.ch> wrote in message
news:3ae6b87f.6743842@news.mcnet.ch...
> I have a file which contents:
> $a Mr. Smith, how do you do?
>
> I have a perl file which contents:
> $a = "good morning";
> open(FILE, "file.lst");
> while (<FILE>)
> {
> $out .= $_;
> }
> print $out;
>
> My problem:
> when I execute the perl file, it prints "$a Mr. Smith, how do you do?"
>
> But I want to print "good morning Mr. Smith, how do you do?"
>
> Thank you
> Sylvain
>
>
------------------------------
Date: Wed, 25 Apr 2001 12:18:38 GMT
From: "flash" <bop@mypad.com>
Subject: Re: perl variables problem
Message-Id: <ygzF6.720089$JT5.19321568@news20.bellglobal.com>
opps that should have read
why would it?
"flash" <bop@mypad.com> wrote in message
news:WfzF6.720086$JT5.19321275@news20.bellglobal.com...
> why wouldn't it?
>
> you didnt tell if other wise.
>
> $out =~ s/\$a/$a/g;
>
>
>
> that should work.
>
> "Sylvain Thevoz" <sylvain.thevoz@mcnet.ch> wrote in message
> news:3ae6b87f.6743842@news.mcnet.ch...
> > I have a file which contents:
> > $a Mr. Smith, how do you do?
> >
> > I have a perl file which contents:
> > $a = "good morning";
> > open(FILE, "file.lst");
> > while (<FILE>)
> > {
> > $out .= $_;
> > }
> > print $out;
> >
> > My problem:
> > when I execute the perl file, it prints "$a Mr. Smith, how do you do?"
> >
> > But I want to print "good morning Mr. Smith, how do you do?"
> >
> > Thank you
> > Sylvain
> >
> >
>
>
------------------------------
Date: Wed, 25 Apr 2001 08:12:22 -0400
From: "Laszlo G. Szijarto" <Laszlo.G.Szijarto@grc.nasa.gov>
Subject: Re: perl variables problem
Message-Id: <9c6eum$h4f$1@sulawesi-fi.lerc.nasa.gov>
perl treats the contents of that file as literals -- so, in that context --
the $a is treated like \$a
there's a couple ways to do this --
either take the "$a" out of the file and print $a.$out
or else add this line after you define the $a
$out=~s/\$a/$a/;
that'll substitute the literal "$a" with the variable $a
------------------------------
Date: Wed, 25 Apr 2001 07:20:42 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: perl variables problem
Message-Id: <slrn9edcoa.ubh.tadmc@tadmc26.august.net>
Sylvain Thevoz <sylvain.thevoz@mcnet.ch> wrote:
>open(FILE, "file.lst");
You should always, yes *always*, check the return value from open():
open(FILE, 'file.lst') or die "could not open 'file.lst' $!";
>My problem:
>when I execute the perl file, it prints "$a Mr. Smith, how do you do?"
>
>But I want to print "good morning Mr. Smith, how do you do?"
Perl FAQ, part 4:
"How can I expand variables in text strings?"
You are expected to check the Perl FAQ *before* posting to the
Perl newsgroup.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Apr 2001 13:00:36 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl variables problem
Message-Id: <9c6hpk$q0b$1@mamenchi.zrz.TU-Berlin.DE>
According to Sylvain Thevoz <sylvain.thevoz@mcnet.ch>:
> I have a file which contents:
> $a Mr. Smith, how do you do?
Avoid the use of variables $a and $b. See perldoc -f sort for why.
> I have a perl file which contents:
> $a = "good morning";
> open(FILE, "file.lst");
> while (<FILE>)
> {
> $out .= $_;
> }
> print $out;
>
> My problem:
> when I execute the perl file, it prints "$a Mr. Smith, how do you do?"
>
> But I want to print "good morning Mr. Smith, how do you do?"
Didn't we have this exact question last week?
Here is one way to do what you want:
my $line = '$x Mr. Smith, how do you do?';
my $x = 'Good morning';
print $line, ' -> ', eval "qq/$line/", "\n";
Prints:
$x Mr. Smith, how do you do? -> Good morning Mr. Smith, how do you do?
While this is probably more or less what you had in mind with your
code, it is insecure, as always when you use string eval with data
that come from outside your program. If someone changed your file
to read "$x Mr./Ms. Smith, how do you do?" your program will crash,
and there are worse things that could happen.
A safer way to accomplish the same thing is to use a substitution
operator: "$line =~ s/\$x/$x/g". Of course, now there is no need
to name the bit that has to be substituted like the Perl variable
that contains the substitution, any unique string would do. This
further decouples the program from the data, which is a good thing.
Anno
------------------------------
Date: Wed, 25 Apr 2001 10:24:07 GMT
From: harri@tolppa.kotisivupalvelu.fi (Harri Haataja)
Subject: Re: So what do YOU use Perl for?
Message-Id: <slrn9ed9iq.lg3.harri@tolppa.kotisivupalvelu.fi>
Steve Lamb wrote:
>On Sun, 22 Apr 2001 11:05:42 +0200, echo 'Rudolf Polzer'>/dev/null
><rpolzer@durchnull.de> wrote:
>>E.Chang <echang@netstorm.net> wrote:
>>> rename and perldoc -f s). (Oh, and a hint: .html is preferred over .htm
>>> as an extension for web documents - unless you're running your server on a
>>> Windows 3.x machine)
>
>>Why? I always use .htm because it is shorter. The same with .jpg and
>>.sht. But I do not restrict me to 8 chars in the name...
>
> Something about the fact that it isn't name HyperText Markup.
Neither is it Joint Photographic Group (Hm.. potheads?) or Motion Pictures
Group (film club?) but using the long suffix would make one look like a
Mac user. :^)
(Oh, yes. Always lowercase and never .htm anywhere. IMNSHO)
--
md5 sum: 07394dd242eb331be403826f2df92bbf
------------------------------
Date: 25 Apr 2001 12:13:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: use Filter::decrypt; How to encrypt source code first?
Message-Id: <9c6f0c$nje$1@mamenchi.zrz.TU-Berlin.DE>
According to John Lin <johnlin@chttl.com.tw>:
> "Anno Siegel" wrote
> > According to John Lin
> > > The crackers can study your .pm file to write a decryptor easily.
> > If an attacker steals both your encrypted source *and* the decryption
> > module you use, you're sol, right.
>
> OK, last quick question. If I have a script running on a ISP machine,
> it doesn't make sense to protect it by encryption because perl need both
> the source script and decryption module to run, whereas the ISP has full
> privilege to access both. Am I right?
You can't protect yourself against the system administrator with
a standard use[1] of Filter::decrypt, because the admin has access
to all files on the system.
You can protect your code from the visitors of your pages in
collaboration with the sysadm, where the adm gives you a safe place
to keep Filter/decrypt.pm out of reach for external visitors.
Anno
[1] In a non-standard use, decrypt.pm could ask the user (or the
environment) for a pass phrase to decrypt the code. This would
protect against everyone, but it's probably hard to implement in
a CGI environment.
------------------------------
Date: Wed, 25 Apr 2001 12:56:12 +0200
From: "Koit Tomingas" <Koit Tomingas@mail.ee>
Subject: user info
Message-Id: <3ae69f0e$1@news.estpak.ee>
Hi!
I'm new in Perl, so I don't know if it is possible at all?
How can I get some information about web page user ?
print $ENV{'USERNAME'}; and
print $ENV{'USERDOMAIN'};
work fine, when I run the script from command prompt,
but give me nothing when I access the script over Web server.
I'm running WinNT and IIS.
Koit Tomingas
------------------------------
Date: Wed, 25 Apr 2001 21:43:24 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: user info
Message-Id: <slrn9ede2r.hu4.mgjv@martien.heliotrope.home>
On Wed, 25 Apr 2001 12:56:12 +0200,
Koit Tomingas <KoitTomingas@mail.ee> wrote:
> Hi!
>
> I'm new in Perl, so I don't know if it is possible at all?
There is absolutely no Perl content in your question, or in this post.
Next time you have a question about CGI, HTTP or related stuff, ask in
one of the groups in comp.infosystems.www.*
> How can I get some information about web page user ?
You can't.
The only information you get is whatever the server makes available to
you. For CGI programs, and URLs that allow authenticated access only,
you can get the username used to log in. Your server, and maybe some of
its plugins, may make more information available to you.
Ask in a CGI group which environment variables to look at. Ask in a
group for your server to see what the available ones are. Find some
resources on CGI on the web, and read up on how it works.
www.cgi-resources,com might be a reasonable start.
> print $ENV{'USERNAME'}; and
> print $ENV{'USERDOMAIN'};
None of those are standard in CGI.
To make this slightly topical for Perl: Use the CGI module that comes
with Perl. Read its documentation.
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | What's another word for Thesaurus?
NSW, Australia |
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 760
**************************************