[18351] in Perl-Users-Digest
Perl-Users Digest, Issue: 519 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 18 14:05:54 2001
Date: Sun, 18 Mar 2001 11:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984942308-v10-i519@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 18 Mar 2001 Volume: 10 Number: 519
Today's topics:
Re: ${_}name -> compile error? <bart.lateur@skynet.be>
Re: -w and use strict; <bart.lateur@skynet.be>
Re: -w and use strict; (Tad McClellan)
Re: -w and use strict; <bart.lateur@skynet.be>
about cgi <s997659@ee.cuhk.edu.hk>
Re: about cgi <dave@dave.org.uk>
Re: about cgi <godzilla@stomp.stomp.tokyo>
Re: Beginners question please help on the verge of thro <principle@seekasonic.com>
Re: Beginners question please help on the verge of thro <godzilla@stomp.stomp.tokyo>
Re: Beginners question please help on the verge of thro <uri@sysarch.com>
Re: Beginners question please help on the verge of thro <mjcarman@home.com>
Re: Beginners question please help on the verge of thro <godzilla@stomp.stomp.tokyo>
Beginners question please help on the verge of throwing <principle@seekasonic.com>
Re: Beginners question please help on the verge of thro nobull@mail.com
Re: check a pop3 mailbox without using additional modul <abcd@ntlworld.com>
Re: HTTP Client Question (John Joseph Trammell)
Re: many "used only once, possible typo" warnings in CG <bart.lateur@skynet.be>
Re: Memory and Perl <bart.lateur@skynet.be>
Moving and mkdir in Unix <milliwave@rfengineering.freeserve.co.uk>
Re: Moving and mkdir in Unix (Tad McClellan)
Re: Moving and mkdir in Unix (Jon Bell)
Re: Overloading in OO perl <taka@yarn.demon.co.uk>
Re: Print to file <bart.lateur@skynet.be>
Re: procedures to do euler path and topological sorting (Damian James)
Re: Restricting access using passwords (Damian James)
sub routine args, and using GD's newFromPng method <nospamplease@thankyou.com>
Re: sub routine args, and using GD's newFromPng method nobull@mail.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 18 Mar 2001 09:06:51 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: ${_}name -> compile error?
Message-Id: <umu8bt09kqg6gq5sb6bgro9rusm13bj2ft@4ax.com>
Jim Kroger wrote:
>I need to put the number of lines in the subject's data file into a variable,
>for example, the number of lines in anna's file into $annalines.
What's wrong with $lines{anna}?
--
Bart.
------------------------------
Date: Sun, 18 Mar 2001 09:34:32 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: -w and use strict;
Message-Id: <r909bt0bf0q434stsg6cc89a4d7enej3gl@4ax.com>
Uri Guttman wrote:
>you have not yet properly shown any evidence that -w is a pragma.
I'm sorry to chime in but if you use
use warnings;
instead of -w, that pretty much looks like a pragma to me. Lower case
name, and all.
--
Bart.
------------------------------
Date: Sun, 18 Mar 2001 08:15:13 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: -w and use strict;
Message-Id: <slrn9b9d71.jip.tadmc@tadmc26.august.net>
Bart Lateur <bart.lateur@skynet.be> wrote:
>Uri Guttman wrote:
>
>>you have not yet properly shown any evidence that -w is a pragma.
>
>I'm sorry to chime in but if you use
>
> use warnings;
>
>instead of -w, that pretty much looks like a pragma to me. Lower case
>name, and all.
But the troll was not speaking of "use warnings". It was speaking of "-w".
(Perl 4, its preferred version, doesn't have "use warnings")
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 18 Mar 2001 18:58:18 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: -w and use strict;
Message-Id: <5b1abt4kgu9gem48vqidj2ladohpo0oqau@4ax.com>
Tad McClellan wrote:
>(Perl 4, its preferred version, doesn't have "use warnings")
Have you seen any of her code lately? A lot of Perl 5 things in there.
--
Bart.
------------------------------
Date: Mon, 19 Mar 2001 00:51:47 +0800
From: Geiger Ho <s997659@ee.cuhk.edu.hk>
Subject: about cgi
Message-Id: <Pine.GSO.4.05.10103190036540.26688-100000@sparc53.ee.cuhk.edu.hk>
Dear all,
I've decided to write a web-based forum. I know i can submit a form to
a perl cgi-script. but how can i hold the data forward, say
I've a log-in html page, in which user can type in their user name and
password and press the submit button. After submitting, the login.cgi will
check $FORM{name} and $FORM{password} with a text file as database. Then
the user will direct to another html page. And in this html page he need
to submit a text by another form. The action now is taken by post.cgi. Now
i would like to generate another new html with his name and the text. My
question is: HOW CAN I IN POST.CGI TO GET BACK HIS LOGIN NAME?
Thank you very much.
Regards,
------------------------------
Date: Sun, 18 Mar 2001 17:31:46 +0000
From: Dave Cross <dave@dave.org.uk>
Subject: Re: about cgi
Message-Id: <c5s9btkcim128uosg89fd8jc6p3bdm1khv@4ax.com>
On Mon, 19 Mar 2001 00:51:47 +0800, Geiger Ho <s997659@ee.cuhk.edu.hk>
wrote:
>Dear all,
>
> I've decided to write a web-based forum. I know i can submit a form to
>a perl cgi-script. but how can i hold the data forward, say
>
> I've a log-in html page, in which user can type in their user name and
>password and press the submit button. After submitting, the login.cgi will
>check $FORM{name} and $FORM{password} with a text file as database. Then
>the user will direct to another html page. And in this html page he need
>to submit a text by another form. The action now is taken by post.cgi. Now
>i would like to generate another new html with his name and the text. My
>question is: HOW CAN I IN POST.CGI TO GET BACK HIS LOGIN NAME?
This a CGI question and would be far better asked in a CGI newsgroup.
Hear, however, are a couple of clues:
* Use hidden fields or cookies.
* Use CGI.pm instead of whatever CGI library you've got that is
filling a hash caled %FORM.
Dave...
--
<http://www.dave.org.uk> SMS: sms@dave.org.uk
<http://www.manning.com/cross/>
------------------------------
Date: Sun, 18 Mar 2001 09:50:51 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: about cgi
Message-Id: <3AB4F57B.4C9A78EE@stomp.stomp.tokyo>
Geiger Ho wrote:
> I've decided to write a web-based forum.
So write this script and test it. Should you
encounter problems you cannot solve, return
here and post pertinent questions.
(snippage)
> log-in html page
> type in their user name and password
> login.cgi will check $FORM{name} and $FORM{password}
> user will direct to another html page.
> this html page...submit a text
> another new html with his name and the text.
> HOW CAN I IN POST.CGI TO GET BACK HIS LOGIN NAME?
Write one script to accomplish all your tasks,
print entry html
username / password facility
text entry facility
submit / verification
print new html
Simple, yes?
Godzilla!
------------------------------
Date: Sun, 18 Mar 2001 18:59:40 +0000
From: Principle <principle@seekasonic.com>
Subject: Re: Beginners question please help on the verge of throwing PC out the window
Message-Id: <621abt8fqdpoa7errbq8cjddj8en4bcrkp@4ax.com>
Have solved the problem now thanks to Michael Carman and every one
else that helped me.
Thanks again its not easy as a non-programmer trying to learn
something as complex as Perl for the first time, so the advice has
been most helpful.
On Sun, 18 Mar 2001 16:11:58 GMT, Michael Carman <mjcarman@home.com>
wrote:
>Principle wrote:
>>
>> [I] would like to be able to access a sub routine in one script
>> from another script [...]
>>
>> Can i access the print_hello sub in the the admin.cgi script from
>> the search.cgi script
>
>You can, but it will require some changes. When you have functionality
>that you want to be shared amongst multiple scripts, you should break
>that out and put it into a module. You then 'use' that module in any
>scripts which need it. Minimally, it might look like this:
>
>package MyModule;
>use strict;
>require Exporter;
>
>use vars qw(@ISA, @EXPORT);
>@ISA = qw(Exporter);
>@EXPORT = qw(print_hello);
>
>sub print_hello {
> print "Hello!\n";
>}
>
>1;
>
>Then, you would add 'use MyModule' to any scripts that wanted the
>print_hello() function.
>
>That's the very brief answer; getting proficient with modules takes a
>bit longer. ;) For more information see the perlmod and perlmodlib
>manpages, and the following parts of perlfaq7:
> "How do I create a module?"
> "How do I keep my own module/library directory?"
> "How do I add the directory my program lives in to the module/
> library search path?"
>
>-mjc
------------------------------
Date: Sun, 18 Mar 2001 09:53:37 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Beginners question please help on the verge of throwing PC out the window
Message-Id: <3AB4F621.C9DC52A@stomp.stomp.tokyo>
Uri Guttman wrote:
> Godzilla! wrote:
(snipped)
> go away.
Good morning Uri! I love you too, dahhhhling!
Godzilla!
------------------------------
Date: Sun, 18 Mar 2001 17:34:06 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Beginners question please help on the verge of throwing PC out the window
Message-Id: <x73dcb56cw.fsf@home.sysarch.com>
>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
G> Principle wrote:
>> Right hers the problem i would like to be able to access
>> a sub routine in one script from another script ie i have
>> this sub in a script called admin.cgi
G> (snipped)
G> This is exceptionally difficult to accomplish and,
G> causes such a degradation of efficiency, it is not
G> a logical methodology.
wow. he explicitly asks for something and you say it is not efficient?
how off tipoci can you get. this is just like the other thread.
G> Unless you have extraordinary reasons for doing this,
G> your most wise choice is to include this needed
G> subroutine within your script in question.
he need was stated. it does not have to be extraordinary. in fact the
need is VERY ordinary and people use it ALL the time. it is called good
programming practice to allow code to be easily shared and reused. cut
and paste like you propose is more work, and not as clean.
G> This is a quick non-technical example of why you
G> don't want to do this. Using your stated parameters
G> as a guideline for exemplification, Script One needs
G> to access subroutine number_three within Script Two:
huh? the main script can LOAD all the others and call any sub it
wants. you have no concept how ot modularize things so why even try to
explain it. you don't even like it.
G> Creating a methodology to successfully accomplish
G> this will cost you a lot of script time and memory,
G> so much so, it is not a viable methodology.
hahahahahah! what a load of crapola. tell that to all the c libraries
and perl modules out in the world.
G> Alternatives would be to create a module or
G> a stand-alone script, either containing only
G> this subroutine. However, why would you do
G> this just for one fairly simple subroutine
G> as you indicate? Use of a module call or a
G> script call would only be marginally more
G> efficient than trying to call a specific
G> subroutine in another script as I exemplified.
who says his sub is simple? his EXAMPLE was simple. why show a complex
sub just to illustrate a SIMPLE question? you don't seem to be able to
extrapolate (look that word up) from a simple example of a dummy sub to
the need to share large libraries of complex code.
G> Write your subroutine into your script in need
G> to retain better speed and better efficiency,
G> in lieu of extraordinary circumstances for
G> accomplishing this another way.
wrong again. go away.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sun, 18 Mar 2001 16:11:58 GMT
From: Michael Carman <mjcarman@home.com>
Subject: Re: Beginners question please help on the verge of throwing PC out the window
Message-Id: <3AB4DEA2.9C13DBBB@home.com>
Principle wrote:
>
> [I] would like to be able to access a sub routine in one script
> from another script [...]
>
> Can i access the print_hello sub in the the admin.cgi script from
> the search.cgi script
You can, but it will require some changes. When you have functionality
that you want to be shared amongst multiple scripts, you should break
that out and put it into a module. You then 'use' that module in any
scripts which need it. Minimally, it might look like this:
package MyModule;
use strict;
require Exporter;
use vars qw(@ISA, @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(print_hello);
sub print_hello {
print "Hello!\n";
}
1;
Then, you would add 'use MyModule' to any scripts that wanted the
print_hello() function.
That's the very brief answer; getting proficient with modules takes a
bit longer. ;) For more information see the perlmod and perlmodlib
manpages, and the following parts of perlfaq7:
"How do I create a module?"
"How do I keep my own module/library directory?"
"How do I add the directory my program lives in to the module/
library search path?"
-mjc
------------------------------
Date: Sun, 18 Mar 2001 09:08:02 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Beginners question please help on the verge of throwing PC out the window
Message-Id: <3AB4EB72.F6CCF93@stomp.stomp.tokyo>
Principle wrote:
> Right hers the problem i would like to be able to access
> a sub routine in one script from another script ie i have
> this sub in a script called admin.cgi
(snipped)
This is exceptionally difficult to accomplish and,
causes such a degradation of efficiency, it is not
a logical methodology.
Unless you have extraordinary reasons for doing this,
your most wise choice is to include this needed
subroutine within your script in question.
This is a quick non-technical example of why you
don't want to do this. Using your stated parameters
as a guideline for exemplification, Script One needs
to access subroutine number_three within Script Two:
Script Two
(program coding.. etc..)
sub routine_one
{ print "I am number one."; }
sub routine_two
{ print "I am number two."; }
sub routine_three
{ print "I am number three."; }
sub routine_four
{ print "I am number four."; }
(more coding.. etc..)
What methodology would you use to access this
sub routine_three from Script One? Only method
to access a specific subroutine within another
script is to somehow pass control parameters to
Script Two, instructing it to run your chosen
sub routine_three and, return results. Same
problem exists when Script Two only contains
one subroutine, the one you need; you have a
problem of addressing only a subroutine.
Creating a methodology to successfully accomplish
this will cost you a lot of script time and memory,
so much so, it is not a viable methodology.
Alternatives would be to create a module or
a stand-alone script, either containing only
this subroutine. However, why would you do
this just for one fairly simple subroutine
as you indicate? Use of a module call or a
script call would only be marginally more
efficient than trying to call a specific
subroutine in another script as I exemplified.
Write your subroutine into your script in need
to retain better speed and better efficiency,
in lieu of extraordinary circumstances for
accomplishing this another way.
Godzilla!
------------------------------
Date: Sun, 18 Mar 2001 15:08:23 +0000
From: Principle <principle@seekasonic.com>
Subject: Beginners question please help on the verge of throwing PC out the window
Message-Id: <rjj9bt46tdqu502jqu0rs391j20pnoj697@4ax.com>
Right hers the problem i would like to be able to access a sub routine
in one script from another script ie i have this sub in a script
called admin.cgi
sub print_hello{
print "hello";
{
now normaly i would access the sub like this
print_hello();
But as its located in another script is there any way to access it say
if i wanted to access this sub from serarch.cgi in the same dir
Can i access the print_hello sub in the the admin.cgi script from the
search.cgi script
hope this makes more sense to you guys than it does to me.
Any help gladly received
------------------------------
Date: 18 Mar 2001 16:16:26 +0000
From: nobull@mail.com
Subject: Re: Beginners question please help on the verge of throwing PC out the window
Message-Id: <u9hf0rhx2d.fsf@wcl-l.bham.ac.uk>
Principle <principle@seekasonic.com> writes:
> Subject: Beginners question please help on the verge of throwing PC out the window
Please use your subject line to tell us about the subject of the thread.
> Right hers the problem i would like to be able to access a sub routine
> in one script from another script ie i have this sub in a script
> called admin.cgi
Please see the recent thead on this exact same subject but ignore the
nonsense from Godzilla and the responses thereto.
By the way, that's a major reason why threads have subject lines - so
that people who come along with the same question will be able to spot
existing threads. An that is why cutsie non-informative subject lines
like yours are considered exceptionally rude and selfish.
> sub print_hello{
> print "hello";
> {
>
> now normaly i would access the sub like this
> print_hello();
>
> But as its located in another script is there any way to access it say
> if i wanted to access this sub from serarch.cgi in the same dir
>
> Can i access the print_hello sub in the the admin.cgi script from the
> search.cgi script
Move the common subroutines into an Exporter module and have both your
scripts use it.
perldoc perlmod
perldoc Exporter
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sun, 18 Mar 2001 10:26:29 -0000
From: "Chile" <abcd@ntlworld.com>
Subject: Re: check a pop3 mailbox without using additional modules
Message-Id: <SO%s6.3247$Q4.900197@news2-win.server.ntlworld.com>
use raw unix sockets code and you can do anything. Access pop3 serverl,
access nntp servers, code a httpd server.
best thing is its not difficult to learn.
"Paul" <paulthomson@hotmail.com> wrote in message
news:3ab3e9ec@news1.homechoice.co.uk...
> Sorry - didn't mean to post this again.
>
>
> "Paul" <paulthomson@hotmail.com> wrote in message
> news:3ab3e99b@news1.homechoice.co.uk...
> > Hi,
> >
> > Does anyone know of a way to check a pop3 mailbox without using
additional
> > modules to the basic perl 5 installation? The reason I ask is my isp
makes
> a
> > hideous charge for installing modules :(
> >
> > Thanks in advance for any pointers or resources,
> >
> > Paul
> >
> > BTW it is an NT server...
> >
> >
>
>
------------------------------
Date: Sun, 18 Mar 2001 09:48:41 GMT
From: trammell@bayazid.hypersloth.net (John Joseph Trammell)
Subject: Re: HTTP Client Question
Message-Id: <slrn9b8upi.me9.trammell@bayazid.hypersloth.net>
On Sat, 17 Mar 2001 14:07:06 -0500, Dilworth whinged:
> *plonk*
Back in yer box, pathetic troll.
------------------------------
Date: Sun, 18 Mar 2001 10:14:34 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: many "used only once, possible typo" warnings in CGI.pm using import_names("UT");
Message-Id: <md09bt8v5q3rcafsb3tqpthg8gtv1e3lao@4ax.com>
Malcolm Dew-Jones wrote:
>step 2, in the various scripts that use the variables
>
> # declare all the variables names, note the syntax is
> # slightly different than normal "use var" usage
>
> use vars @my_global_variables ;
>
Note that the stuff on that line is executed, as plain perl, and passed
as parameters to vars->import, as soon as this lmine is compiled. For
example, this works too:
use lib grep -d, "/path/a/lib", "/path/b/lib", "/path/c/lib";
So, @my_global_vars must already be properly filled when the compiler
gets to this line. But if you fill its contents in the initialisation
code of modules that you used, as intended, that will have happened.
Neat trick. It teaches people to go beyond standard programmer's
thinking. It defeats the purpose of "use strict", so I'm not sure how
much of an improvement it would be over not using strict at all, but
it's (kinda) neat. "strict" doesn't checked fully qualified variable
names, anyway.
--
Bart.
------------------------------
Date: Sun, 18 Mar 2001 09:00:09 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Memory and Perl
Message-Id: <v7u8bt8a9qefqqklofcaup43b5pc6kfd0s@4ax.com>
Collin Borrlewyn wrote:
>is there a memory-saving way to pass variables
>between subroutines without simply creating duplicate local variables? In
>short: How can I use less memory when writing my scripts?
How could you have missed it. There was a very long and thurrough thread
here, in reply to a FAQ posting, no more than a few weeks ago. The new
Deja/Google might have it (it seems to have limited access to older
postings).
--
Bart.
------------------------------
Date: Sun, 18 Mar 2001 16:37:06 -0000
From: "Milliwave" <milliwave@rfengineering.freeserve.co.uk>
Subject: Moving and mkdir in Unix
Message-Id: <992o4t$duf$1@news5.svr.pol.co.uk>
I would like to know how to direct files by creating a directory in the
current working directory, and
moving the "files" into that directory?
open(File Handle1 "original.txt")
open(File handle2 ">text.txt")
1) Now how do I make a directory and move text.txt and original.txt into
that directory
2)Then I would like to delete the original.txt from the current working
directory.
mkidr $file_name
open(File Handle1 "original.txt")
open(File handle2 ">\\$file_name\\text.txt")
would text.txt be created in the $file_name directory?
I need to some to inform me by means of an example how would go about
what I have asked for, as I don't have access to the perldoc manuals
cheers
Kev
------------------------------
Date: Sun, 18 Mar 2001 11:12:03 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Moving and mkdir in Unix
Message-Id: <slrn9b9nij.krh.tadmc@tadmc26.august.net>
Milliwave <milliwave@rfengineering.freeserve.co.uk> wrote:
>I would like to know how to direct files by creating a directory in the
>current working directory, and
>moving the "files" into that directory?
>
>open(File Handle1 "original.txt")
>open(File handle2 ">text.txt")
You do not need the open() function for what you want to do.
>1) Now how do I make a directory and move text.txt and original.txt into
>that directory
perldoc -f mkdir
perldoc -f rename
>2)Then I would like to delete the original.txt from the current working
>directory.
After you have used rename() it will already be gone (that is what
"move" means. "copy" would have left the old file alone).
>mkidr $file_name
Please do not post pseudo code, post Real Perl Code here in the
Perl newsgroup.
You must spell the names of functions correctly if you want perl
to recognize them.
You must separate your statement from the following one with a semi-colon.
>open(File Handle1 "original.txt")
>open(File handle2 ">\\$file_name\\text.txt")
>
>would text.txt be created in the $file_name directory?
What happened when you tried it?
>I need to some to inform me by means of an example how would go about
>what I have asked for, as I don't have access to the perldoc manuals
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You are hereby killfiled then. So long.
You cannot post to the Perl newsgroup without first checking the
Perl FAQs. If you cannot check the Perl FAQs, then do not post
to the Perl newsgroups. (just go find them, _then_ post after checking)
Why do you not have access to the perldoc manuals? They are installed
along with perl itself unless you "do something" to stop it.
If perldoc does not work, then you have a broken perl installation
and you are on your own. Good luck.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 18 Mar 2001 18:35:47 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Moving and mkdir in Unix
Message-Id: <GAEozn.38G@presby.edu>
In article <992o4t$duf$1@news5.svr.pol.co.uk>,
Milliwave <milliwave@rfengineering.freeserve.co.uk> wrote:
>
> [...] I don't have access to the perldoc manuals
Tip: You can find them at <http://www.perl.com/>. Follow the link
labeled DOCUMENTATION.
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
------------------------------
Date: 18 Mar 2001 14:40:07 +0000
From: Paul the Nomad <taka@yarn.demon.co.uk>
Subject: Re: Overloading in OO perl
Message-Id: <m3itl787js.fsf@yarn.demon.co.uk>
ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> [A complimentary Cc of this posting was sent to Abigail
> <abigail@foad.org>],
> who wrote in article <slrn9b4c0j.863.abigail@tsathoggua.rlyeh.net>:
> > \\ sub new {
>
> > \\ if (ref $anArg eq ARRAY) {
> > \\ do something
> > \\ elsif ($anArg =~ /^\d+$/ ) {
> > \\
> > \\ do something else
>
> > That's the way of doing it in Perl.
>
> Since the names of constructors are not hardwired in Perl, you can
> also have different flavors named differently.
>
But the it's not really *overloading*. :)
> Ilya
--
Paul
http://www.seditiousdiaries.com/Donald15.html
------------------------------
Date: Sun, 18 Mar 2001 09:02:14 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Print to file
Message-Id: <9eu8btcob73itu0qu36pesa9io827tlcsb@4ax.com>
David Ehrens wrote:
>> len.green <len.green@ntlworld.com> wrote:
>
>> > Win32 does not support flock();
>
>Win32 has been flocked for quite a while.
There's more than one family of Windows.
--
Bart.
------------------------------
Date: 18 Mar 2001 09:45:11 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: procedures to do euler path and topological sorting in perl
Message-Id: <slrn9b90so.8ih.damian@puma.qimr.edu.au>
cyberian bear chose Sat, 17 Mar 2001 20:10:06 -0500 to say this:
>can anyone suggest where i can find the modules which would do those two
>things.
>
If you do a search at google, you'll find there was a discussion relevant
to the Euler path bit recently (I recall the subject was 'SETL to Perl').
Basically, you need to read a book about algorithms. I have pointed out
that an easy way to go about this would be to read the O'Reilly publication,
_Mastering Algorithms with Perl_, which at least contains working Perl
examples for ways to go about it. If you're more serious, you might want to
check any well recommended book on algorithms in general (I couldn't
possibly make such a recommendation).
If you're looking for modules to do {anything}, go search CPAN. I'm not
going to do that for you, nor (I should think) is anyone else likely to.
Try http://www.cpan.org -- firstly to check the list of mirrors for a site
close to you.
HTH
Cheers,
Damian
--
@;=0..23;@;{@;}=split//,<DATA>;while(@;){for($;=@;;--$;;){next if($:=rand($;
+1))==0+$;;@;[$;,$:]=@;[$:,$;]}print map{$;{$_}}(@| ,@;);push@|,shift@;if$;[
0]==@|;$|=1;select$&,$&,$&,1/80;print"\b"x(@;+@|)}print"\n"__END__
Just another Perl Hacker
------------------------------
Date: 18 Mar 2001 09:55:35 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Restricting access using passwords
Message-Id: <slrn9b91g8.8ih.damian@puma.qimr.edu.au>
Mike Scott chose Sun, 18 Mar 2001 01:26:53 GMT to say this:
>How would one go about implementing a username+password login scheme that
>allowed subsequent access to specific areas of a web site? I'm thinking of
>something like a bulletin board that requires a user to log in before they
>can post a message, or access certain forums. How is this state maintained
>after the user has had his username+password accredited?
>
This is really a CGI question that is best taken up on
comp.infosystems.authoring.cgi. The way in which you go about this is in no
way specific to Perl, and indeed, most Perl people here will be using the
language for things other than CGI.
You have a variety of options, the easiest from your point of view being
those that lie in the web server configuration. Check the documentation of
your web server for such options.
Otherwise you have to come up with a suitable mechanism to save state. My
own choice for this is to use a MySQL database backend, passing a session
identifier to the browser to return with each subsequent action. But there
are a lot of options here. ISTR seeing a good discussion of this on the
web, involving a hangman game -- you might want to try a google search with
'hangman' and 'state info'.
You can, of course, pass state back and forth between browser and server as
hidden fields, but if security is important, recognise that there is none
in such a scenario (unless you're using mod_ssl, of course).
HTH
Cheers,
Damian
--
@;=0..23;@;{@;}=split//,<DATA>;while(@;){for($;=@;;--$;;){next if($:=rand($;
+1))==0+$;;@;[$;,$:]=@;[$:,$;]}print map{$;{$_}}(@| ,@;);push@|,shift@;if$;[
0]==@|;$|=1;select$&,$&,$&,1/80;print"\b"x(@;+@|)}print"\n"__END__
Just another Perl Hacker
------------------------------
Date: Sun, 18 Mar 2001 04:39:00 -0500
From: "null" <nospamplease@thankyou.com>
Subject: sub routine args, and using GD's newFromPng method
Message-Id: <991vmm$pcl$1@bob.news.rcn.net>
I am a perl newbie and am writing my first prog.
I've written a subroutine that i am calling to create several images inside
the script () from png image files. The images and parts of the images are
pasted together later on in the script [using $image->copy(blahblah... ] to
make a new image that I spit out for viewing.
I've had a problem ... first here's the sub and the sub call that I am
using now :
sub createCompImages{
my($filePath, $imgMoniker) = @_;
open(PNG, "< ".$filePath) or die "Couldn't open $filePath for reading:
$!\n";
@_[1] = newFromPng GD::Image(\*PNG) || die "Couldn't create an image for
$filePath for reading: $!\n";
close PNG;
}
&createCompImages($componentPinkrectPath, $componentPinkrect);
further down in the script, I'm referencing the image created by this call
to the sub through the variable $componentPinkrect.
As you see, in the first line of the script, I copied the arguments into
private vars and I reference the var $filePath (given the value of the path
from the script to the png file earlier on in the script) in a couple of
spots. I can't seem to use the var $imgMoniker in place of the array
element @_[1] reference without throwing an error and breaking the script.
Can someone explain the problem to me?
My script works now, but I'd like to be able to use the var instead of the
raw array element reference for obvious reasons. Note : if I paste
$componentPinkrect in for @_[1], it also works. Running in strict mode, no
errors except for when I try to use $imgMoniker instead of @_[1].
Thanks for your help,
-brian
(perl newbie)
------------------------------
Date: 18 Mar 2001 15:30:47 +0000
From: nobull@mail.com
Subject: Re: sub routine args, and using GD's newFromPng method
Message-Id: <u9r8zvw0uw.fsf@wcl-l.bham.ac.uk>
"null" <nospamplease@thankyou.com> writes:
> Subject: sub routine args, and using GD's newFromPng method
Nothing in your question related to the fact that your code happes to
contain GD's newFromPng method.
> I am a perl newbie and am writing my first prog.
Wellcome.
> sub createCompImages{
> my($filePath, $imgMoniker) = @_;
> open(PNG, "< ".$filePath) or die "Couldn't open $filePath for reading:
> $!\n";
> @_[1] = newFromPng GD::Image(\*PNG) || die "Couldn't create an image for
> $filePath for reading: $!\n";
> close PNG;
> }
> &createCompImages($componentPinkrectPath, $componentPinkrect);
> As you see, in the first line of the script, I copied the arguments into
> private vars and I reference the var $filePath (given the value of the path
> from the script to the png file earlier on in the script) in a couple of
> spots. I can't seem to use the var $imgMoniker in place of the array
> element @_[1] reference without throwing an error and breaking the script.
Firstly a couple of cosmetic points. Like the warning you got when
you ran this progam said, you should write $_[1] not @_[1]. What do
you mean you got no such warning? How dare you come here and start
asking sentient entities to help you when you've not already taken
advantage of all the help Perl itself can give you. Also the
subroutine createCompImages does not have a prototype so explicitly
telling Perl to ignore the protype is just confusing to the reader -
drop the & in the funtions call.
Secondy, you have answered your own question. Like you say
$imgMoniker is a _copy_ of $_[1] which is in turn an alias for
$componentPinkrect. If you modify the copy in $imgMoniker it does not
modify $componentPinkrect. If you modify $_[1] it does.
> My script works now, but I'd like to be able to use the var instead of the
> raw array element reference for obvious reasons.
There is in Perl5 no way to make a lexical variable that is an alias
for another variable. This gaping hole is expected to be plugged
RSN. In the mean time you can make a package varable be an alias (not
the recommended approach) or you can have your lexical variables
contain references to the elements of @_ rather than copies of them.
Oh and old bare filehandles are _so_ C20... get with the 21st man![1]
sub createCompImages{
my ($filePath, $imgMoniker) = \(@_);
open(my $png, "<$$filePath") or die "Couldn't open $$filePath for reading:
$!\n";
$$imgMoniker = newFromPng GD::Image($png) || die "Couldn't create an image for
$$filePath for reading: $!\n";
}
> -brian
Hey, me too.
> (perl newbie)
Perl guru in training.
[1] Hell, what am I on today?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
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 V10 Issue 519
**************************************