[9017] in Perl-Users-Digest
Perl-Users Digest, Issue: 2635 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 18 23:08:25 1998
Date: Mon, 18 May 98 20:00:31 -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 Mon, 18 May 1998 Volume: 8 Number: 2635
Today's topics:
Re: Authentication?? <bholzman@mail.earthlink.net>
Re: Does Perl have a IDE?I don't like command line. <brobbins@tis.com>
Efficiently finding the first available UID on a Unix s <apollock@bit.net.au>
extra element in array mswain@my-dejanews.com
Re: extra element in array <rootbeer@teleport.com>
filtering input for security / newbie <bhellbrg@u.washington.edu>
Re: filtering input for security / newbie <rootbeer@teleport.com>
Re: filtering input for security / newbie (Mark-Jason Dominus)
Re: filtering input for security / newbie <bholzman@mail.earthlink.net>
Re: ftpd <ljz@asfast.com>
Here a real stupid question <jeff@pacific.net>
Re: Here a real stupid question <sowmaster@juicepigs.com>
Re: Here a real stupid question <rootbeer@teleport.com>
Re: How to make IIS 3.0 execute perl script? <phengl@ir-optima.com>
Re: How to make IIS 3.0 execute perl script? (Martien Verbruggen)
Re: I can't store a reference in a key of hash! (Gurusamy Sarathy)
Re: I can't store a reference in a key of hash! <gnat@frii.com>
Re: Is if ($a="something") a bad style? (John Moreno)
Re: Need a Perl Data Processing Example <rrayborn@slip.net>
Non-static private variables (George Y. Lembersky)
Re: Non-static private variables (Francisws)
Re: Non-static private variables <bholzman@mail.earthlink.net>
Re: Perl/Wall lingo question <tchrist@mox.perl.com>
Re: Perl/Wall lingo question (Greg Andrews)
Re: Perl/Wall lingo question (Mark-Jason Dominus)
Progress 4GL and Perl DBD/DBI (Phil Freed)
Re: Progress 4GL and Perl DBD/DBI <webmaster@fccjmail.fccj.org>
reading (lots of) files in perl ? scottse@my-dejanews.com
Re: reading (lots of) files in perl ? <bholzman@mail.earthlink.net>
Re: Running Perl on Windows (Gary M. Greenberg)
Re: Text Wrangling Article <lr@hpl.hp.com>
Re: This, I believe has a simple solution. (WercRB)
Re: This, I believe has a simple solution. <rootbeer@teleport.com>
Re: Timing a script <bholzman@mail.earthlink.net>
Re: translate A-Z to 1-26 <lr@hpl.hp.com>
Re: translate A-Z to 1-26 <ljz@asfast.com>
Re: translate A-Z to 1-26 <yary@apicom.com>
Re: vec basics (Barry Masterson)
Re: while, each & assoc array (John Moreno)
Re: Win32 NT Perl Wrapper (Gurusamy Sarathy)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 18 May 1998 22:24:07 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Mark Sage <Mark_Sage@Compuserve.com>
Subject: Re: Authentication??
Message-Id: <3560ED47.1E7E900B@mail.earthlink.net>
[posted & mailed]
Mark Sage wrote:
>
> I am trying to get a PERL program to display a user/password dialog, and
> then process the input. I can make the dialog display by sending a
> "HTTP/1.0 404 Not Authorized", but no matter what I do I cannot get
> anything returned.
>
> Is this possible, can I do it with PERL, does anyone have an example?
>
> If this is not the way to authenticate, is there another way, I am
> trying to avoid using standard text/password HTML fields or using the
> web servers own authentication.
What's wrong with the web server's authentication? One way or the
other, you're going to have to cooperate with your web server, because
under CGI, it is the web server which has a "connection" to the browser,
not your script. If you're using the Apache web server, you might want
to take a look at mod_perl. You could, of course, write the web server
in perl.
HTH,
Benjamin Holzman
>
> Cheers
>
> Mark.
------------------------------
Date: Mon, 18 May 1998 17:25:38 -0400
From: Bert Robbins <brobbins@tis.com>
To: Clinton Pierce <cpierce1@cp500.fsic.ford.com>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <3560A752.7016@tis.com>
Clinton Pierce wrote:
>
> In article <356089D8.994B7F09@gamespot.com>,
> Jon Drukman <jsd@gamespot.com> writes:
> >Abigail wrote:
> >> ++ there are prebuilt packages you can download. your original statement:
> >> ++ "if you want one [c compiler], you have to pay" is false.
> >>
> >> That is ``[native c compiler]''. And that's still true.
> >
> >why is the distinction between c compiler and native c compiler useful
> >or important? in what way will downloading gcc limit you on solaris vs
> >what you would be able to do if you bought SUNpro?
>
> Because I can ship production software to plants and not incur the wrath
> of Ford Management if it's compiled under the Native C Compiler. If people
> die because the C-Compiler screwed up, it's hard to sue GNU--Sun
> Microsystems is another matter.
You haven't been reading the licensing agreements for the software you
have
been using have you? You will see the same disclaimer on just about all
software saying that all they are responsible for when something goes
wrong
is to replace the defective distribution material that you received said
software upon.
Thanks
Bert Robbins
------------------------------
Date: Tue, 19 May 1998 12:05:46 +1000
From: "Andrew Pollock" <apollock@bit.net.au>
Subject: Efficiently finding the first available UID on a Unix system
Message-Id: <6jqpdp$ba7$1@hermes.bit.net.au>
Hi,
Does anyone have some sample code to find the first available UID on a Unix
system in a relatively quick and efficient manner?
What I'm currently using is not fast or efficient and looks like it gives
the CPU a flogging.
Thanks in advance
Andrew
------------------------------
Date: Tue, 19 May 1998 01:55:30 GMT
From: mswain@my-dejanews.com
Subject: extra element in array
Message-Id: <6jqoqi$mb$1@nnrp1.dejanews.com>
I am trying to search for certain files in a directory tree and save the
filenames to an array. Invariably, the array ends up with an extra element at
the end, typically 0 or 256. An example:
@filelist=system("find /data -name \"*CSTSS*\"");
print @filelist;
produces output like:
/data/CSTSS.dat
/data/temp/CSTSS2.dat
256
What causes the extra element and how should I get rid of it?
Sorry if the answer is obvious, I just don't see it.
Thanks,
Mike
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Tue, 19 May 1998 02:47:00 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: mswain@my-dejanews.com
Subject: Re: extra element in array
Message-Id: <Pine.GSO.3.96.980518194514.28659J-100000@user2.teleport.com>
On Tue, 19 May 1998 mswain@my-dejanews.com wrote:
> I am trying to search for certain files in a directory tree and save the
> filenames to an array. Invariably, the array ends up with an extra
> element at the end, typically 0 or 256. An example:
>
> @filelist=system("find /data -name \"*CSTSS*\"");
> print @filelist;
>
>
> produces output like:
>
> /data/CSTSS.dat
> /data/temp/CSTSS2.dat
> 256
That's not an extra element. It's the return value from system. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 18 May 1998 16:38:20 -0700
From: "W. Hellberg" <bhellbrg@u.washington.edu>
Subject: filtering input for security / newbie
Message-Id: <Pine.A41.3.95b.980518163633.126650E-100000@homer04.u.washington.edu>
I'm a beginner trying to use Perl to make an interactive form.
My problem is about putting in a security filter so that only legal
alphanumeric characters get to the server (I've read that this is more
secure than filtering out possible illegal characters).
Line 9 below works as one such filter in this simple skeleton:
1 #!/usr/local/bin/perl -T
2
3 require 'cgi-lib.pl';
4 print &PrintHeader;
5 &ReadParse (*simple)
6
7 $anna = $simple('anna');
8
9 if ($anna =~ /[^_0-9a-zA-Z] + /) {
10 print "Hey, perkele!, cut that out! etc"
11 } else { print "Thanks" }
12 exit;
I understand basically how the line filters; I don't know how to use
it or something similar in the following program (I'm writing out
Brenner's ReadParse subroutine here, thinking that the filter might
need to be in that parsing):
#!/usr/local/bin/perl
require 'cgi-lib.pl';
print &PrintHeader;
do ReadParse(*form);
sub ReadParse {
local (*in) = @_ if @_;
local ($i, $loc, $key, $val);
if ($ENV{'REQUEST_METHOD'} eq "GET") {
$in = $ENV{'QUERY_STRING'};
} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); }
@in = split(/&/,$in);
foreach $i (0 .. $#in) {
$in[$i] =~ s/\+/ /g;
($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator
$in{$key} .= $val; }
}
return 1; #just for fun
}
$recipient = "me\@here.com";
$subject = "Form submission";
open(MAIL, "| /usr/lib/sendmail -n -oi -t");
print MAIL "To: $recipient\n";
print MAIL "Subject: $subject\n";
print MAIL "\n";
print MAIL "Name: $form{'name'}\n";
print MAIL "Phone: $form{'phone'}\n"; #etc
close (MAIL);
print <<HTML_RESPONSE;
<HTML> etc
<BODY>Yr application has been received.</BODY>
</HTML>
HTML_RESPONSE
exit;
I've tried integrating the filtering line and other varieties in
many ways, but I feel I'm going in circles - have looked in lots of
books and search the net - found several programs to do the task,
but not quite - tried several dozen permutations, but I'm not
understanding program flow, or the kinds of variables and/or
other stuff.
I'd appreciate some pointers/encouragement. Would somebody with
more experience help?
Thanks a lot -
-Bill
------------------------------
Date: Tue, 19 May 1998 01:46:14 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: "W. Hellberg" <bhellbrg@u.washington.edu>
Subject: Re: filtering input for security / newbie
Message-Id: <Pine.GSO.3.96.980518183715.28659E-100000@user2.teleport.com>
On Mon, 18 May 1998, W. Hellberg wrote:
> My problem is about putting in a security filter so that only legal
> alphanumeric characters get to the server (I've read that this is more
> secure than filtering out possible illegal characters).
This is good that you're thinking about security issues. "There is no such
thing as being 'too paranoid'." :-)
> Line 9 below works as one such filter in this simple skeleton:
> 9 if ($anna =~ /[^_0-9a-zA-Z] + /) {
Perhaps that's not what you meant. That condition will be true only if
there's a non-alphanumeric character followed by two or more spaces in
$anna. So, 'bad*data' wouldn't trigger that condition.
Here's my common idiom for this sort of thing:
($safe) = ($suspect =~ /^(\w+)$/);
After this statement, $safe is either undef (meaning that the pattern
didn't match) or it's set to a known-safe and untainted string. Since the
pattern is anchored, the only non-alphanumeric character I'll allow is a
trailing newline, which won't become part of $safe. (It's also possible to
use the same variable on the left and right sides, but this is clearer.)
Does that give you what you need? Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 18 May 1998 22:35:56 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: filtering input for security / newbie
Message-Id: <6jqr6c$eqv$1@monet.op.net>
Keywords: educate mig shrove silver
In article <Pine.A41.3.95b.980518163633.126650E-100000@homer04.u.washington.edu>,
W. Hellberg <bhellbrg@u.washington.edu> wrote:
>7 $anna = $simple('anna');
You want
$anna = $simple{'anna'};
here. Those should be curly braces, not parentheses.
In recent versions of Perl, the '' are omittable:
$anna = $simple{anna};
------------------------------
Date: Mon, 18 May 1998 22:07:34 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: "W. Hellberg" <bhellbrg@u.washington.edu>
Subject: Re: filtering input for security / newbie
Message-Id: <3560E966.2D11B0C2@mail.earthlink.net>
[posted & mailed]
> I've tried integrating the filtering line and other varieties in
> many ways, but I feel I'm going in circles - have looked in lots of
> books and search the net - found several programs to do the task,
> but not quite - tried several dozen permutations, but I'm not
> understanding program flow, or the kinds of variables and/or
> other stuff.
>
> I'd appreciate some pointers/encouragement. Would somebody with
> more experience help?
>
> Thanks a lot -
>
> -Bill
Your script looks pretty secure to me, except that you'll probably want
to set/clear $ENV{'IFS'}, $ENV{'PATH'} and $ENV{'CDPATH'}. You don't
really need to filter your form parameters, because you don't do
anything unsafe with them. You should check $? after you close the pipe
to mail, though.
------------------------------
Date: 18 May 1998 21:11:54 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: ftpd
Message-Id: <ltu36nt679.fsf@asfast.com>
Arthur Dardia <ahdiii@webspan.net> writes:
> I believe there's a file called "ftp.pl" (or maybe just "ftp") that
> shipped with the Win32 port by ActiveState. It's in Perl\lib. HTH.
If this is the same as the `ftp.pl' that comes with the standard
release of Perl5, then it's an FTP *client*, not an FTP *daemon* (see
quote from original post, below).
> Walter Fitzharris wrote:
>
> > I am looking for an ftp daemon written in perl(5).
^^^^^^^^^^
--
Lloyd Zusman ljz@asfast.com
perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'
------------------------------
Date: Mon, 18 May 1998 19:20:15 -0700
From: "Pacific News" <jeff@pacific.net>
Subject: Here a real stupid question
Message-Id: <6jqq15$8ns$1@nntp1.ba.best.com>
Hello all,
Please forgive this newbie question, but I'm new to perl and I'm on a time
line. Here it goes... How do I pass arguements from a URL to the same perl
script to restructure a perl generated web page? I have everything working
except for this. I want to be able to have the page look different when you
click on a HTML link.
http://www.mydomain.com/cgi-bin/myperl?myarguement
I've tried using @ARGV to extract the information, but couldn't get it to
work. I also tried $myinfo = (<>) and STDIN to now avail. What am I
missing? Thanks in advance...
Jeff
------------------------------
Date: Mon, 18 May 1998 22:30:04 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: Pacific News <jeff@pacific.net>
Subject: Re: Here a real stupid question
Message-Id: <3560EEAC.4F2A@juicepigs.com>
[posted & mailed]
Pacific News wrote:
>
> Hello all,
>
> Please forgive this newbie question, but I'm new to perl and I'm on a time
> line. Here it goes... How do I pass arguements from a URL to the same perl
> script to restructure a perl generated web page? I have everything working
> except for this. I want to be able to have the page look different when you
> click on a HTML link.
>
> http://www.mydomain.com/cgi-bin/myperl?myarguement
>
> I've tried using @ARGV to extract the information, but couldn't get it to
> work. I also tried $myinfo = (<>) and STDIN to now avail. What am I
> missing? Thanks in advance...
You'll find the args in the $ENV{'QUERY_STRING'} if you do it that way.
HTH
--
Bob Trieger | Titanic: big boat, bigger
sowmaster@juicepigs.com | iceberg, big deal
------------------------------
Date: Tue, 19 May 1998 02:52:34 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Pacific News <jeff@pacific.net>
Subject: Re: Here a real stupid question
Message-Id: <Pine.GSO.3.96.980518194742.28659K-100000@user2.teleport.com>
On Mon, 18 May 1998, Pacific News wrote:
> Subject: Here a real stupid question
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> How do I pass arguements from a URL to the same perl
> script to restructure a perl generated web page?
The same way you pass arguments from a URL to a non-Perl program. :-)
This means that the answer has to do with such things as HTTP, rather
than Perl.
> I've tried using @ARGV to extract the information, but couldn't get it
> to work.
Now you're trying to read the arguments, not pass them. That's easy to do
with the CGI module. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 19 May 1998 00:20:44 GMT
From: "Pheng Lay" <phengl@ir-optima.com>
Subject: Re: How to make IIS 3.0 execute perl script?
Message-Id: <01bd82bb$b329d3c0$ed8fd9cf@pheng-lay>
Martien,
Sorry if I mis-understand the web server and IIS. I thought that IIS is
also a web server because it services www.
Martien Verbruggen <mgjv@comdyn.com.au> wrote in article
<6jqfnq$jkm$3@comdyn.comdyn.com.au>...
> In article <01bd8274$5c3905a0$1c90d9cf@pheng-lay>,
> "Pheng Lay" <phengl@ir-optima.com> writes:
> > I've installed perl 5.0 build 316 on NT 4.0 with IIS 2.0. I can
execute
> > perl script on the command prompt, but when I try to execute the perl
> > script thru browser, I could not execute it. By default, after
installing
> > perl, it placed the following line in registry:
>
> You can't execute CGI programs in your browser. You will need to
> install a web server. Please ask on one of the comp.infosystems.www.*
> groups what might be a suitable solution for you.
>
> Martien
> --
> Martien Verbruggen |
> Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
> Commercial Dynamics Pty. Ltd. | clothes.
> NSW, Australia |
>
------------------------------
Date: 19 May 1998 02:27:38 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How to make IIS 3.0 execute perl script?
Message-Id: <6jqqmq$kld$1@comdyn.comdyn.com.au>
In article <01bd82bb$b329d3c0$ed8fd9cf@pheng-lay>,
"Pheng Lay" <phengl@ir-optima.com> writes:
> Martien,
> Sorry if I mis-understand the web server and IIS. I thought that IIS is
> also a web server because it services www.
Probably. I really don't know much about IIS. If by 'execute from the
browser' you meant that you were pointing your browser at your IIS
server, and the IIS server barfed in some way, then it is a server
problem, most likely. If a script works from the command line, but not
when run as a CGI, then it's not a perl problem.
You should ask questions about web server configuration in one of the
comp.infosystems.www.* groups.
You might find the following documentation useful also:
Perl CGI FAQ and (no offense) Idiot's guide:
http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.com/CPAN/doc/FAQs/cgi/perl-cgi-faq.html
Section 9 of the perl FAQ:
# perldoc perlfaq9
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: 19 May 1998 01:52:32 GMT
From: gsar@engin.umich.edu (Gurusamy Sarathy)
Subject: Re: I can't store a reference in a key of hash!
Message-Id: <6jqol0$hv@srvr1.engin.umich.edu>
[ mailed and posted ]
In article <5qvhr3b58c.fsf@prometheus.frii.com>,
Nathan Torkington <gnat@frii.com> wrote:
>The module in question is called Tie::IxHash and is available from
>CPAN. See http://www.perl.com/CPAN for more on CPAN. The Tie::IxHash
>module simply handles the parallel hash (mapping stringified
>references to real references) behind the scenes. It doesn't offer any
>performance benefits, just a cleaner syntax (you magically get a hash
>that returns references from keys and each).
Actually, Tie::IxHash is probably more that what the poster needs.
Tiny Tie::RefHash, which is a standard part of perl, will do the job.
Tie::IxHash will also work to preserve references as hash keys, due to
the happy circumstance that it doesn't stringify the keys internally.
But it is not _required_ if the poster doesn't care if his hashes
maintain their order or not.
- Sarathy.
gsar@umich.edu
------------------------------
Date: 18 May 1998 19:58:49 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Re: I can't store a reference in a key of hash!
Message-Id: <5qemxrm36u.fsf@prometheus.frii.com>
gsar@engin.umich.edu (Gurusamy Sarathy) writes:
> Actually, Tie::IxHash is probably more that what the poster needs.
> Tiny Tie::RefHash, which is a standard part of perl, will do the job.
I *meant* RefHash, honestly!
Nat
(braino)
------------------------------
Date: Tue, 19 May 1998 02:21:32 GMT
From: phenix@interpath.com (John Moreno)
Subject: Re: Is if ($a="something") a bad style?
Message-Id: <1d98vnv.1h5t3yythx5z4N@roxboro0-013.dyn.interpath.net>
Randal Schwartz <merlyn@stonehenge.com> wrote:
> >>>>> "John" == John Moreno <phenix@interpath.com> writes:
-snip
> John> Hm? I'm not sure what you mean by "sense" - it's certainly not the same
> John> as the original question, but unless I'm missing something it's the same
> John> (or rather has the same effect) as Mark-Jason's example.
>
> Ugh! My goof! I didn't notice the == 0 in the first one! I had thought
> that it was still testing for non-zero.
>
> Ouch.
Whew.
--
John Moreno
------------------------------
Date: Mon, 18 May 1998 18:54:45 -0700
From: "Randal Rayborn" <rrayborn@slip.net>
Subject: Re: Need a Perl Data Processing Example
Message-Id: <6jqq9u$j5o$1@owl.slip.net>
Jim, while your wittily sarcastic reply goes to the heart of the question,
as you might have surmised I am working in a Windows NT environment, where,
sadly, the join command does not exist. I do not doubt that Perl, with the
proper modules, can outperform any other commonly used data processing
language and so I ask again: can anyone point me towards an appropriate
match-merge code example?
Yours in gratitude,
Randal Rayborn, MCSE
>Randal Rayborn <rrayborn@slip.net> wrote:
>> I have two fixed field data files which I need to read in, join together
on
>> a merge key (say one for simplicity) and write out as a complete file.
Does
>> anyone have a good code example for this? I am specifically interested in
>> the process of reading a record from one file then looping through and
>> matching the key field on the other file. This is a very "COBOL-like"
>> operation.
>>
>> Randal Rayborn, MCSE
>
>By posting this inquiry, you demonstrate that you don't want to re-invent
>the wheel, which is admirable. The "COBOL-like" two-file match program has
>been written, and its name is join (the UNIX "join" command). It couples
>nicely with other utilities such as sort, uniq, cut, sed, awk, Perl, etc.
>Yes, the name "join" comes from where you think it comes from: relational
>data base theory.
>
>Curiously, the join command is not covered on the MCSE exam.
>
>--
>Jim Monty
>monty@primenet.com
>Tempe, Arizona USA
------------------------------
Date: 18 May 1998 23:40:19 GMT
From: gyl8384@omicron.acf.nyu.edu (George Y. Lembersky)
Subject: Non-static private variables
Message-Id: <6jqgt3$ml4$1@news.nyu.edu>
Keywords: Non-static private variables
I was wondering if anyone knew how to create a non-static (instance)
private variable in a Perl class.
As I understand Perl classes are just packages, which are just name
spaces. And instances of these classes are references to thingies which
are scalars, hashes or arrays. If this is all there is to an instance of
a class, than all of its variables must be stored in the arrays or hashes
and these are visible by the package that instantiated this class. Is
there any way to have instantiated variables that are private? The
variables inside the package are static - they are the same across all
instances.
- George
------------------------------
Date: 19 May 1998 02:06:27 GMT
From: francisws@aol.com (Francisws)
Subject: Re: Non-static private variables
Message-Id: <1998051902062800.WAA20704@ladder03.news.aol.com>
I am not quite sure what your asking. But there is the
my $variable which will make a variable local to the routine.
this variable cannot be passed up or down.
local ($variable) this will make a variable local to the routine and can be
passed down.
there is bless keyword to tag objects internally with a pointer to the
packages they belong to.
I don't know if this is a help or not.
------------------------------
Date: Mon, 18 May 1998 21:56:26 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: "George Y. Lembersky" <gyl8384@omicron.acf.nyu.edu>
Subject: Re: Non-static private variables
Message-Id: <3560E6CA.7A9C0E16@mail.earthlink.net>
[posted & mailed]
George Y. Lembersky wrote:
>
> I was wondering if anyone knew how to create a non-static (instance)
> private variable in a Perl class.
>
> As I understand Perl classes are just packages, which are just name
> spaces. And instances of these classes are references to thingies which
> are scalars, hashes or arrays. If this is all there is to an instance of
> a class, than all of its variables must be stored in the arrays or hashes
> and these are visible by the package that instantiated this class. Is
> there any way to have instantiated variables that are private? The
> variables inside the package are static - they are the same across all
> instances.
>
> - George
Please read the documentation which comes with perl, specifically the
"perlobj", "perltoot" and "perlbot" man pages. You're quite a bit
confused about terminology; these documents should help clear things up.
------------------------------
Date: 19 May 1998 00:06:03 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl/Wall lingo question
Message-Id: <6jqidb$gu5$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, wayne@Glue.umd.edu (Wayne C. McCullough) writes:
:Theoretical Computer Science is Math.
"Computer Science is no more about computers than astronomy
is about telescopes." --E.W. Dijkstra
:Applied Computer Science is engineering.
If you discover a new phenomemom, and
...both understand it and can prove why it occurs, publish
in a mathematics journal.
...understand it and but cannot prove it, publish
in a physics journal.
...neither understand it nor are able prove it, publish
in an engineering journal.
:The two paths diverged years ago and have less in common then
:"Modern Literature" and "Solid State Physics". Which is ironic
:because math an engineering folks at least admit that there is
:something in common between the two fields.
And what do you call someone who gets an "MIS" degree from the Business
School so they can become an "IT Professional?
A very large program is bogging down the computer and management
wants to know why, so sets three different employees to solve
the problem.
The computer scientist analyses the program's algorithm and
reduces it from cubic to logarithmic.
The computer engineer finds nothing with his oscilloscope
so decides to install more swap space.
The IT professional goes down to CompUSA and asks whether
there's a Microsoft Service Pack for this yet.
--tom
--
You are the sponsor for the account andrew (Andrew Hume).
------------------------------
Date: 19 May 1998 01:45:15 GMT
From: gerg@shell. (Greg Andrews)
Subject: Re: Perl/Wall lingo question
Message-Id: <6jqo7b$q4b$1@news.ncal.verio.com>
tchrist@mox.perl.com (Tom Christiansen) writes:
>
>And what do you call someone who gets an "MIS" degree from the Business
>School so they can become an "IT Professional?
>
>A very large program is bogging down the computer and management
>wants to know why, so sets three different employees to solve
>the problem.
>
> The computer scientist analyses the program's algorithm and
> reduces it from cubic to logarithmic.
>
> The computer engineer finds nothing with his oscilloscope
> so decides to install more swap space.
>
> The IT professional goes down to CompUSA and asks whether
> there's a Microsoft Service Pack for this yet.
>
Which one posts to c.l.p.misc asking for the answer? ;-)
(Sorry for the unreplyable address in my From: line, Tom)
-Greg
------------------------------
Date: 18 May 1998 22:27:23 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Perl/Wall lingo question
Message-Id: <6jqqmb$env$1@monet.op.net>
Keywords: clarity optimism peck survive
In article <6jqidb$gu5$1@csnews.cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
>In comp.lang.perl.misc, wayne@Glue.umd.edu (Wayne C. McCullough) writes:
>:Theoretical Computer Science is Math.
>
> "Computer Science is no more about computers than astronomy
> is about telescopes." --E.W. Dijkstra
My reaction to that is the same as the first time I heard you quote it:
1. Dijkstra is full of shit as usual.
2. And he doesn't know much about astronomy!
I mean, I *guess* you could make a case for computer science not being
about computers, in the same sense that aeronautical engineering is
not about airplanes, or architecture is not about concrete, or
shoemaking is not about leather, or astronomy is not about telescopes,
but I don't think it would be a very interesting case. Whether or not
astronomy is `about' telescopes, it still remains that you have to
know an awful lot about telescopes if you want to do astronomy.
All arts and sciences have at their base a healthy does of craft, and
familiarity with these crafty details is essential for serious
practitioners. Artists have to know an awful lot about firing kilns
and pyrometric cones and ink and stretching canvas and whatever, all
this messy material stuff that has nothing to do with Pure Art, but
you can't do Art without it. Astronomers spend a lot of time
shivering on mountaintops and fussing with mirrors and cameras. Those
things are both a lot less craftlike than computer programming.
I don't think it's wise to try to take the craft parts out of
something as craft as computer programming. Sure, there's a lot of
theory there; that doesn't mean there's no involvement with actual
computers.
------------------------------
Date: Tue, 19 May 1998 01:15:52 GMT
From: ptf@cybertours.com (Phil Freed)
Subject: Progress 4GL and Perl DBD/DBI
Message-Id: <3563dd00.36964805@newshost.cybertours.com>
Has anyone created a DBD/DBI interface to the Progress 4GL? Failing
that, has anyone done anything clever (aside from the obvious "open a
pipe from the 4GL" or "open the 4GL from a pipe")?
I'm betting that we can write something nice to work with Webspeed -
but I hate to reinvent the wheel.
Thanks in advance for your comments.
------------------------------
Date: Tue, 19 May 1998 02:17:17 GMT
From: Bill 'Sneex' Jones <webmaster@fccjmail.fccj.org>
Subject: Re: Progress 4GL and Perl DBD/DBI
Message-Id: <3560E9CE.21230B02@fccjmail.fccj.org>
Phil Freed wrote:
>
> Has anyone created a DBD/DBI interface to the Progress 4GL? Failing
> that, has anyone done anything clever (aside from the obvious "open a
> pipe from the 4GL" or "open the 4GL from a pipe")?
>
> I'm betting that we can write something nice to work with Webspeed -
> but I hate to reinvent the wheel.
>
> Thanks in advance for your comments.
:-)
I have asked something similar to this is comp.*.progress and
haven't seen an answer...
Having 4+ years experience in Progress v6 in CTOS, Unix, Dos/Windows,
etc, I can say is Progress has a nice Transaction Server; but that and
everything else can be done well in Perl without Progress.
The question I asked was - Did anyone know of a Perl-script to read
Progress schema structure and associated data for migration reasons...
Hmmm, maybe that's why no one responded. I abandoned Progress
at v7 when I discovered PSC was heading to a Windows-centric existence.
Followups set.
-Sneex- =)
____________________________________________________________________________
Bill Jones | FCCJ Webmaster | Voice 1-904-632-3089 | Fax 1-904-632-3007
Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
mailto:webmaster@fccjmail.fccj.org | http://webmaster.fccj.org/Webmaster
------------------------------
Date: Tue, 19 May 1998 00:45:46 GMT
From: scottse@my-dejanews.com
Subject: reading (lots of) files in perl ?
Message-Id: <6jqknq$qn8$1@nnrp1.dejanews.com>
Hi
I'm trying to read a series of files in perl, at the moment I'm doing the
following:
-----
#!/usr/local/bin/perl
$primary_so = 12345;
@question_html_array = ('question_header.html','question_body1.html');
%question_html_file_array =
("question_header.html","question_header","question_body1.html","question_bod
y1");
$question_html_files = @question_html_array;
for ($question_html_count = 0; $question_html_count != $question_html_files;
$question_html_count++) {
$FILE_HANDLE =
($question_html_file_array{$question_html_array[$question_html_count]});
$INPUT_FILE = ("/opt/local/http/ifsdoc-cgi-bin/html/" .
$question_html_array[$question_html_count]);
open (FILE_HANDLE,INPUT_FILE) || die ("Error reading : $!;");
};
@question_header = <question_header>; # is there any way to do this in
@question_body1 = <question_body1>; # the for loop ?
$question_string = join (@question_header,$primary_so,@question_body1);
print $question_string;
-----
What I'm trying to do is read a large number of files and then create a final
variable from the contents of the files joined with some data from another
source.
I'm not a programmer by any means, and I'm hoping that someone can give me a
hint as to how to the above a bit more efficiently....
Thanks
Scott
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 18 May 1998 21:51:26 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: scottse@my-dejanews.com
Subject: Re: reading (lots of) files in perl ?
Message-Id: <3560E59E.731794A7@mail.earthlink.net>
scottse@my-dejanews.com wrote:
>
> Hi
>
> I'm trying to read a series of files in perl, at the moment I'm doing the
> following:
> -----
<snip>
> What I'm trying to do is read a large number of files and then create a final
> variable from the contents of the files joined with some data from another
> source.
>
> I'm not a programmer by any means, and I'm hoping that someone can give me a
> hint as to how to the above a bit more efficiently....
>
Well, since what you wrote above is so riddled with errors it's barely
perl, it's pretty difficult to figure out what you're trying to do. If
all you want to do is concatenate files together with some constant
text, you don't need perl. Try typing "man cat". If you want something
different, you're going to have to explain it better.
HTH,
Benjamin Holzman
------------------------------
Date: Tue, 19 May 1998 00:49:19 GMT
From: garyg@gator.net (Gary M. Greenberg)
Subject: Re: Running Perl on Windows
Message-Id: <jG481.342$r8.738680@news.randori.com>
In article <355eab87.2530398@news.demon.co.uk>, steven@amber.co.uk (Steven Wayne) wrote:
> genfil@my-dejanews.com wrote:
>
> >I need help!
> >I write perl scripts on unix and now I have to write scripts on NT and
> >Win95.
> >Is there an equivalent of "#!/usr/bin/perl" on NT and Win95?
If you have MKS Toolkit you can shebang all you like ;-}
Without it, (on NT anyway), you can add your perl script's directory to
your %path% (or all paths if you're the administrator), then owtdi is:
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0;
rather than #!/usr/bin/perl
And invoke your perl script as:
perl <myscript> {args}
Seems like a Kludge to me, but then isn't that what Win{95,NT} are too!
> >Thank you!
>
> You can use:
>
> #!/perl/bin -w
>
> etc to put any command line switches in, but this won't cause the program
> to run as it does in Unix. To do this you will have to associate the .pl
> extension with c:\perl\bin\perl.exe and name your perl scripts xxx.pl
>
> Do you know how to do this?
gary -=- The C Programmers' Reference -=-
http://www.gator.net/~garyg/C/c.html
-=- Avenue Programmers' Classes' Requests -=-
http://www.gator.net/~garyg/class.htm
------------------------------
Date: Mon, 18 May 1998 17:42:31 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: Text Wrangling Article
Message-Id: <6jqkht$b6j@hplntx.hpl.hp.com>
Bill 'Sneex' Jones wrote in message
<3560C082.1BC77B42@fccjmail.fccj.org>...
>Steve Palincsar wrote:
>>
>> > @{[]} which allows you to use arbitrary expressions.
>
>> was right there in the Camel all along; but Hall showed me what it
was
>> good for at a time when I was ready to learn it.
The books are fine, but here's an even more accessible source, with
another twist:
perlfaq4: How do I expand function calls in a string?
This is documented in the perlref manpage. In general, this is fraught
with quoting and readability problems, but it is possible. To
interpolate a subroutine call (in a list context) into a string:
print "My sub returned @{[mysub(1,2,3)]} that time.\n";
If you prefer scalar context, similar chicanery is also useful for
arbitrary expressions:
print "That yields ${\($n + 5)} widgets\n";
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 19 May 1998 00:53:01 GMT
From: wercrb@aol.com (WercRB)
Subject: Re: This, I believe has a simple solution.
Message-Id: <1998051900530100.UAA11838@ladder03.news.aol.com>
> Is the *vary* first line of your script "#!/path/to/your/perl"?
Yes, it definately is.
>
> The "#!" *must* be the *vary first* characters of the file. No
> newlines, white space, anything.
>
I was using the perl installed on local before
#!/usr/local/bin/perl
which worked fine. The newer version that I installed
#!/usr/home/me/bin/perl
is what is not working correctly.
------------------------------
Date: Tue, 19 May 1998 01:30:59 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: WercRB <wercrb@aol.com>
Subject: Re: This, I believe has a simple solution.
Message-Id: <Pine.GSO.3.96.980518182804.28659C-100000@user2.teleport.com>
On 18 May 1998, WercRB wrote:
> %s: Command not found
> %s: Undefined variable
> According to the docs, these messages mean I am running Perl
> from a "Bourne Shell",
To be more accurate, it seems that your script is being interpreted by
that shell rather than by a perl binary. Perhaps your system doesn't
recognize the #! line, or perhaps your #! line is malformed. You should
probably ask your local expert to take a look at things. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 18 May 1998 22:25:43 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Craig Berry <cberry@cinenet.net>
Subject: Re: Timing a script
Message-Id: <3560EDA7.81F512EF@mail.earthlink.net>
> Note that this only gets you an integer number of seconds, and that the
> precision is +- 1 second. So for quick searches on a fast server, it
> won't mean much. Also note that user percieved search time can be
> noticeably longer due to network delays.
>
> If you need finer resolution, I suggest lifting the hood on Benchmark.pm
> and seeing how it handles code timing.
Just get Time::HiRes.
>
> ---------------------------------------------------------------------
> | Craig Berry - cberry@cinenet.net
> --*-- Home Page: http://www.cinenet.net/users/cberry/home.html
> | Member of The HTML Writers Guild: http://www.hwg.org/
> "Every man and every woman is a star."
------------------------------
Date: Mon, 18 May 1998 17:28:18 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: translate A-Z to 1-26
Message-Id: <6jqjn9$au4@hplntx.hpl.hp.com>
Craig Berry wrote in message <6jqgud$h05$1@marina.cinenet.net>...
>brian d foy (comdog@computerdog.com) wrote:
>: In article <6jqc9i$3gc@usenet.srv.cis.pitt.edu>, juping+@pitt.edu
(Juping Jin) posted:
>:
>: >I want to translate A-Z symbols to numberical symbols, and tried:
>: >
>: > s/([A-Z])/ord('\1')-65/g;
>:
>: $_ = 'Just Another New York Perl Hacker';
>:
>: s/([A-Z])/ord($1) - 64/eg;
>
>Or, to be character set independent:
>
> s/([A-Z])/ord($1) - ord('A') + 1/eg;
>
>Some of us still see EBCDIC data now and then... :)
Replacing the 64 by ord('A') - 1 seems wise. But your expression has to
be much more elaborate to work for the EBCDIC character set:
Decimal value Symbol
129-137 a-i
145-153 j-r
162-169 s-z
193-201 A-I
209-217 J-R
226-233 S-Z
Working it out is an exercise left for any reader who cares. I don't
:-)
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 18 May 1998 21:54:04 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: translate A-Z to 1-26
Message-Id: <ltogwvt48z.fsf@asfast.com>
cberry@cinenet.net (Craig Berry) writes:
> brian d foy (comdog@computerdog.com) wrote:
> : In article <6jqc9i$3gc@usenet.srv.cis.pitt.edu>, juping+@pitt.edu (Juping Jin) posted:
> :
> : >I want to translate A-Z symbols to numberical symbols, and tried:
> : >
> : > s/([A-Z])/ord('\1')-65/g;
> :
> : $_ = 'Just Another New York Perl Hacker';
> :
> : s/([A-Z])/ord($1) - 64/eg;
>
> Or, to be character set independent:
>
> s/([A-Z])/ord($1) - ord('A') + 1/eg;
>
> Some of us still see EBCDIC data now and then... :)
But what about the gap between 'I' and 'J' and between 'R' and 'S' in
EBCDIC?
To handle this in the EBCDIC case (and in the totally general case),
some sort of table lookup would be needed.
But based on the `ord' entry in the `perlfunc' man pages, it looks
like this might be a moot point in Perl, since `ascii' is specifically
mentioned:
ord EXPR
ord Returns the numeric ascii value of the first
character of EXPR. If EXPR is omitted, uses $_.
For the reverse, see the chr entry elsewhere in
this document .
--
Lloyd Zusman ljz@asfast.com
perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'
------------------------------
Date: Mon, 18 May 1998 18:41:44 -0700
From: Yary Hluchan <yary@apicom.com>
Subject: Re: translate A-Z to 1-26
Message-Id: <3560E358.48E5@apicom.com>
This will work for any char set, and upper and lower (feature or bug?)
# setup
$c = 1;
for $a ('a' .. 'z') {
$b{$a} = $b{"\u$a"} = $c++;
}
# go
$_="Just another perl hacker,";
s/([A-Za-z])/$b{$1}/egi;
print;
------------------------------
Date: 18 May 1998 20:47:36 -0400
From: jbarrm@panix.com (Barry Masterson)
Subject: Re: vec basics
Message-Id: <6jqkr8$54e@panix3.panix.com>
Steffen Beyer (sb@engelschall.com) wrote:
: [mailed && posted]
Thanks to those who responded. I'm working on a cgi script, and
while thinking out a problem, I felt that vec might be the solution.
I like to have a good understanding of a language, and its functions
before I dive into something new. I'm reviewing the bitwise operators
as described in a C book. It's already starting to make sense.
: Are you sure that you want to use "vec"?
: There is a module on CPAN offering much more functionality for bit vectors
: than "vec", which is also very efficient because its core is written in C.
: The name is "Bit::Vector", it's available from
This I overlooked, the CPAN modules.
Thank you.
Barry Masterson
jbarrm@panix.com
--
>--->--->--->--->--->
FreeBSD 2.2.6
<---<---<---<---<---<
------------------------------
Date: Tue, 19 May 1998 02:21:40 GMT
From: phenix@interpath.com (John Moreno)
Subject: Re: while, each & assoc array
Message-Id: <1d98vuy.phjdpopdzhmkN@roxboro0-013.dyn.interpath.net>
Randal Schwartz <merlyn@stonehenge.com> wrote:
> >>>>> "John" == John Moreno <phenix@interpath.com> writes:
>
-snip-
>
> John> Well, I knew what I meant and so did you, and I ain't writing
> John> documentation or specs so it seems close enough to me. Of course if you
> John> put it in one of your books or classes somebody would be bound to laugh
> John> at it (and of course in those circumstances they'd probably be right).
>
> The problem, John, is that we're not having a private conversation.
Of course you're right, and looking at that first sentence is a bit more
than I wanted to write.
> So if the newbies playing along at home, mistake what you wrote for a
> completely accurate statement, they'll be fuzzily wondering why:
>
> print $n if $n > 10 while $n = <STDIN>;
>
> doesn't work. Because it *does* work in what you said, but not in
> real Perl. :-)
Ugh. I'm not sure whether you are over or under estimating the newbies,
but wouldn't expect anybody to do that (on the other hand my judgement
of what people will do is notoriously off).
> Thus, I feel somewhat obligated to do my part to point out the errors
> in what other people post here. Especially people that claim they
> know better. (Nudge nudge.)
<g>
--
John Moreno
------------------------------
Date: 19 May 1998 02:19:31 GMT
From: gsar@engin.umich.edu (Gurusamy Sarathy)
Subject: Re: Win32 NT Perl Wrapper
Message-Id: <6jqq7j$1rq@srvr1.engin.umich.edu>
[ mailed and posted ]
In article <3560B537.539F061B@sig.net>, sonny <parafina@sig.net> wrote:
>Way back when ('93-'95) with the Intergraph perl 4.xxx NT port it was
>necessary. It was still necessary on the early Hip 5.x port. The
>installation program of current ports (Activestate and the Garam Masala -
>> spunky-pseudonyms
>or whatever) seem to all the necessary NT registry work, making the wrapper
>a non-issue. I've used AT and perl scripts to automate downloads from
>client sites, works dandy.
Actually the Garam Masala installation doesn't touch the registry
with a ten-foot pole. It installs stuff under the one directory you
asked it to put stuff under, and that's it. No hidden locations that
get fiddled, no mystery, no mayhem whatsoever. I consider that a
feature.
As for the necessity of wrappers, consider the fact that file associations
are broken for redirections. Or that they're not available in
poor-mans-win32 (aka Windows95).
- Sarathy.
gsar@umich.edu
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2635
**************************************