[18004] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 164 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 29 00:05:57 2001

Date: Sun, 28 Jan 2001 21:05:09 -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: <980744709-v10-i164@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 28 Jan 2001     Volume: 10 Number: 164

Today's topics:
    Re: $FindBin::Bin for modules <johnlin@chttl.com.tw>
    Re: <STDIN> as an array <traigle@si.umich.edu>
    Re: <STDIN> as an array <peter.sundstrom@eds.com>
    Re: <STDIN> as an array <traigle@si.umich.edu>
    Re: CGI.pm <nospam@nospam.com>
    Re: CGI.pm <trwww@my-deja.com>
    Re: closed filehandle error <whtwlf@NOSPAMoptushome.com.au>
    Re: Comparing multiple values <nospam@nospam.com>
        email address with receiver's name <johnlin@chttl.com.tw>
    Re: Finding unused variables ? <johnlin@chttl.com.tw>
    Re: how do I use 'strict' and 'vars' <extramail@home.com>
    Re: how do I use 'strict' and 'vars' <extramail@home.com>
    Re: How to pass $vars to a script from within another s (Mark Jason Dominus)
    Re: How to send contents of html file in email? <peter.sundstrom@eds.com>
    Re: How to unload module from memory? <andrew@erlenstar.demon.co.uk>
    Re: How to unload module from memory? tigra@sky.deep.ru
    Re: How to unload module from memory? <dan@tuatha.sidhe.org>
    Re: How to unload module from memory? tigra@sky.deep.ru
    Re: html link on perl created dynamic webpage <nospam@nospam.com>
    Re: mod_perl Perl: <a565a87@my-deja.com>
    Re: New way to learn Perl? <m_ario@my-deja.com>
        passing parameter <b0l4549@cs.tamu.edu>
    Re: Perl programmer wanted <extramail@home.com>
    Re: Perl with Windows98 <m_ario@my-deja.com>
    Re: Problem renaming under Win32 (Eric Bohlman)
    Re: substition problem <anon@anon.com>
    Re: ternary conditional operator <nospam@nospam.com>
        Unicode and URL encoding (Benjamin Chen)
    Re: Unicode and URL encoding <flavell@mail.cern.ch>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 29 Jan 2001 11:10:14 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: $FindBin::Bin for modules
Message-Id: <952n21$pg@netnews.hinet.net>

"Joe Smith" wrote
> John Lin wrote:
> >my suggestion is to extend FindBin.pm to do the same
> >thing for modules.  That would be more complete.
>
> It means that if you create a patch yourself for this new functionality,
> document it, and test it using the most recent sources (perl-5.7.0),
> then it can be included as part of the official perl distribution.

Really?  Everyone can patch perl?  That's... good.
Doesn't it need some thorough discussion before taking action?
What if I give silly variable names like

$FindBin::DirectoryWhereModuleIsStored

Anyway, there must be a well defined process, right?

By the way, I have another thing to complain.
In most cases, one large program is divided into many modules
and stored together with the main program.  For example,
in C, the main program often begins with

#include <stdio.h>    /* in default directory */
#include "part1.h"
#include "part2.h"
 ...

The #include looks for "part1.h" and "part2.h" in the directory
*where the main program is stored*.

But in Perl, if we say

use CGI;    # in default directory, fine
use Part1;
use Part2;

perl looks for "Part1.pm" and "Part2.pm" in (beside default directories)
*current working directory*, not *where the main program is stored*.

That's annoying.  If I evoke the main program from another directory,
it will give "file not found" errors.  Even worse, it might pick up the
wrong (unexpected) Part1.pm in cwd.

To correct this, now all my main programs look like:

use FindBin;
use lib $FindBin::Bin;
use CGI;
use Part1;
use Part2;

I feel very ridiculous.
Is there a chance that the next version of perl will change this behavior?

Thank you very much.

John Lin

P.S.  If you say "patches to the perl compiler are welcomed",
oh... I will surrender.





------------------------------

Date: Mon, 29 Jan 2001 03:05:37 GMT
From: Jeff Traigle <traigle@si.umich.edu>
Subject: Re: <STDIN> as an array
Message-Id: <B69A4779.18EE4%traigle@si.umich.edu>

On 1/28/01 8:17 PM, in article slrn979h5a.rro.abigail@tsathoggua.rlyeh.net,
"Abigail" <abigail@foad.org> wrote:

> Jeff Traigle (traigle@si.umich.edu) wrote on MMDCCVIII September MCMXCIII
> in <URL:news:B69A2DAC.18EC3%traigle@si.umich.edu>:
> -: 
> -: The code is simple:
> -: 
> -: #!/usr/bin/perl
> -: 
> -: while (<STDIN>) {
> -:     if (/a/i && /e/i && /i/i /o/i && /u/i) {
> -:         print;
> -:     }
> -: }
> -: 
> -: This is, in fact, the exact code provided in the book as one solution for
> -: this exercise. However, executing this code results in the following error:
> -: 
> -: ./vowels.plx: syntax error near unexpected token `<STDIN>'
> -: ./vowels.plx: ./vowels.plx: line 3: `while (<STDIN>) {'
> 
> I don't get that with 5.005_03. I do get a run time error (division by
> zero), because there is no && between /i/i and /o/i (-w would have warned
> you against that).
> 
> -: Is this a design change between 5.004 (which the book was written for) and
> -: 5.005? Is there a known bug in the RedHat Linux 6.0 distributed copy of
> -: perl? Was the book just plain wrong in multiple locations about this
> -: working?
> 
> No. RedHat has distributed development versions of Perl, but that wouldn't
> effect this. No.

Well, that was a mistype on my part in the note. No such mistype in the
script I was trying to run on my Linux box. Adding -w option didn't yield
any further information on the problem, however.

I redid a simple script just reading <STDIN> and assigning it to an array
and it worked. The first one I tried was just a copy and edit of the above
script that wasn't working.

So I just retyped the script I was trying to get working in the first place.
It worked this time. I must have accidentally imbedded some hidden character
that it was choking on.

-- 
Jeff Traigle
traigle@si.umich.edu
http://www-personal.si.umich.edu/~traigle/



------------------------------

Date: Mon, 29 Jan 2001 15:04:56 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: <STDIN> as an array
Message-Id: <952j4a$g8o$1@hermes.nz.eds.com>


"Jeff Traigle" <traigle@si.umich.edu> wrote in message
news:B69A2DAC.18EC3%traigle@si.umich.edu...
> Hi, folks.
>
> In all the years I've been administering Unix systems, I've rarely had
need
> to write scripts. The few I have needed, I've done in csh or ksh,
depending
> on the environment I was working in at the time. I decided to delved into
> the world of perl so this weekend I've started by reading Learning Perl
(2nd
> Edition) from O'Reilly & Associates, Inc. I've run into a problem
concerning
> <STDIN> as an array that I haven't seen mentioned in the archives at
> www.deja.com. I hope you can enlighten me.
>
> I'm running perl 5.005_003 on RedHat Linux 6.0. Nothing special. It's as
> shipped on that Linux distribution. One of the exercises in the regular
> expressions section asks to write a program that accepts a list of words
on
> STDIN and looks for a line containing all five vowels.
>
> The code is simple:
>
> #!/usr/bin/perl
>
> while (<STDIN>) {
>     if (/a/i && /e/i && /i/i /o/i && /u/i) {
>         print;
>     }
> }
>
> This is, in fact, the exact code provided in the book as one solution for
> this exercise. However, executing this code results in the following
error:
>
> ./vowels.plx: syntax error near unexpected token `<STDIN>'
> ./vowels.plx: ./vowels.plx: line 3: `while (<STDIN>) {'
>
> I get similar errors trying to make an explicit assignment of <STDIN> to
an
> array variable (@arrayname = <STDIN>;) as is also mentioned as legitimate
in
> the book.
>
> Is this a design change between 5.004 (which the book was written for) and
> 5.005? Is there a known bug in the RedHat Linux 6.0 distributed copy of
> perl? Was the book just plain wrong in multiple locations about this
> working?

The error message you get is from bash trying run the script.  How are you
invoking the script?  Make sure that #!/usr/bin/perl really is the first
line of the script.




------------------------------

Date: Mon, 29 Jan 2001 04:26:03 GMT
From: Jeff Traigle <traigle@si.umich.edu>
Subject: Re: <STDIN> as an array
Message-Id: <B69A5CF9.1925F%traigle@si.umich.edu>

On 1/28/01 9:04 PM, in article 952j4a$g8o$1@hermes.nz.eds.com, "Peter
Sundstrom" <peter.sundstrom@eds.com> wrote:

> 
> "Jeff Traigle" <traigle@si.umich.edu> wrote in message
> news:B69A2DAC.18EC3%traigle@si.umich.edu...
>> 
>> ./vowels.plx: syntax error near unexpected token `<STDIN>'
>> ./vowels.plx: ./vowels.plx: line 3: `while (<STDIN>) {'
> 
> The error message you get is from bash trying run the script.  How are you
> invoking the script?  Make sure that #!/usr/bin/perl really is the first
> line of the script.

There wasn't any line prior to #!/usr/bin/perl, but that apparently was the
line where the imbedded hidden character was. Deleting just that line in one
of the broken scripts and retyping it fixed the script.

-- 
Jeff Traigle
traigle@si.umich.edu
http://www-personal.si.umich.edu/~traigle/



------------------------------

Date: 29 Jan 2001 03:17:03 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: CGI.pm
Message-Id: <952nbf$o5i$2@216.155.33.38>

In article <952b2n$id4$1@nnrp1.deja.com>, bits101010@my-deja.com wrote:

gah, jeopardy-posting.

 | Try this:
 | 
 | $cgi = new CGI;
 | # this should get the number=714 part, using regular expression
 | # $ENV{'QUERY_STRING') should contain number=714
 | $ENV{'QUERY_STRING') =~ /number=(\d+)$/;
 | $number = $1;
 | 
 | # get the rest into array
 | foreach ($query->param()) {
 |   $FieldArray[$i++] = $query->param($_);
 | }


why? you only need do 

my $number = param('number'); 
or
my $number = $query->param('number');

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


------------------------------

Date: Mon, 29 Jan 2001 04:41:21 GMT
From: trwww <trwww@my-deja.com>
Subject: Re: CGI.pm
Message-Id: <952s9g$vpm$1@nnrp1.deja.com>

In article <952nbf$o5i$2@216.155.33.38>,
  The WebDragon <nospam@nospam.com> wrote:
> In article <952b2n$id4$1@nnrp1.deja.com>, bits101010@my-deja.com
wrote:
>  | Try this:
>  |
>  | $cgi = new CGI;
>  | # this should get the number=714 part, using regular expression
>  | # $ENV{'QUERY_STRING') should contain number=714
>  | $ENV{'QUERY_STRING') =~ /number=(\d+)$/;
>  | $number = $1;
>  |
>  | # get the rest into array
>  | foreach ($query->param()) {
>  |   $FieldArray[$i++] = $query->param($_);
>  | }
>
> why? you only need do
>
> my $number = param('number');
> or
> my $number = $query->param('number');
>

well, thats not exactly what you only need to do, since the form mixes
POST and URL parameters, but it is silly to do the parsing when CGI.pm
gives you a perfectly good function called url_param()

CGI.pm documentation -> MIXING POST AND URL PARAMETERS


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Mon, 29 Jan 2001 14:27:13 +1100
From: "Shane Lowry" <whtwlf@NOSPAMoptushome.com.au>
Subject: Re: closed filehandle error
Message-Id: <952nkv$r0s$1@merki.connect.com.au>

Thanks Eric,
                    the double open was a cut/paste error from my code into
the post. I have solved the problem by using the OO filehandle methods.
Still a little strange, but at least it now works

thanks again

Shane





------------------------------

Date: 29 Jan 2001 02:05:38 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: Comparing multiple values
Message-Id: <952j5i$jif$0@216.155.33.38>

In article <x7r91oucr3.fsf@home.sysarch.com>, Uri Guttman 
<uri@sysarch.com> wrote:

 | >>>>> "TW" == The WebDragon <nospam@nospam.com> writes:
 | 
 |   TW> I watched this whole entire thread unfold and saw absolutely NO 
 |   ONE 
 |   TW> respond to Damien Conway's extremely useful suggestion, therefore 
 |   I 
 |   TW> reiterate: 
 | 
 | what do you call this followup, chopped liver?
 | 
 | *****************
 | 
 | >>>>> "DC" == Damian Conway <damian@cs.monash.edu.au> writes:
 | 
 |   DC> I'm late to this thread, so I'm not sure if anyone has yet 
 |   suggested:
 | 
 |   DC> 	use Quantum::Superpositions;
 | 
 |   DC> 	if ($somevar == any(3,4,8,9)) {
 |   DC> 	    ...
 |   DC> 	}
 | 
 | we all did in an alternate universe. you are the only one who did it in
 | this one.

I call that "Damien Conway's extremely useful suggestion", which is what 
I was referring to.. notice there were no followups to his suggestion in 
the thread until recently :)

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


------------------------------

Date: Mon, 29 Jan 2001 11:38:01 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: email address with receiver's name
Message-Id: <952omb$34a@netnews.hinet.net>

Dear all,

Sorry if this is a repost.  My news server lost my post.

Let me explain "email address with receiver's name" first.
For address "johnlin@chttl.com.tw", we can add a name "John Lin" to it.

"johnlin@chttl.com.tw (John Lin)" or "John Lin <johnlin@chttl.com.tw>"

The two formats are frequently seen.  I am not sure which is right.
But experiments showed neither could work correctly.

I use MIME::Lite to send to many people "with names".  The following is
my code.  Only the first one received the email.  The others didn't.

use MIME::Lite;
my $mail = new MIME::Lite(
    From => 'johnlin@chttl.com.tw (John Lin)',
      To => 'lin54321@hotmail.com (John at hotmail), '.
            'johnlin@chttl.com.tw (John at company)',
Subject => 'test',
    Data => "Hi\n"
);
$mail->send_by_smtp;


Of course, if I send "without name", it works fine.

To => 'lin54321@hotmail.com, johnlin@chttl.com.tw',

My question is how can I send "with name"?  Could you help me please?

Thank you very much.

John Lin

P.S.  In the code

Data => "Hi\n";

If I don't append the "\n", the program will hang there.
It seems to be bug of MIME::Lite.





------------------------------

Date: Mon, 29 Jan 2001 11:36:13 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Finding unused variables ?
Message-Id: <952oiq$2va@netnews.hinet.net>

"Abigail" wrote
> John Lin wrote

> our() is weird, confusing, and should be avoided.

One day I found my code can be trimmed cleaner:

use strict;
use Exporter;
use vars '@ISA @EXPORT';
@ISA = ('Exporter');
@EXPORT = ('PI');

becomes

use strict;
use base 'Exporter';
our @EXPORT = ('PI');

I don't know whether I should thank to "our" or hate "use strict".

> $$ And also annoying because most of my programs/modules have
> $$ our $debug = 0;    # but not necessarily further used
> Assuming $debug is placed at the top of your program/module, why not:
>     my $debug = 0;

I assume when debugging I'll need to turn on some modules'
debug message while keep other modules silent.

$ModuleA::debug = 1;
$ModuleB::debug = 0;
$ModuleC::debug = 0;

so they need to be "our", not "my", right?

I know the canonical way is

ModuleA->debug(1);

but it costs more (1 sub + 1 my $debug) than just an "our $debug".

John Lin





------------------------------

Date: Mon, 29 Jan 2001 02:48:55 GMT
From: Joel Nelson <extramail@home.com>
Subject: Re: how do I use 'strict' and 'vars'
Message-Id: <3A74D9EB.E91451FD@home.com>

Abigail wrote:

> Joel Nelson (extramail@home.com) wrote on MMDCCVIII September MCMXCIII in
> <URL:news:3A74C1AD.F664EBAE@home.com>:
> && In my typical cgi scripts I have an '&initialize' subroutine I call
> && right away.  It will declare global variables other subroutines will
> && need to access.  When I use 'strict' I get a lot of :
> &&
> && Global symbol $soAndSo requires explicit package name at scriptName.cgi
> && line 22
> &&
> && I would like to use strict to make sure my code is good and for
> && debugging.  If I declare variables using 'my' they are not global.  If
> && I don't use 'my' I get the above warnings.  From reading it looks like I
> && should use 'vars'.  Can someone explain this or point me to some
> && documentation that covers it?
>
>     man vars
>     man strict
>
> Could it have been more obvious?
>
> Abigail
> --
> $_ = "\112\165\163\1648\141\156\157\164\150\145\1628\120\145"
>    . "\162\1548\110\141\143\153\145\162\0128\177"  and &japh;
> sub japh {print "@_" and return if pop; split /\d/ and &japh}

Hah!  You assume I'm on unix.  So no, it could NOT have been more obvious.
Anybody after you these days?  Thanks for the tip!!

Joel



------------------------------

Date: Mon, 29 Jan 2001 03:14:43 GMT
From: Joel Nelson <extramail@home.com>
Subject: Re: how do I use 'strict' and 'vars'
Message-Id: <3A74DFF7.B96A6454@home.com>

Mark Jason Dominus wrote:

> http://perl.plover.com/FAQs/Namespaces.html

Mark,

Thanks!!  That's an answer right on the mark.  It gives complete reasons and
detail for the problem I suggested for myself.  Abigails answer is more typical.
However, the man pages don't explain the errors that will occur (assuming I was
using unix) and why.  Allthough brief, thanks for extra insight of your answer.
You do the perl community good!!!!

Joel



------------------------------

Date: Mon, 29 Jan 2001 03:22:46 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: How to pass $vars to a script from within another script and e-mail results to a group.
Message-Id: <3a74e205.19f6$394@news.op.net>

In article <01c08943$ae02b100$48c249d8@rjuliano>,
creafin1998 <creafin1998@yahoo.com> wrote:
>$prog = '/path/script.pl?var=$value';
>$group = 'user1\@dot.com user2\@dot.com user3\@dot.com';
>
>`$prog | mail $group`;

Try this:

        $ENV{QUERY_STRING} = "var=$value";
        $ENV{REQUEST_METHOD} = 'GET';
        $prog  ='/path/script.pl';
        $group = 'user1@dot.com user2@dot.com user3@dot.com';
        system("$prog | mail $group");

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


------------------------------

Date: Mon, 29 Jan 2001 14:16:10 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: How to send contents of html file in email?
Message-Id: <952g8r$crk$1@hermes.nz.eds.com>


"creafin1998" <creafin1998@yahoo.com> wrote in message
news:01c08971$319daa60$48c249d8@rjuliano...
> I may have found a resource and answer my own question.  For those of you
> interested, check out the free script here:
> http://www.zdnet.com/devhead/stories/articles/0,4413,2587501,00.html

You can create your own free script using the MIME::LIte and
MIME::Lite::HTML modules, eg:

#!/usr/bin/perl -w
use MIME::Lite;
use MIME::Lite::HTML;

my $mailHTML = new MIME::Lite::HTML
     From     => 'MIME-Lite@alianwebserver.com',
     To       => 'alian@jupiter',
     Subject => 'Mail in HTML with images';

$MIMEmail = $mailHTML->parse('http://www.alianwebserver.com');
$MIMEmail->send;

Pretty easy, eh?





------------------------------

Date: 29 Jan 2001 02:04:49 +0000
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: How to unload module from memory?
Message-Id: <87d7d7p0zi.fsf@erlenstar.demon.co.uk>

>>>>> "tigra" == tigra  <tigra@sky.deep.ru> writes:

 tigra> But what about undefining the module itself in case I don't
 tigra> need it anymore (but I do need the memory it consumes)? Do I
 tigra> really need this or the black magic of garbage collection does
 tigra> this job?

I've done some experimenting with this, with not entirely satisfactory
results.

There's a delete_package() function provided in the Symbol module (at
least in 5.005_03 which I'm using). Unfortunately it doesn't seem to
do a good enough job; if a function in a module refers to a lexical
variable, then calling delete_package() on the module does not cause
the destruction of the variable's contents, though doing an explicit
undef on the function does cause the variable to be destroyed.

i.e. given something like this:

package Tracer;

sub new { return bless [] }
sub DESTROY { print "object destroyed\n" }

package Foo::Bar;

my $var = new Tracer;

sub f { return $var }


then doing
  undef &Foo::Bar::f;
or
  undef *Foo::Bar::f;

causes the "object destroyed" message to be printed, but

  delete_package("Foo::Bar")

does not. (Until the program actually ends.)

Not doing the undef's, or only doing undef &Foo::Bar::f, seems to
result in memory leakage. Doing an undef *Foo::Bar::f seems not to
leak memory, but it's not quite what I want to do.

-- 
Andrew.


------------------------------

Date: Mon, 29 Jan 2001 02:49:39 GMT
From: tigra@sky.deep.ru
Subject: Re: How to unload module from memory?
Message-Id: <952lo2$qmc$1@nnrp1.deja.com>

In article <87d7d7p0zi.fsf@erlenstar.demon.co.uk>,
  Andrew Gierth <andrew@erlenstar.demon.co.uk> wrote:
> >>>>> "tigra" == tigra  <tigra@sky.deep.ru> writes:
>
>  tigra> But what about undefining the module itself in case I don't
>  tigra> need it anymore (but I do need the memory it consumes)? Do I
>  tigra> really need this or the black magic of garbage collection does
>  tigra> this job?
>
> I've done some experimenting with this, with not entirely satisfactory
> results.
>
> There's a delete_package() function provided in the Symbol module (at
> least in 5.005_03 which I'm using). Unfortunately it doesn't seem to
> do a good enough job; if a function in a module refers to a lexical
> variable, then calling delete_package() on the module does not cause
> the destruction of the variable's contents, though doing an explicit
> undef on the function does cause the variable to be destroyed.
>
> i.e. given something like this:
>
> package Tracer;
>
> sub new { return bless [] }
> sub DESTROY { print "object destroyed\n" }
>
> package Foo::Bar;
>
> my $var = new Tracer;
>
> sub f { return $var }
>
> then doing
>   undef &Foo::Bar::f;
> or
>   undef *Foo::Bar::f;
>
> causes the "object destroyed" message to be printed, but
>
>   delete_package("Foo::Bar")
>
> does not. (Until the program actually ends.)
>
> Not doing the undef's, or only doing undef &Foo::Bar::f, seems to
> result in memory leakage. Doing an undef *Foo::Bar::f seems not to
> leak memory, but it's not quite what I want to do.

OK. As I've understood the sufficient method is to recover all symbols
contained in the package (wonder, howto do it?) and undef them. On the
other hand - it's a problem for the PERL developers to help with (I
haven't seen it's internals).

Sergey


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Mon, 29 Jan 2001 03:22:28 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: How to unload module from memory?
Message-Id: <Ul5d6.159741$P82.19448546@news1.rdc1.ct.home.com>

tigra@sky.deep.ru wrote:
> Hi.

> I want to implement something akin Apache::Registry on my own. The
> problem is that I want to unload modules when some time expires but
> don't know how to do this. Reloading modules seems doesn't expose any
> problems: just undef all module's functions and eval the source again.
> But what about undefining the module itself in case I don't need it
> anymore (but I do need the memory it consumes)? Do I really need this or
> the black magic of garbage collection does this job?

You can't really and truly clean out a module that's no longer needed,
especially if it's got any C code associated with it. (Either XS or
from the Inline module) The best you can do is completely clean out the
symbol table for the module which should toss most of the variables.
I'm pretty sure that it won't clean out all the memory taken up by
the code in the module, and you'll definitely need to jump through
a number of extra odd hoops if you want to reload a particular module.
You have a remote chance of being able to do that if it's all perl,
but I wouldn't even try for modules with XS code attached.

People seem to want to do this infrequently--is it something we should
spend time architecting in for perl 6? Dynamically unloading (and then
potentially reloading) modules hasn't ever struck me as something
worth the time to do, but that certainly doesn't mean it isn't worth
doing.

				Dan
		(Speaking as official Perl 6 internals guy)


------------------------------

Date: Mon, 29 Jan 2001 03:34:20 GMT
From: tigra@sky.deep.ru
Subject: Re: How to unload module from memory?
Message-Id: <952obt$slr$1@nnrp1.deja.com>

In article <87d7d7p0zi.fsf@erlenstar.demon.co.uk>,
  Andrew Gierth <andrew@erlenstar.demon.co.uk> wrote:
> >>>>> "tigra" == tigra  <tigra@sky.deep.ru> writes:
>
>  tigra> But what about undefining the module itself in case I don't
>  tigra> need it anymore (but I do need the memory it consumes)? Do I
>  tigra> really need this or the black magic of garbage collection does
>  tigra> this job?
>
> I've done some experimenting with this, with not entirely satisfactory
> results.
>
> There's a delete_package() function provided in the Symbol module (at
> least in 5.005_03 which I'm using). Unfortunately it doesn't seem to
> do a good enough job; if a function in a module refers to a lexical
> variable, then calling delete_package() on the module does not cause
> the destruction of the variable's contents, though doing an explicit
> undef on the function does cause the variable to be destroyed.
>
> i.e. given something like this:
>
> package Tracer;
>
> sub new { return bless [] }
> sub DESTROY { print "object destroyed\n" }
>
> package Foo::Bar;
>
> my $var = new Tracer;
>
> sub f { return $var }
>
> then doing
>   undef &Foo::Bar::f;
> or
>   undef *Foo::Bar::f;
>
> causes the "object destroyed" message to be printed, but
>
>   delete_package("Foo::Bar")
>
> does not. (Until the program actually ends.)
>
> Not doing the undef's, or only doing undef &Foo::Bar::f, seems to
> result in memory leakage. Doing an undef *Foo::Bar::f seems not to
> leak memory, but it's not quite what I want to do

Just a guess. I looked into the sources of Symbol.pm. It does actually
something like cleaning the whole symbol table of the specified package
with all variables, hashes, arrays, etc.
It's somewhat a hack which may not go the same way as 'undef' does.
Seems that DESTROY isn't called automagically when the reference to an
object from symbol table is wiped out, but 'undef' do does an explicit
call to it.
It's just a guess. What 'undef' actually does can be found only in perl
sources (unfortunately I had no time yet to cope with them)

Sergey


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: 29 Jan 2001 02:53:28 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: html link on perl created dynamic webpage
Message-Id: <952lv8$o5i$0@216.155.33.38>

In article <94smo7$c69$1@nnrp1.deja.com>, Dave Brondsema 
<brondsem@my-deja.com> wrote:

 | In article <94sfou$5dn$1@nnrp1.deja.com>,
 |   davidmonroe@my-deja.com wrote:
 | > I'm new to Perl and am having difficulty putting a link in a page
 | that was
 | > generated by a Perl script.  This is what I have and it does not work.
 | >
 | > print "\n<a
 | href="http://www.atgl.spear.navy.mil/feedback/trnofmod.htm">View
 | > your submission here</a><br>";
 | 
 | Since you double quote what you are trying to print, you can't have
 | double quotes within that.  Here are some alternatives:
 | 
 | print "<a href=\"escaped\">asdf</a>";
 | print '<a href="single quotes">asdf</a>';
 | print qq~<a href="qq operator">asdf</a>~;
 | print qq(<a href="qq operator is my favorite">asdf</a>);

ugh.

#!/path/to/perl -w
use strict; #mentioned, as always, in case you aren't. ;) 
 ...
use CGI 2.74 qw/:standard -no_xhtml/;
 ...
#included target also to show 'how it could/should be done'...
print a({-href=>'http://www.atgl.spear.navy.mil/feedback/trnofmod.htm', 
         -target=>'new'}, 
        "View Your Submission here"), 
      br(); # br can be done with or without the sub parens, i.e...), br;
 ...

Since I discovered how much 'neatening' the code recieves using CGI.pm, 
I'm loathe to do it any differently unless compelling reasons exist in a 
particular implementation. Much easier to read, ney?

 HTH

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


------------------------------

Date: Mon, 29 Jan 2001 04:47:34 GMT
From: Rob <a565a87@my-deja.com>
Subject: Re: mod_perl Perl:
Message-Id: <952sl5$vu5$1@nnrp1.deja.com>

Tigra and Brian,

Thank you both for responding to my post.

Yes, about 3 days ago I went and bought the MacEachern/Stein "Writing
Apache Modules with Perl and C" after going to the bookstore repeatedly
to browse that and other titles over the past week or so.  I hadn't
bought a book in several months and was torn between that and buying
the Camel or others first, but lightning struck and I had to have it.

Your answers clear up remaining uncertainty I had about the perl-
mod_perl connection.  When I delve into the book and do some examples,
I just want to be reassured at some point that my projects are in fact
utilizing mod_perl (only because I know so little about CGI scripts to
begin with).  I wouldn't want to start writing CGI scripts for Apache,
only to find out later that my stuff wasn't even touching upon the
mod_perl I have and thought was been used.

I guess after reading the book and knowing more about the technology,
I'll feel more confident that mod_perl will actually be actively
engaged.  (With the knowledge I have at this point about server
creation, I wouldn't know the difference.)

Thanks again,
-Rob


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Mon, 29 Jan 2001 02:32:10 GMT
From: Mario <m_ario@my-deja.com>
Subject: Re: New way to learn Perl?
Message-Id: <952knb$prt$1@nnrp1.deja.com>

In article <94sqbc$flf$1@nnrp1.deja.com>,
  jqcordova@my-deja.com wrote:
> I've spent the last couple of years building well-known e-commerce
> sites using Open Source code. Turns out that I spent a fair amount of
> time teaching Perl (especially object oriented Perl) to jr.
> programmers. I found that the most effective way to impart knowledge
> was the so-called Socratic method of question/answer. I got so tired
of
> going through the question/answer ritual with each new engineer, that
I
> put together a website  www.codecity.com to do the job for me. Now,
> it's taken on a life of it's own and I thought I would tell this group
> about it as you may find it useful too. If you could provide some
> feedback and maybe even submit a quiz or two through the site, it
would
> be highly appreciated.

It blocks on the question 'who created python?'.

You should also try to make it more easy and fast to add a quiz.

Some questions are pretty annoying,as 'how many lines of code is the
perl interpreter?'. Honestly ... who cares?:-)

My last advice is to have at least 2-3 different levels of difficulty.

--
Mario
diab.litoATusa.net


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Sun, 28 Jan 2001 22:19:17 -0600
From: Bin - Lu <b0l4549@cs.tamu.edu>
Subject: passing parameter
Message-Id: <Pine.SOL.4.10.10101282218350.285-100000@robert>

Hi,


I'm writing a 'server side image map'. The code is as follows:

 ...
<form action="http://..../image.pl">
<INPUT NAME="image" TYPE="IMAGE" SRC="banner.jpg">
 ...

When calling the Perl cgi file, I have:
http://..../image.pl?image.x=244&image.y=164

In image.pl, I have

#!/usr/bin/perl -w

#print "content-type: text/html\n\n";

$x=$ENV{QUERY_STRING};
$y=$ENV{QUERY_STRING};            
print "image x is: $x";
print "image y is: $y";

But the image.pl is not running correctly. Does anybody what's wrong with
my code? Thanks a lot!

Bin            



------------------------------

Date: Mon, 29 Jan 2001 03:38:43 GMT
From: Joel Nelson <extramail@home.com>
Subject: Re: Perl programmer wanted
Message-Id: <3A74E597.60AAAB01@home.com>

> >One simple task, $30 or less. Possible admin or mod allowances at a UBB, the
> >Poketavern as a reward also.
> >
> >
>
>         Wow, I've always wanted Poketavern, whatever that is. Is that
> where a Pokeman goes to get drunk?

Found myself laughing outloud to that response!!!  :-)

Joel



------------------------------

Date: Mon, 29 Jan 2001 02:47:10 GMT
From: Mario <m_ario@my-deja.com>
Subject: Re: Perl with Windows98
Message-Id: <952ljd$qe4$1@nnrp1.deja.com>

In article <5x0d6.982660$%C1.12691639@Flipper>,
  "Appie" <a.pietersspam@chello.nl> wrote:
> I've tried to run cgi-scripts on my machine. I have got Perl
installed. I
> have got PWS installed. The only thing that happens is that I get a
DOS
> screen where the script runs and then the DOS screen closes again.
There
> must be something basicly wrong. I can not figure it out. Is there
someone
> who can help me?
>

The dos screen is the perl script running in its standard
environment,that is not the CGI.It closes after executing it or when an
error occurred.

If you installed PWS properly,be careful that the server is running and
that your scripts are in the right directory (I guess inetpub/www/cgi-
bin,don't remember exactly).

However my friendly advice is to install Apache for windows.Despite of
what you may think it is much more easy to make it work than the PWS.

http://www.apache.org

--
Mario
diab.litoATusa.net


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: 29 Jan 2001 02:35:08 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Problem renaming under Win32
Message-Id: <952kss$j8r$1@bob.news.rcn.net>

Richard Muller <rlmuller(at)msn.(dot)(deletethis).com> wrote:
> The following code is intended to rename files I downloaded in the past when
> two-digit years were adequate. But names like that don't sort
> satisfactorily.  I decided to try and rename them automatically.  But my
> rename  command failed.

> Can anyone suggest why rename failed?

perl can.  rename (...,...) or warn "rename failed: $!";

> ...
> while ( glob($dir . "\\*") )
> {
>      if( /WDJ-099/i )
>     {
>           print "$_\n";
>           $RevisedName = s/WDJ-099/WDJ1999./i;

This isn't doing what you think it is.  It substitutes the first
occurrence of WDJ-099 to WDJ1999 in $_ and sets $RevisedName to the number
of substitutions made (which in this case will always be 1).  The original 
filename will have been lost.

>           my $nRet = rename($_, $RevisedName);

If the original filename was "WDJ-099.txt" this will expand to

  rename("WDJ1999..txt",1);

>           print "$_ <== " . ($nRet?"":"not") . " changed\n";
>           $nFilesChanged++ if( $RevisedName !~ /WDJ-099/i );
>     }
> }


------------------------------

Date: Sun, 28 Jan 2001 18:16:40 -0800
From: Peter <anon@anon.com>
Subject: Re: substition problem
Message-Id: <MPG.14de726520b894599896a8@news.supernews.com>

In article <ae8ccht1.fsf@pobox.com>, jdf@pobox.com says...
> Peter <anon@anon.com> writes:
> 
> > I'm having trouble substituting these two strings using the substitution 
> > operator. I'm getting syntax errors, I don't know what needs a backslash 
> > and what doesn't.
> 
> You didn't post your code, so there's no telling where you've gone
> wrong.
> 
> 

Your news reader is probably trying to decode the HTML. It's there.


------------------------------

Date: 29 Jan 2001 02:59:40 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: ternary conditional operator
Message-Id: <952mas$o5i$1@216.155.33.38>

In article <x7elxquinl.fsf@home.sysarch.com>, Uri Guttman 
<uri@sysarch.com> wrote:

 | your precedence is wrong. ?: binds tighter than =
 | 
 | regardless, you should do it this way:
 | 
 | $redirto = $director =~ /else/ ? "yes" : "no" ;
 | 
 | uri

heh I'm glad I'm reading today -- I'd completely forgotten this little 
factoid. :)

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


------------------------------

Date: 29 Jan 2001 02:40:10 GMT
From: chenb@red.seas.upenn.edu (Benjamin Chen)
Subject: Unicode and URL encoding
Message-Id: <952l6a$mi1$1@netnews.upenn.edu>

Hi all,

  Thanks for replying but what I really wanted to do was convert the 
unicode character representation of the form $#xxxx; using some sort of
function in Perl.  My CGI script grabs the key/value pairs using the CGI
perl module.  I actually found a way around the problem recently by
changing my POST to a GET in the html form.  I am still curious as to whether 
or not you can take the unicode representation and convert it into the
characters.  Sorry if I wasn't too clear.  Thanks!  (I posted here since
I couldn't find a cgi script newsgroup.  If someone could point me to one
that would be great.  Thanks again.)

-Ben

--


------------------------------

Date: Mon, 29 Jan 2001 02:50:59 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Unicode and URL encoding
Message-Id: <Pine.LNX.4.30.0101290243250.14190-100000@lxplus003.cern.ch>

On 29 Jan 2001, Benjamin Chen wrote:

>   I was trying to create a script which will take in foreign
> language character sets that use Unicode (Chinese, Korean, etc)
> and ran into a slight snag. When the user enters in the characters
> into the textfield and submit the form (I use a POST method) the
> majority of the time, I get something like this as the outcome:
> &#19971;

I'm not at all sure what you think this has to do with Perl, and I
personally have little experience with CJK situations, but I've taken
a look at form submission issues and this might conceivably help as a
starting point (at least, I wasn't able to find anything better, so I
tried to write something myself)

http://ppewww.ph.gla.ac.uk/~flavell/charset/form-i18n.html

If you have any input, then I'd be glad to quote it with appropriate
attributations.  Whether the c.l.p.misc group wants to hear about it
is a different question, though.  Regulars, what say you?

> The outcome should have been a "random" assortment of ascii characters.

I'm sorry, I can't make any sense of that assertion.  ASCII is a 7-bit
coding, that can represent only a tiny repertoire of characters, none
of which have any relevance to CJK. Are you talking about octet (byte)
values in your favourite CJK coding, or what?

Disclaimer: I don't really grok CJK codings, I'm just interested in
the technology of character representation.

all the best



------------------------------

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 164
**************************************


home help back first fref pref prev next nref lref last post