[12130] in Perl-Users-Digest
Perl-Users Digest, Issue: 5730 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 20 00:07:25 1999
Date: Wed, 19 May 99 21:00:20 -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 Wed, 19 May 1999 Volume: 8 Number: 5730
Today's topics:
Re: appending a box form (David Efflandt)
Re: backspace in file output question (David Efflandt)
Binary image file reading or $x as a number. mc_david@my-dejanews.com
Re: Binary image file reading or $x as a number. (Alastair)
Re: Binary image file reading or $x as a number. armchair@my-dejanews.com
Re: Blasting array into hash ??? (Larry Rosler)
Re: Blasting array into hash ??? (Larry Rosler)
Re: Blasting array into hash ??? (Larry Rosler)
Cant find file (Brian)
Dynamic Loading chenlock99@yahoo.com
Re: FAQ 4.68: How do I handle binary data correctly? (Ronald J Kimball)
Re: File Opening Problem (Ronald J Kimball)
Re: HELP - Extracting META KEYWORDS script not working (Larry Rosler)
Re: HELP - Extracting META KEYWORDS script not working (Larry Rosler)
Re: If possible, then how do I remove the last line in (Larry Rosler)
Re: Perl "constructors" armchair@my-dejanews.com
Re: Perl "constructors" armchair@my-dejanews.com
Perl, Oracle8i and CLOBs <wvw@fred.net>
Re: perltootc - OO Tutorial for Class Data in Perl <metcher@spider.herston.uq.edu.au>
Re: perltootc - OO Tutorial for Class Data in Perl <metcher@spider.herston.uq.edu.au>
Re: Question about -T (Ronald J Kimball)
Re: radio buttons... <seugenio@man.amis.com>
Re: Seek on STDIN? (Ronald J Kimball)
Re: su and perl <wemuis@itwol.bhp.com.au>
Re: things that make you go ICK! (Ronald J Kimball)
Re: TROLL ALERT (Re: Perl "constructors") armchair@my-dejanews.com
Re: undef of namespaces (Ronald J Kimball)
Re: Y2K. localtime(time) (Ronald J Kimball)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 May 1999 03:54:35 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: appending a box form
Message-Id: <slrn7k71oi.t4.efflandt@efflandt.xnet.com>
On 18 May 1999 23:15:43 GMT, Twarren10 <twarren10@aol.com> wrote:
>I am a relatively new Pearl programmer working on a search cgi. I call the
>search cgi from a html form message=post. It's all working, but what I need to
>know is, is there any way when the search results links come up, to place
>(append) the form box to the bottom of the search results with an option to
>search again? I've tried everything I can think of, what am I missing. I even
>tried using the print statements to print in the form, but the result was
>nothing showed up. Can anyone help me on this? Thanks.
See 'perldoc CGI' and if your CGI.pm is up to date, the first thing you
see will be an example of how to have a form reproduced along with the
posted data.
--
David Efflandt efflandt@xnet.com
http://www.xnet.com/~efflandt/
------------------------------
Date: 20 May 1999 03:57:22 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: backspace in file output question
Message-Id: <slrn7k71to.t4.efflandt@efflandt.xnet.com>
On Tue, 18 May 1999 12:48:45 GMT, papakee@aol.com <papakee@aol.com> wrote:
>I wrote my first perl program which simply
>takes input from STDIN and printf's it to
>an output file. If I have to backspace to
>correct a typo, the offending characters and the
>backspace appears in the output file also.
>This is on a DOS/Win version of perl. Anyone
>know how to process the backspace before it
>appears in the file?
>
>Thanks in advance: Tim
>papakee@aol.com
What OS? You might try the Delete key and see if it gets rid of those
pesky ^H's and errors.
--
David Efflandt efflandt@xnet.com
http://www.xnet.com/~efflandt/
------------------------------
Date: Thu, 20 May 1999 01:34:06 GMT
From: mc_david@my-dejanews.com
Subject: Binary image file reading or $x as a number.
Message-Id: <7hvoqf$9a$1@nnrp1.deja.com>
I can't seem to find anywhere in the reference books that I'm using (I'm
looking in O'Reilly) how I can convert a character that I got with getc
to a binary (or hex) type.
I am reading a binary image char by char and trying to convert each char
to a hex text representation.
I'm sure there is some easy way to do it, and I apologize for being a
newbie, but when I have a character via $byteMe = getc INFILE I get an
error when I try to print it as a hex number via print sprintf "%x",
$byteMe. The error is: Argument "x" isn't numeric in sprintf ...
So how do I make it numeric; or alternatively how should I read a file
char by char so that I can work with each char as a hex value.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Thu, 20 May 1999 02:05:21 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Binary image file reading or $x as a number.
Message-Id: <slrn7k6v1r.5n.alastair@calliope.demon.co.uk>
mc_david@my-dejanews.com <mc_david@my-dejanews.com> wrote:
>
>So how do I make it numeric; or alternatively how should I read a file
>char by char so that I can work with each char as a hex value.
I'd look into the 'pack' and 'unpack' functions.
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Thu, 20 May 1999 01:59:58 GMT
From: armchair@my-dejanews.com
Subject: Re: Binary image file reading or $x as a number.
Message-Id: <7hvqau$15r$1@nnrp1.deja.com>
In article <7hvoqf$9a$1@nnrp1.deja.com>,
mc_david@my-dejanews.com wrote:
> I can't seem to find anywhere in the reference books
> that I'm using (I'm
> looking in O'Reilly) how I can convert a character that I got
> with getc
> to a binary (or hex) type.
>
> I am reading a binary image char by char and trying to
> convert each char
> to a hex text representation.
>
> I'm sure there is some easy way to do it, and I apologize for being a
> newbie, but when I have a character via $byteMe = getc INFILE I get an
> error when I try to print it as a hex number via print sprintf "%x",
> $byteMe. The error is: Argument "x" isn't numeric in sprintf ...
>
> So how do I make it numeric; or alternatively how should I read a file
> char by char so that I can work with each char as a hex value.
There may be better ways, but this seems to work:
my $byteMe = getc INFILE;
my $byte2 = unpack("C",$byteMe);
print sprintf "%x", $byte2;
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 19 May 1999 18:40:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Blasting array into hash ???
Message-Id: <MPG.11ad07ce39fe9b94989aba@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37435D11.8AA0A35D@mediaone.net> on Wed, 19 May 1999 19:53:37
-0500, Michael D. Schleif <mds-resource@mediaone.net> says...
...
+ If I have a simple array (@nodes), I know that I can blast it into an
+ hash in several ways:
+
+ [1] @nodes{@nodes} = ();
+
+ Now, I can test for existence of an element by name.
Yes.
+ [2] @nodes{@nodes} = (1) x @nodes;
+
+ Now, I can use Boolean tests for existence.
Yes.
+ [3] But, suppose that I want to assign another constant array as the
+ value to
+ each key in the new hash. Call this initialization of HOL . . .
+
+ for (@nodes) {
+ $nodes{$_} = ([1, 0, 1, 0]);
+ }
+
+ Although this works, it can be slower than necessary.
Yes.
+ [4] Why *doesn't* this do what I thought it would do?
+
+ @nodes{@nodes} = ([1, 0, 1, 0]) x @nodes;
+
+ When complete, the following makes it look like I expect:
+
+ for (keys %nodes) {
+ print "$_ : @{ $nodes{$_} }\n";
+ }
You only think this is right. There is only one anonymous array, and
all the hash elements refer to it. (I was caught on this in this
newsgroup a while ago. :-)
+ [5] However, try this:
+
+ my @nodes = qw(mds abc 123 xyz 987); # sample data
+ @nodes{@nodes} = ([1, 0, 1, 0]) x @nodes;
+ @{ $nodes{987} }[3]++;
+ for (keys %nodes) {
+ print "$_ : @{ $nodes{$_} }\n";
+ }
+
+ Wow! Change one (1) instance of the fourth element of one row and
+ the fourth element of every row is also changed!
+
+ Clearly, I *do not* understand what these tricky array to hash
+ conversions actually do.
+
+ Who can explain this in simple terms?
See above.
+ [6] I have settled on map, for now:
+
+ %nodes = map{ $_, ([1, 0, 1, 0]) } @nodes;
+
+ Is this the best solution? Is this the fastest, most efficient?
This would be better, because it still uses the speedy hash slice:
@nodes{@nodes} = map [ 1, 0, 1, 0 ] => 1 .. @nodes;
General principle to produce a list of $n items:
(EXPR) x $n -- EXPR evaluated once and repeated $n times.
map EXPR => $n -- EXPR evaluated $n times.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 18:58:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Blasting array into hash ???
Message-Id: <MPG.11ad0c1d94ab5f81989abf@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37435D11.8AA0A35D@mediaone.net> on Wed, 19 May 1999 19:53:37
-0500, Michael D. Schleif <mds-resource@mediaone.net> says...
...
+ If I have a simple array (@nodes), I know that I can blast it into an
+ hash in several ways:
+
+ [1] @nodes{@nodes} = ();
+
+ Now, I can test for existence of an element by name.
Yes.
+ [2] @nodes{@nodes} = (1) x @nodes;
+
+ Now, I can use Boolean tests for existence.
Yes.
+ [3] But, suppose that I want to assign another constant array as the
+ value to
+ each key in the new hash. Call this initialization of HOL . . .
+
+ for (@nodes) {
+ $nodes{$_} = ([1, 0, 1, 0]);
+ }
+
+ Although this works, it can be slower than necessary.
Yes.
+ [4] Why *doesn't* this do what I thought it would do?
+
+ @nodes{@nodes} = ([1, 0, 1, 0]) x @nodes;
+
+ When complete, the following makes it look like I expect:
+
+ for (keys %nodes) {
+ print "$_ : @{ $nodes{$_} }\n";
+ }
You only think this is right. There is only one anonymous array, and
all the hash elements refer to it. (I was caught on this in this
newsgroup a while ago. :-)
+ [5] However, try this:
+
+ my @nodes = qw(mds abc 123 xyz 987); # sample data
+ @nodes{@nodes} = ([1, 0, 1, 0]) x @nodes;
+ @{ $nodes{987} }[3]++;
+ for (keys %nodes) {
+ print "$_ : @{ $nodes{$_} }\n";
+ }
+
+ Wow! Change one (1) instance of the fourth element of one row and
+ the fourth element of every row is also changed!
+
+ Clearly, I *do not* understand what these tricky array to hash
+ conversions actually do.
+
+ Who can explain this in simple terms?
See above.
+ [6] I have settled on map, for now:
+
+ %nodes = map{ $_, ([1, 0, 1, 0]) } @nodes;
+
+ Is this the best solution? Is this the fastest, most efficient?
This would be better, because it still uses the speedy hash slice:
@nodes{@nodes} = map [ 1, 0, 1, 0 ] => 1 .. @nodes;
General principle to produce a list of $n items:
(EXPR) x $n -- EXPR evaluated once and repeated $n times.
map EXPR => 1 .. $n -- EXPR evaluated $n times.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 19:49:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Blasting array into hash ???
Message-Id: <MPG.11ad17fac27510df989ac0@nntp.hpl.hp.com>
In article <MPG.11ad0c1d94ab5f81989abf@nntp.hpl.hp.com> on Wed, 19 May
1999 18:58:25 -0700, Larry Rosler <lr@hpl.hp.com> says...
...
> General principle to produce a list of $n items:
>
> (EXPR) x $n -- EXPR evaluated once and repeated $n times.
>
> map EXPR => 1 .. $n -- EXPR evaluated $n times.
For those who like symmetry, we can use instead of a sequence of
integers a picket fence:
map EXPR => (1) x $n
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 17:51:27 GMT
From: pontz@channel1.com (Brian)
Subject: Cant find file
Message-Id: <3742f80f.4704504@news1.channel1.com>
Hello
Anyone know perl can see some files but cant find others? I have a
perl script that does random passwords. The problem is that this file
$log='log.file';
perl can see and open and everything but this one
$ranpass='pass.words';
perl cant find it even though its in the same directory as the other
one. But if I open it like this
open(RANDOM, "pass.words") || die "Couldnt open file:$!";
it works fine. Why doesnt it work like this
open(RANDOM, "$ranpass") || die "Couldnt open file:$!";
Brian
Windows 95
32-bit extensions and a graphical shell for a 16-bit
patch to an 8-bit operating system originally
coded for a 4-bit microprocessor, written by a 2-bit
company that can't stand for 1 bit of competition.
------------------------------
Date: Wed, 19 May 1999 14:42:04 GMT
From: chenlock99@yahoo.com
Subject: Dynamic Loading
Message-Id: <3742c903.9825945@news.mindspring.com>
I have problem loading DBI module when I tried to run my script. It
complaint about dynamic loading not available in this perl. I have to
either to rebuild the new perl or statically link the module to it. I
have tried rebuilt the perl with dynamic loading but it failed, seems
like my complier doesn't support. Any idea how to resolve this ?
Thanks.
------------------------------
Date: Wed, 19 May 1999 23:19:01 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: FAQ 4.68: How do I handle binary data correctly?
Message-Id: <1ds2lyz.q4n52e18hium8N@p18.block1.tc4.state.ma.tiac.com>
Larry Rosler <lr@hpl.hp.com> wrote:
> In article <3742da5c@cs.colorado.edu> on 19 May 1999 09:35:56 -0700, Tom
> Christiansen <perlfaq-suggestions@perl.com> says...
[...]
> > On some legacy systems, however, you have to play tedious games
> > with "text" versus "binary" files. See the section on "binmode" in
> > the perlfunc manpage, or the upcoming the perlopentut manpage
> > manpage.
>
> <RANT>
>
> I guess I'll keep harping on this until the Perl writers and teachers
> change their attitudes and their approach to this question. The proper
> -- dare I say 'mature' -- answer is:
>
> Use the "binmode" function immediately after opening the file.
I agree. Perl is a multi-platform programming language. The
documentation should be multi-platform as well.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
perl -le 'print "Just another \u$^X hacker"'
------------------------------
Date: Wed, 19 May 1999 23:19:03 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: File Opening Problem
Message-Id: <1ds2mfk.jia8w01hehgvoN@p18.block1.tc4.state.ma.tiac.com>
Brian Frutchey <frutchey@usc.edu> wrote:
> But suddenly, all of my scripts which use
> write mode
> are giving me the error "Insecure dependency in open while running
> setgid at
> .../.../... line ...".
When you get an error message in Perl you are unsure about, you should
refer to the perldiag documentation:
Insecure dependency in %s
(F) You tried to do something that the tainting mechanism didn't
like. The tainting mechanism is turned on when you're running setuid
or setgid, or when you specify -T to turn it on explicitly. The
tainting mechanism labels all data that's derived directly or
indirectly from the user, who is considered to be unworthy of your
trust. If any such data is used in a "dangerous" operation, you get
this error. See in the perlsec manpage for more information.
The perlsec documentation will tell you how to untaint your data.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 19 May 1999 18:48:54 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: HELP - Extracting META KEYWORDS script not working
Message-Id: <MPG.11ad09dd1adb777b989abb@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <taylorFC0AJ2.K3I@netcom.com> on Thu, 20 May 1999 00:54:38
GMT, Dave Taylor <taylor@netcom.com> says...
> I'm trying to write a Perl script that will let me feed in an arbitrary
> page of HTML and pull out the CONTENTS of the meta keyword tag. The
> line will look like:
>
> <META NAME="keywords" CONTENT="x,y,z">
...
> $buf =~ /name\s*=\s*"keywords"\s+content\s*=\s*=\s*"([^"]*)"/oi;
I see two successive equals signs '=\s*=' in the regex, but not in the
HTML tag. D'oh!
(The /o is not needed, as there is no interpolation into the regex.)
> # print the matched buffer value
>
> print "\n$1\n\n";
Always check for a successful match before using a captured vaariable
such as $1.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 18:57:21 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: HELP - Extracting META KEYWORDS script not working
Message-Id: <MPG.11ad0bd73be21948989abd@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <taylorFC0AJ2.K3I@netcom.com> on Thu, 20 May 1999 00:54:38
GMT, Dave Taylor <taylor@netcom.com> says...
> I'm trying to write a Perl script that will let me feed in an arbitrary
> page of HTML and pull out the CONTENTS of the meta keyword tag. The
> line will look like:
>
> <META NAME="keywords" CONTENT="x,y,z">
...
> $buf =~ /name\s*=\s*"keywords"\s+content\s*=\s*=\s*"([^"]*)"/oi;
I see two successive equals signs '=\s*=' in the regex, but not in the
HTML tag. D'oh!
(The /o is not needed, as there is no interpolation into the regex.)
> # print the matched buffer value
>
> print "\n$1\n\n";
Always check for a successful match before using a captured vaariable
such as $1.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 18:18:21 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: If possible, then how do I remove the last line in a text file via CGI? (txt)
Message-Id: <MPG.11ad02b023d59fda989ab9@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <t%H03.778$kw.30120@dfiatx1-snr1.gtei.net> on Wed, 19 May
1999 23:42:17 GMT, limbeck <limbeck@gte.net> says...
> I use a script that adds one new line to a text file every time it is
> executed via a form. I need it to remove the last line in that text file,
> however, every time it adds a new one to the top (executes the script via
> form).
>
> So, how do I remove just the last line of a text file in CGI, if this is
> possible?
CGI means Common Gateway Interface. It is a specification, not a
programming language.
> Please forgive my ignorance... I know HTML well, and understand the concept,
> but I still do *not* actually know CGI fully. I need to get a book some
> time. :)
This has nothing to do with HTML or CGI. It is, for a change, really a
Perl question! And it is a Frequently Asked Question, at that.
perlfaq5: "How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the beginning of a
file?"
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 20 May 1999 02:31:46 GMT
From: armchair@my-dejanews.com
Subject: Re: Perl "constructors"
Message-Id: <7hvs6j$2l7$1@nnrp1.deja.com>
In article <927038345.900648@localhost>,
zenin@bawdycaste.org wrote:
> armchair@my-dejanews.com wrote:
>
> :> > That is one reference per object. $self. I am aware that you can
> : have
> :> > that reference point to a data structure, which in turn can hold
> :> > references to other data structures.
>
> Your browser still can't linewrap correctly.
That's a DejaNews issue.
>
> No, it has hashes, which have the same effect for nearly all
> practical uses.
Except that they are never guaranteed to hold one field. And never
guaranteed to have any "field name" or key.
>
> : And yet is has something that is only a special symbol away
> : from being one
> : as I illustrated elsewhere:
> :
> : my #time_record
> : ( $sec,
> : $min,
> : $hour,
> : $mday,
> : $mon,
> : $year,
> : $wday,
> : $yday,
> : $isdst
> : ) = localtime(time);
>
> my %time_record;
> @time_record{qw(
> sec
> min
> hour
> mday
> mon
> year
> wday
> yday
> isdst
> )} = localtime;
>
> What's your point?
I never would have figured out the above slightly longer and more
complicated technique. And at the end of the day, you gain nothing
except slower access over a record.
>
> : And just what is the big horrid taboo about records? What is so
> : outrageous about the concept?
>
> There is none. Quite the opposite actually, as perl has built
> in support for hashs (records).
You mean hashs (maps).
>
> : What would happen to Perl programmers if you had my record ( $name,
> : ^$address, $city, $state, $zip, $ref_other ); in the
> : language?
>
> What would it gain over a hash? Hint: nothing.
Matter of opinion. A hash has an unknown amount of fields, 0 to n, and
they can be misassigned - STATE key was put in as STATES. Record has a
fixed set of fields that are always present, with a guaranteed name.
> : $s = "$n zots"; # combine string var with string literal,
> : # assign result to string
>
> Correct
> : I am not looking for a separate type for short, int, double,
> : just one
> : that holds numeric values.
>
> my $n;
my $n = "zenin";
>
> if you want to be anal and blow chunks if anyone ever
> tries to put
> anything "non-numeric" into $n, make yourself a pretty
> little tied scalar class.
Or use something called Fields.pm.
>
> : What technique do you use to validate that the $var you
> : as being
> : passed is actually a numeric value?
>
> It depends; Define numeric. Decimal, float? Also note that in perl
> "123 foo bar dog" == 123. Of course under -w you'll get a warning
> if you do that, however if $n = '0 but true' you won't. It will all
> "work" however.
Perl only has one numeric and that consists of numbers, whether whole or
real. My question is rhetorical as I have seen both the FAQ (uses
regular expressions) and the "man page" where they show a technique
(discussed in another post) where they add "this will cause warnings if
you have the -w set." Since -w is highly recommended by people here,
that "manual page" should be changed to show the FAQ technique.
>
> If you want to be anal, use a regexp to check it.
>
> There is a method to this madness however, that you don't
> have the experience to understand as yet.
I'm just glad I don't understand your continued use of the term anal,
and hope I never do.
> : I am not sure how showing me code that illustrates how dollar
> : sign does
> : not differentiate the type of the variable, helps your case.
>
> We're still waiting for you to make a valid case at all, what's
> the difference?
>
sub a {
my $scalar = $_[0];
}
what does $scalar contain zenin, number, string or reference?
> : will even praise it. But, the $ type symbol is obviously ambiguous -
> : string? number? reference to another variable?
>
> It's a single value, which is why we call it a
> "scalar" value. It's not ambiguous at all.
>
my $scalar = myObject->ReturnSomething();
what does $scalar hold at this moment zenin, number, string or
reference?
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Thu, 20 May 1999 02:51:00 GMT
From: armchair@my-dejanews.com
Subject: Re: Perl "constructors"
Message-Id: <7hvtak$387$1@nnrp1.deja.com>
In article <yliu9r3qlx.fsf@windlord.stanford.edu>,
Russ Allbery <rra@stanford.edu> wrote:
> armchair <armchair@my-dejanews.com> writes:
>
> > But since Perl does not have what C++ calls "function
> > overloads" where
> > the same name can be used for different functions, who each
> > differ by
> > input parameter types
>
> Er... of course it does. That's why Perl puts all of the arguments
> in @_
> and lets you do whatever you want with them, including
> completely changing
> the behavior of the sub if there are three arguments instead of
> two, or if
> the arguments are of different types.
>
> I write Perl code like that all the time.
With function overloading, you can add new parameter lists and leave old
code completely untouched and unmodified. It also makes you code more
modular. And someone has mentioned a Perl module that somehow allows
this.
>
> > I think there is some benefit to be looking at code and
> > instantly see
> > that a method is a constructor, or not.
>
> Why? Seriously.
The quicker you can see what someone's code is doing, the quicker you
can get on to making your changes. As much as I hate a standard being
different from what I want to use, the more things are standardized the
easier it becomes for people to comprehend each other's code. That of
course does not mean that there cannot be complete comprehension of all
code given infinite coding styles. But it does say that the
comprehension will require less effort and occur faster. And could
become significant if you have to look at large amounts of someone
else's code.
>
> > I am using size of the project to try and amplify a value or
benefit.
>
> I don't think that's a very good technique. The things that work
> well for
> small projects don't necessarily work better for big projects,
> and there
> are things one does for big projects that would be a disaster in small
> projects. I think small projects are completely different beasts in a
> more fundamental way than that.
Regardless of if there are some cases where the above is true,
if you had to look over a large amount of Perl programs that I had
written, you would be muttering over and over again - "this is C code,
this guy doesn't know how to code in Perl. What's he doing now....".
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 19 May 1999 22:41:59 -0400
From: wvw <wvw@fred.net>
Subject: Perl, Oracle8i and CLOBs
Message-Id: <37437677.FCC@fred.net>
Greetings,
I really need some help getting perl to insert and fetch CLOB's; I have
the latest and greatest DBI/DBD's from CPAN; I've no problem with other
types ... just these durn CLOB's. The workaround I'm using now is to
call a stored procedure which reads a file and does an insert ... no
problem ... just cumbersome.
Short samples of inserts and fetches would be greatly appreciated.
Thanks,
wvw@fred.net
------------------------------
Date: Thu, 20 May 1999 12:31:15 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: perltootc - OO Tutorial for Class Data in Perl
Message-Id: <374373F3.975A4BAE@spider.herston.uq.edu.au>
"David L. Cassell" wrote:
>
> [courtesy cc to poster]
>
> Jaime Metcher wrote:
> >
> > [some interesting addenda heartlessly snipped]
> >
> > refugees from more patriarchal languages...
>
> Ooh. Nice. Mind if I quote you on this someday?
>
Sure. Do it in alt.feminism and get some brownie points.
--
Jaime Metcher
------------------------------
Date: Thu, 20 May 1999 13:27:40 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: perltootc - OO Tutorial for Class Data in Perl
Message-Id: <3743812C.1A6F1984@spider.herston.uq.edu.au>
Andrew Allen wrote:
>
<snip>
> : rise from it's grave and distract the Perl programmmer. A phatic mention of
> : autovivification here might be kindly.
>
> Huh?
>
> phat-ic: (n) : of, relating to, or being speech used for social
> or emotive purposes rather than for communicating information.
>
> Why would perl docs have "social or emotive purposes"? Perhaps
> parenthetical? Also autovivification is (again) the wrong term.
>
> Andrew
from perlfaq4:
Then that element ``autovivifies''; that is, it springs into existence whether
you store something there or not.
from the blue camel:
Uninitialized variables automatically spring into existence as needed.
from perlref:
This is one of the cases we mentioned earlier in which references could spring
into existence when in an lvalue context...This process is called
autovivification.
...plus general usage on clp* and p5p. I'll concede the point -
autovivification is the wrong term, despite the provocatively worded excerpt
from the camel. Perhaps I could amend my paragraph to:
: Unless you also declare %ClassData as a lexical in the derived class's file
: scope, it will spring into existence as a package variable in the derived
class's
: package.
This paragraph would be phatic because it doesn't add any information to the
documentation set. We can find this out for ourselves, but it makes us feel all
warm and gooey when the documenter throws us a bone and saves us even a little
hair-pulling. OK, maybe this use of 'phatic' is a little tongue-in-cheek.
Andrew 2, Jaime 0.
--
Jaime Metcher
------------------------------
Date: Wed, 19 May 1999 23:19:06 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Question about -T
Message-Id: <1ds2n8a.1gbyynd15o91k3N@p18.block1.tc4.state.ma.tiac.com>
Greg Coit <gbc1@axe.humboldt.edu> wrote:
> After reading perlsec, I think
> the problem is that one of these directories is writable by other than
> the owner or group:
>
> $ENV{"PATH"} = "/usr/local/bin:/usr/bin:/bin:/usr/sbin:.";
> delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
>
> Does my guess at the problem seem correct? If so, I don't have any
> control over these directories. Any way of temporarily disabling -T for
> this subroutine? Any other way around this?
Why don't you just set $ENV{PATH} to "", and specify the full path to
your program in the open() statement?
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 20 May 1999 03:37:58 GMT
From: "Sheila Eugenio" <seugenio@man.amis.com>
Subject: Re: radio buttons...
Message-Id: <01bea272$0d435300$2bbe10ac@amipnet>
As a sample:
my $sth = $dbh->prepare(qq{
select criteria, code
from rj_ref
where area = '$username'}) || die "Can't prepare statement: $DBI::errstr";
my ($criteria, $code);
$sth->bind_columns(undef, \($criteria, $code));
while ($sth->fetch){
print "<tr><td width=100><div align=center><input type=radio name=area
value=$code></div></td><td width=150><div
align=left>$criteria</div></td></tr>\n";
}
Ashwini Nagaraj <anagaraj@ford.com> wrote in article
<3742EA07.410ECE96@ford.com>...
> Hi All,
>
> Can any one tell if it is possible to print radio buttons while fetching
> rows in a DBI query. I am doing a customer satisfaction survey and all
> the questions are printed out from the query through DBI. So, after
> fetching each question I need to put radio buttons for rating that
> particular question. I am using Perl-CGI. Any kind of help is greatly
> appreciated.
>
> Ash
>
------------------------------
Date: Wed, 19 May 1999 23:19:08 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Seek on STDIN?
Message-Id: <1ds2o2a.ugewsvr4t3ukN@p18.block1.tc4.state.ma.tiac.com>
Al Sharka <asharka@my-dejanews.com> wrote:
> open(README, "zcat $ARGV[0] |") || die "Couldn't fork: $!\n";
>
> $RECORDSIZE=68;
> $TEMPLATE="i H14 i a5 s H16 H14 H4 H14 H16 H14 H14";
>
> #this doesn't work to skip records. What's wong here?
> seek(README, $RECORDSIZE * $ARGV[1], 0) if $ARGV[1];
If you want to know what's wrong, ask.
if ($ARGV[1]) {
seek(README, $RECORDSIZE * $ARGV[1], 0)
or die "Can't seek: $!\n";
}
which will die with the message:
Can't seek: Illegal seek
You can't seek on a pipe.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 20 May 1999 11:13:00 +1000
From: Steve Muir <wemuis@itwol.bhp.com.au>
Subject: Re: su and perl
Message-Id: <3743619C.7770C00C@itwol.bhp.com.au>
Hi ...
Thanks for the reply....
Yes, I am aware of the basic security risk but I need to able to
automate an su to another user.
I would like to do it by passing the user's password via a web page (ie
cgi) but the su program doesn't seem to like this either.
Basically what I'm trying to do is run a program which is owned by (and
can only be run by) userA from a web page. What I'd like to do is have a
form which asks the user for his name and email (required for logging
and where to send the program's results) and the password of userA
(hidden)...
Does any of this make sense.
Any ideas ?
Steve
Jean-Louis Leroy wrote:
>
> In article <37429190.B8F830CB@itwol.bhp.com.au>, Steve Muir wrote:
>
> > $ suprog -u <username> -p <password>
>
> Are you aware that any user will be able to read the
> <username> and <password> by means of a simple `ps -ef'?
>
> Jean-Louis Leroy
> http://ourworld.compuserve.com/homepages/jl_leroy
--
=======================================
Steve Muir
BHP IT Network Management
Email: muir.steve.sg@bhp.com.au
wemuis@itwol.bhp.com.au
sgm04@uow.edu.au
=======================================
------------------------------
Date: Wed, 19 May 1999 23:19:11 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: things that make you go ICK!
Message-Id: <1ds2pmy.cr6hb11n6mtw7N@p18.block1.tc4.state.ma.tiac.com>
S Starre <sstarre@my-dejanews.com> wrote:
> Oh I love this...
>
> Illegal character \015 (carriage return) at ..//CGI.pm line 1.
> (Maybe you didn't strip carriage returns after a network transfer?)
> BEGIN failed--compilation aborted at ./mpost.cgi line 30.
>
> I tried to take your advice (Larry R & Tom C) and use CGI.pm- and I get
> this sucky result.. As usual, the unix sysadmin, in true unix sysadmin
> form, says "it's no problem just turn off warnings"...
That does indeed make me go ICK.
Your sysadmin is clueless. That is not a warning; that is a compilation
error. Warnings are irrelevant here.
Tell your sysadmin to install CGI.pm properly.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
perl -e 'for(@ARGV){require $_;print "$_\n $INC{$_}\n"}' CGI.pm
------------------------------
Date: Thu, 20 May 1999 02:42:28 GMT
From: armchair@my-dejanews.com
Subject: Re: TROLL ALERT (Re: Perl "constructors")
Message-Id: <7hvsql$328$1@nnrp1.deja.com>
In article <927142546.431844@localhost>,
zenin@bawdycaste.org wrote:
> armchair@my-dejanews.com wrote:
> >snip<
> : And the documentation does still have me baffled. For instance:
> :
> : "localtime - convert UNIX time into record or string using local
time"
> :
> : Maybe you can explain why they are using the term record in Perl
> : documentation?
>
> That's easy, it doesn't:
>
> $ perldoc -tf localtime | grep record | wc
> 0 0 0
> $ perldoc -tf localtime
>
> localtime EXPR
> Converts a time as returned by the time function to a 9-element
> array with the time analyzed for the local time zone. Typically
> used as follows:
>
> # 0 1 2 3 4 5 6 7 8
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
> localtime(time);
> >>SNIP<<
>
> Ok, so maybe it should say "list" instead of "array", BFD.
>
Well, you may not believe me on this, but I cut and paste my text from
an entry in the "online manual" that you can get to via www.perl.com.
If you follow link path
"Documentation->individually->Supporting->perlfunc->localtime"
you now end up at:
ftp://ftp.rge.com/pub/languages/perl/doc/manual/html/pod/perlfunc/localt
ime.html
where it used to say (and I actually believe the address has changed
from a <something>.ca/.../ ) what was diplayed in my post.
It now uses the word 9-element array. You are correct in pointing out
that the example appears to show what seems to be normally referred to
as a list.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 19 May 1999 23:19:16 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: undef of namespaces
Message-Id: <1ds2ptw.n2ujnw1atpld9N@p18.block1.tc4.state.ma.tiac.com>
Marc Dietrich <marc.dietrich@physik.uni-giessen.de> wrote:
> can someone please tell me, how to undefine complete namespaces (like
> Q::). I have some variables in the Q namespace ($Q::a, @Q::b, ...) and
> undef(%Q::) doesn't work.
DB<1> $Q::bar = 'a'
DB<2> V Q
$bar = 'a'
DB<3> x %main::Q::
0 'bar'
1 *Q::bar
DB<4> undef %Q::
DB<5> V Q
DB<6> x %main::Q::
empty array
DB<7>
Works for me. What happened when you tried it?
--
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
perl -e'for(sort keys%main::){print if $$_ eq 1}
' -s -- -' Just' -' another ' -'Perl ' -'hacker
' http://www.tiac.net/users/chipmunk/ [rjk@linguist.dartmouth.edu]
------------------------------
Date: Wed, 19 May 1999 23:19:17 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Y2K. localtime(time)
Message-Id: <1ds2qvd.w2rqomrhaoa7N@p18.block1.tc4.state.ma.tiac.com>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> Because they can't fricking read, and even if they can, it never occrus
> to them to try. It's the Microsoft way.
Nice try, Tom, but you apparently never read the original post... (Or
perhaps it never occured to you to try? ;)
>> environment:
>> Solaris 2.6, Perl 5.005_02
What was that about this being "the Microsoft way"?
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"Remember, Perl doesn't write bad programs; programmers do."
------------------------------
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 5730
**************************************