[17274] in Perl-Users-Digest
Perl-Users Digest, Issue: 4696 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 23 09:05:32 2000
Date: Mon, 23 Oct 2000 06:05:11 -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: <972306311-v9-i4696@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 23 Oct 2000 Volume: 9 Number: 4696
Today's topics:
- Major automotive website enquiries@seriousmonkey.com
Alphanumeric sorting of hashes <ra_jones@my-deja.com>
c-funktion Clear Screen?? <brian@reichholf.at>
Re: c-funktion Clear Screen?? nobull@mail.com
Re: c-funktion Clear Screen?? <gellyfish@gellyfish.com>
Re: Can perl code be sandboxed? (M.J.T. Guy)
Examples of GD::Graph3d <m.gabryelski@psi-net.pl>
Re: File locking <bart.lateur@skynet.be>
Re: Help with array concatenation <pdcawley@bofh.org.uk>
Re: here and filehandle <jeffp@crusoe.net>
Re: local file handle <MY_FILE> mgopi@csa.iisc.ernet.in
Net::FTP->ls(".doh"); <bcaligari@my-deja.com>
newbie cgi examples <joe@benburb.demon.co.uk>
Re: newbie cgi examples <anders@wall.alweb.dk>
On being Schwartz.. (was Re: newbie cgi examples) (Randal L. Schwartz)
Re: Out of Memory - ActivePerl 5.6/Win98 SE 192MB RAM <krahnj@acm.org>
Passing a hash to a subroutine <bruce_phipps@my-deja.com>
Re: Passing a hash to a subroutine <mauldin@netstorm.net>
Re: Passing a hash to a subroutine (Bernard El-Hagin)
Re: Passing a hash to a subroutine <gellyfish@gellyfish.com>
Re: Passing a hash to a subroutine <bruce_phipps@my-deja.com>
Re: Perl 5.005 or 5.6? <bart.lateur@skynet.be>
Re: Perl for PalmOS? (Tramm Hudson)
Perl:socket connection port 23 flam73@my-deja.com
Re: Perl:socket connection port 23 <bruce_phipps@my-deja.com>
Re: Perl:socket connection port 23 <gellyfish@gellyfish.com>
Re: POV-Ray file parsing, digestion, and excretion? <simon.andrews@bbsrc.ac.uk>
Redirect-mailto: Trick -- "prevents spider spam" james_thornton@my-deja.com
regular expression joelyhughes@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 22 Oct 2000 13:33:45 +0000
From: enquiries@seriousmonkey.com
Subject: - Major automotive website
Message-Id: <8t1bdp$mqa$101@lure.pipex.net>
seriousmonkey.com is set to revolutionise the global automotive
industry with a wide range of genuinely groundbreaking and innovative
Internet services benefiting business and consumers alike.
In order to support the hyper-growth expansion of our global operations,
seriousmonkey.com will shortly be looking for a number of high-calibre,
professional candidates to join our fast-paced and dedicated teams in
London and the Republic of Ireland.
To visit seriousmonkey.com or view our online job vacancies, go to
http://www.seriousmonkey.com
Frank Pottle
Managing Director
seriousmonkey.com
Article posted 23/10/2000 13:33:45.520
`XP)NIplMzsn"=@6o,_AJS<_0<ks@
gw`kRpr&Kjyw;(/~Y(|Wb~01:
nQIh`G6|*J\i
1_9Z="An'
W7!Y#QaaAv8Ew2m>6RT?B~0~-8~oCP6n
7@4[.{Jp(~zGk#}~|roxry
i
$@g8^m8E;!hVD=@]7q9!{L
Y[oVs&Ln[%McOG(LMsKWuM,{NY>Ds;op.=0BezGbGlUoQqc)IU9W
wis{V>QJNZ_6s|af(~tQ!bRf4p%9HUz[)Bi[Z7avSBdW8u:?x)Hj$g
c{%B0^,`"j#2`|xd99xa]-mJYLc^IJ8*h;"a$?
FKS8^lx
-n42($cfhz5<?%Z*^N8IQnB7<<-?@ .01/BCa~^WWU~2 p;>
Rs`WTt
(Q1QS*V}nK6Par!sM^[-2b" b~'
@Fb%=QNas-b>{VgD/k4H'6A@2JXWtR^CO<
v9DC$Zg/x4EQ
/h*E w6&rH1ADuL#~"sV@=.$;|;eNrI;{_@6ZNGJ5vEn4`.
I wP@dGpZ!3kkke14'S]MR2e2xL}dtnW.
^ug=A:Yq?o13h"1t9HVl7i#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=191$sF,[Kl;Ust<7
\U'U!0du>SC_Q.\1`|dI~w{L;s7TR`b;8jy9&}
WH|eOKs$:^BTL=v6Wal#}2f?iQ/K?G}HK+:Y!b_{.5[@YsCq(VF
------------------------------
Date: Mon, 23 Oct 2000 12:43:44 GMT
From: ra jones <ra_jones@my-deja.com>
Subject: Alphanumeric sorting of hashes
Message-Id: <8t1bq0$rh7$1@nnrp1.deja.com>
The scenario:
A hash consisting of pairs of entries (standard stuff) as follows:
%hash = (
'CD3','0',
'CD25','33',
'CD8','21',
'CD66','1'
);
I need to sort it by alphanumeric rather than ASCII order (ie CD3, CD8,
CD25, CD66), so I use the command:
print "Key: $_; value: $hash{$_}\n" foreach (sort{ $a cmp $b }keys
%hash); # also tried <=> instead of cmp
But it does not work, only sorts in ASCII order (ie CD25, CD3, CD66,
CD8).
Have I made a fundamental mistake here? Using Perl 5.005.
--
ra jones (posted via deja.com)
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 23 Oct 2000 13:14:35 +0200
From: "Brian Reichholf" <brian@reichholf.at>
Subject: c-funktion Clear Screen??
Message-Id: <39f41da1$0$24820@SSP1NO25.highway.telekom.at>
All I want to do is use the C/C++ Funktion "clrscr();"
is there any possibility to do so?
------------------------------
Date: 23 Oct 2000 12:39:37 +0100
From: nobull@mail.com
Subject: Re: c-funktion Clear Screen??
Message-Id: <u9vgujss5i.fsf@wcl-l.bham.ac.uk>
"Brian Reichholf" <brian@reichholf.at> writes:
> All I want to do is use the C/C++ Funktion "clrscr();"
Really why?
See FAQ: "How can I call my system's unique C functions from Perl?"
See also FAQ: "How do I clear the screen?"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 23 Oct 2000 11:58:10 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: c-funktion Clear Screen??
Message-Id: <mJVI5.3140$7u4.60518@news.dircon.co.uk>
On Mon, 23 Oct 2000 13:14:35 +0200, Brian Reichholf Wrote:
> All I want to do is use the C/C++ Funktion "clrscr();"
>
> is there any possibility to do so?
>
see the item in perlfaq8 entitled
How do I clear the screen?
If all you want to do is clear the screen. Otherwise you will have to
write an XS wrapper for the library that the function is found in - read
the perlxs manpage for more on that.
/J\
------------------------------
Date: 23 Oct 2000 11:41:13 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Can perl code be sandboxed?
Message-Id: <8t184p$nbv$1@pegasus.csx.cam.ac.uk>
James Taylor <james@NOSPAM.demon.co.uk> wrote:
>
>Presumably you'll get plenty of people giving one line answers
>to your question in the form "perldoc Safe" but as I don't have
>perldoc on my system I won't do that. :-)
You mean you don't have Perl installed on your system ?
A correctly installed (sufficiently recent) Perl always includes perldoc.
Mike Guy
------------------------------
Date: Mon, 23 Oct 2000 13:54:16 +0200
From: "Maciej Gabryelski" <m.gabryelski@psi-net.pl>
Subject: Examples of GD::Graph3d
Message-Id: <8t18kk$fa4$1@news.tpi.pl>
Hi there.
I'm looking for examples of using GD::Graph3d (GD::Graph::bars3d in
particularly). Could I ask for anyone who has experience with this module to
show me examples of code with I can start over. I'm looking for
documentation for this module too.
Thanks in advance.
Maciej Gabryelski
m.gabryelski@psi-net.pl
------------------------------
Date: Mon, 23 Oct 2000 10:02:55 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: File locking
Message-Id: <7138vso83vhc2t7rrn2ddg93u76qifq8em@4ax.com>
Logan Shaw wrote:
>When reading, don't lock the file. Instead, check the modification
>time on the file and make sure it's in the past. Then, read the file.
>Then, check the modification time again. If it hasn't changed, great.
>
>If it has, then discard everything you've read from it.
>This is a bit of a weird approach. The advantage is that serialized
>writes are never blocked by reads. It could be useful on a system like
>a mail server, where it's probably more important for the server to be
>able to write to the mailbox in a timely fashion than for the mail
>client to be able to read from it in a timely fashion.
Yes, it is a bit weird. But, if the file is updated in very short
intervals, you can wait forever to read it properly.
But mail is appended, i.e; added to the end of the mail file, isn't it?
The old data is never overwritten? Well, make use of that. Read the file
size when you start reading. Read only that amount of bytes. Disregard
anything after that. tell(FH) can tell you if you've reached that point
yet.
--
Bart.
------------------------------
Date: 23 Oct 2000 10:47:45 +0100
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: Help with array concatenation
Message-Id: <m1d7gr7uta.fsf@rt158.private.realtime.co.uk>
"Godzilla!" <godzilla@stomp.stomp.tokyo> writes:
> Tad McClellan wrote:
>
> > Martien Verbruggen wrote:
> > > Jody Fedor wrote:
> > > > Uri Guttman wrote:
>
> > > > > this is how you learn perl.
>
> > > > I'm a learn by example type of programmer. I think I can learn
> > > > more from
>
> > [ snip list of books ]
>
> > > But Uri's point is still valid. if you really want to learn
> > > Perl, you _have_ to get comfortable with its documentation.
> > > Books get out of date. Examples are sometimes not clear enough,
> > > and only describe one particular case of the use of constructs
> > > and functions.
>
> > Books have lots of disadvantages compared to the standard docs
> > (PODs) delivered with every perl distribution:
>
>
> (snipped)
>
>
>
> Your displayed logic and rationale, McClellan, for a
> best method to learn Perl programming is to make use
> of documentation rather than textbooks, is analogous
> to instructing young students the best way to learn to
> read and write, is to make use of a dictionary rather
> than make use of instructional textbooks.
Have you actually read the perl 5 documentation set? It's not just
lists of functions, there's damn fine tutorials in there too.
--
Piers
------------------------------
Date: Mon, 23 Oct 2000 08:45:19 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: here and filehandle
Message-Id: <Pine.GSO.4.21.0010230842540.1894-100000@crusoe.crusoe.net>
[posted & mailed]
On Oct 23, Jonathan Stowe said:
>Why ? The deafult is implicit double quotes. There is only a necessity
>to supply the explicit quotes if you want to use single quotes or backticks.
Actually, you need quotes if there's whitespace involved, but check
message Pine.GSO.4.21.0010212149280.25707-100000@crusoe.crusoe.net for the
full details. Eh, whatever, I'll just plop an excerpt down here.
>Actually, here-docs are quite poorly documented. The rules on quoting
>your here-doc identifier are as follows:
>
> * the identifier needn't be quoted if it is a sequence of
> alphanumberscore characters (/[a-zA-Z0-9_]+/) and DIRECTLY follows the
> '<<' (that is, NO whitespace between '<<' and identifier)
>
> * the identifier must be quoted if there is whitespace between the '<<'
> and the identifier, or if it is NOT a sequence of alphanumberscore
> characters
There's a bit more, regarding the half-hearted interpolation of the
identifier, but that's a bit more trifling. I should really patch
perldata.pod.
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: 23 Oct 2000 10:24:36 GMT
From: mgopi@csa.iisc.ernet.in
Subject: Re: local file handle <MY_FILE>
Message-Id: <8t13l4$aps$1@news.netmar.com>
In article <8svroa$o61$1@nnrp1.deja.com>, <percy_yip@my-deja.com> writes:
>I need to use a local file handle in a function because I am doing a
>recursive function there.
>
>I tried to use
>@sub my_function {
>
>my <FILE> = @_[0]; # it doesn't work!!!!!
>..
>..
>..
>..
> my_function ( new_file );
>}
>
>For normal variables, I can use my to create local variables, but not
>for file handle. Anyone can tell me why, and how to solve this problem.
>
>Thanks in advance.
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
use local instead of my
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: Mon, 23 Oct 2000 12:15:50 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Net::FTP->ls(".doh");
Message-Id: <8t1a5j$qdd$1@nnrp1.deja.com>
after connecting and logging into an ftp server
@files = $ftp->ls('*.doh');
If no .doh files exist, @files still 1 element (undefined).
Any clues?
Brendon
++++
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 23 Oct 2000 11:55:48 +0000
From: joe mc cool <joe@benburb.demon.co.uk>
Subject: newbie cgi examples
Message-Id: <u7pukrojp7.fsf@benburb.tangent.com>
Please,
I am trying to work my way through some of the CGI examples in: Learning
Perl by Swhartz et al, particularly those on ice cream at the start of
Chp 19.
Here's my approach:
1. cut and past the code from the examples (I have the CD version of
the book).
2. save as a text file, say foo.
3. execute perl foo
Almost immediately it says: "off line mode" and starts asking me for
pairs.
I am now stuck :-( Do I enter the pairs as literally:
1 = manila CR
2 = plain CR
3 = chocolate CR
How do I get out of this loop and how do I run the final program in my
browser ?
TIA.
--
joe mc cool SMIEEE
========================================================================
Tangent Computer Research BT71 7LN (www.tangent-research.com)
voice:(44)2837-548074fax:(44)-870-0520185 The more you say the less the better.
------------------------------
Date: Mon, 23 Oct 2000 13:05:37 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: newbie cgi examples
Message-Id: <LYUI5.8550$Uy5.370215@news000.worldonline.dk>
joe mc cool wrote:
> Please,
>
> I am trying to work my way through some of the CGI examples in: Learning
> Perl by Swhartz et al, particularly those on ice cream at the start of
> Chp 19.
>
> Here's my approach:
>
> 1. cut and past the code from the examples (I have the CD version of
> the book).
>
> 2. save as a text file, say foo.
>
> 3. execute perl foo
>
> Almost immediately it says: "off line mode" and starts asking me for
> pairs.
>
> I am now stuck :-( Do I enter the pairs as literally:
>
> 1 = manila CR
> 2 = plain CR
> 3 = chocolate CR
Yes, and then hit Ctrl + D, then the program will execute and print the
output to your console. A piece of advice is, that if your script provides
a HTML form with a textfield named city, try entering "city=new york" or so
as one of the key-value pairs, etc.
Just hitting Ctrl + D to make sure your script handles an empty request
well is no bad idear either...
>
> How do I get out of this loop and how do I run the final program in my
> browser ?
You need a webserver for that, and it has to know what to do w/ your
script.
For an apache webserver:
In the config file,
* Enable ExecCGI for the directory where your scripts are located.
* Make sure the extension is set right.
Your httpd.config will have information enough for you to figure it out...
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: 23 Oct 2000 05:24:23 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: On being Schwartz.. (was Re: newbie cgi examples)
Message-Id: <m1og0bd9u0.fsf@halfdome.holdit.com>
>>>>> "joe" == joe mc cool <joe@benburb.demon.co.uk> writes:
joe> I am trying to work my way through some of the CGI examples in: Learning
joe> Perl by Swhartz et al, particularly those on ice cream at the start of
Wow. That's a spelling that I've not seen before. And believe me,
I've seen quite a few. With a first name missing a letter according
to everyone but my mom, and a last name with 7 consonants and a vowel,
the odds of EVER getting my name right are pretty low.
I suppose the artificially made-up name "Schwartz" (which my
grandfather adopted when he came to the US before the turn of this
century) is perhaps easier to spell than his original name in Germany
of "von Schraeder". I can't imagine how many "first name - last name"
forms I'd foul up with that. :)
I don't think the story of why he changed his name was ever fully
handed down. Knowing *some* of what my Dad tells me about him, he was
probably on the run from the German police. :) He was a vaudeville
performer, or maybe that was just his cover story. :)
Just another guy with Schwartz in his name not related to ANY other Schwartz's,
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 23 Oct 2000 03:23:53 -0700
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Out of Memory - ActivePerl 5.6/Win98 SE 192MB RAM
Message-Id: <39F411B9.6165670B@acm.org>
Gwyn Judd wrote:
>
> however you also need to check for erros on
> system calls (such as open()).
What are those system calls doing under the covers? ;-)
John
------------------------------
Date: Mon, 23 Oct 2000 12:11:11 +0100
From: "Bruce Phipps" <bruce_phipps@my-deja.com>
Subject: Passing a hash to a subroutine
Message-Id: <8t16dt$5r1$1@sshuraac-i-1.production.compuserve.com>
I'm trying to implement my_function(\%hash) or similar:
=========================================
#!/usr/bin/perl
%hash = (
CAO=>'Cairo',
BDP=>'Budapest',
SDY=>'Sydney'
);
&do (\%hash); #this does work as I anticipated
#&do(DAL=>'Dallas',SFO=>'San Francisco'); #this does!
sub do {
my (%places) = @_;
my ($k, $v);
while (($k, $v) = each (%places)) {
print "$k is $v\n";
}
}#end of do
===============
I get HASH...... = printed out.
What's the way to fix this?
TIA
Bruce.
------------------------------
Date: Mon, 23 Oct 2000 11:47:23 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Passing a hash to a subroutine
Message-Id: <39F424E8.CDF70CBA@netstorm.net>
Bruce Phipps wrote:
>
> I'm trying to implement my_function(\%hash) or similar:
> #!/usr/bin/perl
If you enable warnings (a good idea always)
#!/usr/bin/perl -w
perl will tell you what's wrong:
Reference found where even-sized list expected at <filename> line
<whatever>
Use of uninitialized value in concatenation (.) at <filename> line
<whatever>
> %hash = (
> CAO=>'Cairo',
> BDP=>'Budapest',
> SDY=>'Sydney'
> );
>
> &do (\%hash); #this does work as I anticipated
> #&do(DAL=>'Dallas',SFO=>'San Francisco'); #this does!
>
> sub do {
> my (%places) = @_;
> my ($k, $v);
> while (($k, $v) = each (%places)) {
> print "$k is $v\n";
> }
>
> }#end of do
You're passing a reference, but your subroutine expects an array with an
even number of elements which it will assign to the key, value pairs of
%places.
To use a reference to %hash:
do (\%hash);
sub do {
my $places = shift; # same effect as my ($places)=@_, but clearer
my ($k, $v);
print "$k is $v\n" while ($k, $v) = each (%$places);
}
To use the contents of %hash (a copy of %hash):
do (%hash);
sub do {
my (%places) = @_;
my ($k, $v);
print "$k is $v\n" while ($k, $v) = each (%places);
}
-- Jim
------------------------------
Date: 23 Oct 2000 11:56:12 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Passing a hash to a subroutine
Message-Id: <slrn8v89th.28m.bernard.el-hagin@gdndev25.lido-tech>
On Mon, 23 Oct 2000 12:11:11 +0100, Bruce Phipps
<bruce_phipps@my-deja.com> wrote:
>I'm trying to implement my_function(\%hash) or similar:
>=========================================
>#!/usr/bin/perl
>
>%hash = (
> CAO=>'Cairo',
> BDP=>'Budapest',
> SDY=>'Sydney'
> );
>
>&do (\%hash); #this does work as I anticipated
>#&do(DAL=>'Dallas',SFO=>'San Francisco'); #this does!
>
>sub do {
>my (%places) = @_;
>my ($k, $v);
>while (($k, $v) = each (%places)) {
>print "$k is $v\n";
>}
>
>}#end of do
>===============
>I get HASH...... = printed out.
You're not passing a hash to your subroutine. You're passing a hash
reference (hence the backslash before the name of the %hash variable).
Try to rewrite your sub this way:
sub Do{
my $hash_ref = shift;
while (my ($k, $v) = each %{$hash_ref}){
print "$k is $v\n";
}
}
Notice I used the name 'Do' for the sub rather than 'do'. It's always
better to use names different than keywords already used by Perl. To
read more about references I refer you (ugh!) to:
perldoc perlref
perldoc perldsc
perldoc perllol
perldoc perldata
Cheers,
Bernard
--
perl -le'
($B,$e,$r,$n,$a,$r,$d)=q=$B$e$r$n$a$r$d==~m;
\$(.);xg;print$B.$e.$r.$n.$a.$r.$d;'
------------------------------
Date: Mon, 23 Oct 2000 12:02:22 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Passing a hash to a subroutine
Message-Id: <iNVI5.3141$7u4.60518@news.dircon.co.uk>
On Mon, 23 Oct 2000 12:11:11 +0100, Bruce Phipps Wrote:
> I'm trying to implement my_function(\%hash) or similar:
> =========================================
> #!/usr/bin/perl
>
> %hash = (
> CAO=>'Cairo',
> BDP=>'Budapest',
> SDY=>'Sydney'
> );
>
> &do (\%hash); #this does work as I anticipated
> #&do(DAL=>'Dallas',SFO=>'San Francisco'); #this does!
>
> sub do {
> my (%places) = @_;
> my ($k, $v);
> while (($k, $v) = each (%places)) {
> print "$k is $v\n";
> }
>
> }#end of do
> ===============
> I get HASH...... = printed out.
> What's the way to fix this?
Yes you will do, has are passing a hash *reference* to the sub routine.
You will want to read the perlref manpage to find out more about this.
In the first instance you will want to alter the sub routine something like:
sub do
{
my ($places) = @_;
my ($k, $v);
while (($k, $v) = each (%{$places}))
{
print "$k is $v\n";
}
}
But I would highly recommend reading the perlref manpage.
/J\
------------------------------
Date: Mon, 23 Oct 2000 13:52:42 +0100
From: "Bruce Phipps" <bruce_phipps@my-deja.com>
Subject: Re: Passing a hash to a subroutine
Message-Id: <8t1cc4$2on$1@sshuraaa-i-1.production.compuserve.com>
Thanks to all who answered -- I'll try a few of the suggestions out and see
if I can follow the man pages for perlref.
Bruce
------------------------------
Date: Mon, 23 Oct 2000 09:58:11 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl 5.005 or 5.6?
Message-Id: <ee28vso9pthksm0tac9hoc3jhc6lur0qdo@4ax.com>
Marc Fearby wrote:
>So, apart from the fact that some modules might not have been recompiled
>for 5.6, it's OK?
No nasty patches, AFAIK. I haven't needed any, anyway.
>I don't want to upgrade if it's full of holes or nasty
>patches. In particular, PNGgraph hasn't isn't available on ActiveState's
>site for 5.6 yet and I really need it. I don't really want to re-write
>my code for Chart::Bars anything something else.
Huh... it looks to me like PNGgraph is just a plain Perl module. You
don't need to recompile anything. From that module anyway. But PNGgraph
is based upon GD. You do need a version of GD for 5.6, one that supports
PNG. For Win32 on Intel-compatible, you need
<http://www.activestate.com/PPMPackages/5.6/x86/GD.tar.gz>
and also, for PPM,
<http://www.activestate.com/PPMPackages/5.6/GD.ppd>
If you don't have Internet access from that PC to let the script
download the .tar.gz file, edit URL in the PPD file (the CODEBASE tag
for the OS tagged element where the attribute name is "MSWin32") so that
PPM can read it from a local copy of the file (a relative file path is
ok).
--
Bart.
------------------------------
Date: 23 Oct 2000 12:19:27 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Perl for PalmOS?
Message-Id: <8t1acf$ir1$1@sloth.swcp.com>
Tony L. Svanstrom <tony@svanstrom.com> wrote:
>Which actually would work, which it won't if you've got it on your Palm
>and you don't have a static IPaddress and a 24/7-connection to it.
I had a 24/7 connection with a static IP address for my Palm when I
used the CDPD modem. 166.135.2.151 was always my Palm Pilot Pro,
which had been modified to use an external power supply. You would
be amazed how long such a unit could run off 2700 mAh racing batteries.
Wireless access most anywhere in the country and a flat rate
service plan. What a life...
There was no Perl on the Pilot, but a proxy server would fetch
documents and rehost them on my web server. The web user agent on
the Pilot also would fetch documents via a proxy. ObPerl: CGI.pm
and LWP were used.
Tramm
--
o hudson@swcp.com hudson@turbolabs.com O___|
/|\ http://www.swcp.com/~hudson/ H 505.323.38.81 /\ \_
<< KC5RNF @ N5YYF.NM.AMPR.ORG W 505.986.60.75 \ \/\_\
0 U \_ |
------------------------------
Date: Mon, 23 Oct 2000 10:50:36 GMT
From: flam73@my-deja.com
Subject: Perl:socket connection port 23
Message-Id: <8t155r$mn8$1@nnrp1.deja.com>
Dear perl-users,
the following needs to be done:
open up a TCP/IP connection, where the source port number=23
and the destination port number=13.
Which commands/script can be used in Perl to do this?
regards,
Patrick Berkhout,
Netherlands
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 23 Oct 2000 12:07:53 +0100
From: "Bruce Phipps" <bruce_phipps@my-deja.com>
Subject: Re: Perl:socket connection port 23
Message-Id: <8t167j$sej$1@sshuraaa-i-1.production.compuserve.com>
use IO::Socket
to create a socket.
Look at man IO::Socket, I think there are some examples included.
HTH
Bruce
------------------------------
Date: Mon, 23 Oct 2000 11:54:22 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl:socket connection port 23
Message-Id: <OFVI5.3139$7u4.60518@news.dircon.co.uk>
On Mon, 23 Oct 2000 10:50:36 GMT, flam73@my-deja.com Wrote:
> Dear perl-users,
>
> the following needs to be done:
> open up a TCP/IP connection, where the source port number=23
> and the destination port number=13.
>
You'll probably want to use the module IO::Socket, also see the perlipc
manpage.
/J\
------------------------------
Date: Mon, 23 Oct 2000 12:15:43 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: POV-Ray file parsing, digestion, and excretion?
Message-Id: <39F41DDF.A7BCA6E3@bbsrc.ac.uk>
David Steuber wrote:
>
> David Steuber <nospam@david-steuber.com> writes:
>
> ' I'm wondering if anyone has done any kind of Perl code that reads,
> ' processes, and generates POV-Ray code.
>
>
> I've already gone and subscribed to comp.graphics.rendering.raytracing
> and comp.graphics.rendering.renderman.
POV-Ray actually has its own news server (news.povray.org) which
contains the group povray.programming. Whilst the Perl question is a
bit removed from their usual fodder, if someone has tried this then
they'll probably be reading that group.
Hope this helps
Simon.
------------------------------
Date: Mon, 23 Oct 2000 11:24:30 GMT
From: james_thornton@my-deja.com
Subject: Redirect-mailto: Trick -- "prevents spider spam"
Message-Id: <8t175b$o75$1@nnrp1.deja.com>
Redirect-mailto: Trick
Prevents bots from siphoning your e-mail address from your website.
This solves Jakob Nielsen's primary problem with using mailto: links on
his website.
See: http://www.jamesthornton.com/code/
-James
___________________________________________________________
Be a part of the Unified Mind at http://www.unifiedmind.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 23 Oct 2000 11:55:23 GMT
From: joelyhughes@my-deja.com
Subject: regular expression
Message-Id: <8t18va$pi4$1@nnrp1.deja.com>
Hi,
I need a regex (or more than one?) which can indentify all tags of a
certain type in a HTML doc which have a certain parameter. I then want
to be able to alter an additional parameter (inserting it if it does
not previously exist) with a new value.
I though I'd start off with somthing like
/<INPUT.*TYPE='HIDDEN'.*>/gi
Can I then pump these results into another regex which look for the
attributes?
regards
Joel
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4696
**************************************