[12173] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5773 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 25 11:07:20 1999

Date: Tue, 25 May 99 08:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 25 May 1999     Volume: 8 Number: 5773

Today's topics:
    Re: FAQ 8.18: How can I do an atexit() or setjmp()/long (Andrew Allen)
    Re: Finding the date... <dgris@moiraine.dimensional.com>
    Re: Ho to get started with Tk on Win32? <lusol@Pandora.CC.Lehigh.EDU>
    Re: Ho to get started with Tk on Win32? <gellyfish@gellyfish.com>
    Re: How can I "poll" the serial port ?? <ricklim@vcn.bc.ca>
    Re: How can I "poll" the serial port ?? <ricklim@vcn.bc.ca>
    Re: In favor of extending "my" to apply to subroutines  <kensai@nortel.com>
    Re: In favor of extending "my" to apply to subroutines  <tchrist@mox.perl.com>
    Re: jerri rigged forms instead of CGI... bad? <jeromeo@atrieva.com>
    Re: need an anti-leech script <garethr@cre.canon.co.uk>
    Re: need an anti-leech script (Sam Holden)
        O'Reilly's Programming Web Graphics with Perl & GNU Sof <jeremy@microlink.net>
    Re: Perl "constructors" <emschwar@rmi.net>
    Re: Perl "constructors" <emschwar@rmi.net>
    Re: Perl on Win32 - How can I hide the process? <perin@panix7.panix.com>
    Re: Printers <gellyfish@gellyfish.com>
    Re: re-webifying strings for GET methods <jdporter@min.net>
    Re: removings " "s from strings (Tad McClellan)
    Re: Return of array <jdporter@min.net>
    Re: Return of array <kensai@nortel.com>
    Re: simple question <gellyfish@gellyfish.com>
        substituting string with current date (EXCHANGE:SKY:6S34)
    Re: substituting string with current date (Sam Holden)
    Re: XS programming (HELP!) newbie... <craig@mathworks.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 24 May 1999 17:10:07 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: FAQ 8.18: How can I do an atexit() or setjmp()/longjmp()? (Exception handling)
Message-Id: <7ic15f$4li$1@fcnews.fc.hp.com>

[posted and mailed]

Tom Christiansen (perlfaq-suggestions@perl.com) wrote:
:     If exception handling is all you're interested in, try the
:     exceptions.pl library (part of the standard perl distribution).

Perhaps Error.pm should also be mentioned here. In fact, perhaps
mentions of *.pl libraries in the docs should be vaguely deprecated ;)

Andrew


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

Date: Tue, 25 May 1999 14:51:30 GMT
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Finding the date...
Message-Id: <SNy23.925$x11.4206@wormhole.dimensional.com>

fl_aggie@thepentagon.com (I R A Aggie) writes:

> Larry R. has a function that does this correctly, and has been submitted
> to the PFR (Perl Function Repository), and should be in Deja.com. It is
> only for 1 day, but the number of days should be a trivial modification...

Minor correction--it was Russ Allbery who wrote the code in
question.  It's available from-

http://moiraine.dimensional.com/~dgris/cgi-bin/pfr?func=yesterday&type=exact

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: 25 May 1999 13:32:28 GMT
From: "Stephen O. Lidie" <lusol@Pandora.CC.Lehigh.EDU>
Subject: Re: Ho to get started with Tk on Win32?
Message-Id: <7ie8pc$tje@fidoii.cc.Lehigh.EDU>

Leon <leonandrews@my-dejanews.com> wrote:
> Hi,

> Can anyone point me to any examples of how to get started with Tk?

> I have all of the modules, but there don't seem to be any demo programs
> to try. Also, do I need to install any more software to get Tk to make
> windows Apps? Will a simple "hello world" type of program written in
> Perl using Tk fire up a Windows window?

You give no what/how details, but any proper Perl/Tk installation comes
with the "widget" program, which you can run from any DOS window... 


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

Date: 25 May 1999 15:17:23 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Ho to get started with Tk on Win32?
Message-Id: <374ab0f3@newsread3.dircon.co.uk>

Leon <leonandrews@my-dejanews.com> wrote:

Subject: Ho to get started with Tk on Win32?

I was just intrigued by that subject line - is this some kind of
neighbourhood community action scheme ;-}

> Hi,
> 
> Can anyone point me to any examples of how to get started with Tk?
> 
> I have all of the modules, but there don't seem to be any demo programs
> to try. Also, do I need to install any more software to get Tk to make
> windows Apps? Will a simple "hello world" type of program written in
> Perl using Tk fire up a Windows window?
> 

There are demo programs - just try typing 'widget' at your command prompt

On my windows machine the demos are in C:\Perl\site\lib\Tk\demos

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: 25 May 1999 12:17:02 GMT
From: Rick Lim <ricklim@vcn.bc.ca>
Subject: Re: How can I "poll" the serial port ??
Message-Id: <7ie4bu$mad$1@sylvester.vcn.bc.ca>

I am on a UNIX system, I'll give it a try,
Thanks for the suggestion.



Abraham Grief <abey@cs.ucr.edu> wrote:


: On 23 May 1999, Rick Lim wrote:

:> I have tried
:> open(SERIALPORT, "+>$Port");
:> then a
:> $sStringFromPort .= <SERIALPORT>;
:> but if there is no data in the serial port then
:> the program just blocks until something arrives.
:> what I would like to do is just poll the port and
:> if there is data then process it otherwise the program
:> carrys on, the idea is to send data to the serial port
:> and test for a response if not do some other process.


: I've never tried it on a serial port, but if you're on some sort of Unix,
: this might work:

: sysopen(SERIALPORT, $Port, O_RDWR|O_NDELAY);

: Hope this helps.



-- 
The wealth of reality, cannot be seen from your locality.


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

Date: 25 May 1999 12:18:46 GMT
From: Rick Lim <ricklim@vcn.bc.ca>
Subject: Re: How can I "poll" the serial port ??
Message-Id: <7ie4f6$mad$2@sylvester.vcn.bc.ca>

I'll read that, thanks for the suggestion.

Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote:
: On 23 May 1999 05:16:02 GMT, Rick Lim <ricklim@vcn.bc.ca> wrote:
:>I have tried
:>open(SERIALPORT, "+>$Port");
:>then a
:>$sStringFromPort .= <SERIALPORT>;
:>but if there is no data in the serial port then
:>the program just blocks until something arrives.
:>what I would like to do is just poll the port and
:>if there is data then process it otherwise the program
:>carrys on, the idea is to send data to the serial port
:>and test for a response if not do some other process.

: perldoc -f select


: -- 
: Sam

: If your language is flexible and forgiving enough, you can prototype
: your belief system without too many core dumps.
: 	--Larry Wall

-- 
The wealth of reality, cannot be seen from your locality.


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

Date: Tue, 25 May 1999 09:30:56 -0400
From: digital kensai <kensai@nortel.com>
Subject: Re: In favor of extending "my" to apply to subroutines as well as variables
Message-Id: <374AA610.375EC9E9@nortel.com>

Steven Elliott wrote:

> Currently in perl there is no way of directly marking a
> subroutine/method as being private to a given file/module (assuming one
> module per file).  In C this can be accomplished using the "static"
> keyword.  In C++ it can be accomplished using the "private" keyword
> (assuming one class per file).  I realize there are various ways of
> indirectly accomplishing this as the following demonstrates:
> ----------PrivateSubs.pm ---------------
> package PrivateSubs;
>
> ### private methods ###
> # technique #1
> my $private_method_1 = sub
> {
>     print "1: This private method was implemented using an anonymous ".
>           "subroutine.\n";
> };

> I think there would be a significant benefits to extending the "my"
> keyword in order to allow technique #4.  These benefits include:
> 1) A Compiler enforced scope rule would be universal whereas mere naming
> conventions (techniques techniques #2 and #3) may vary from project to
> project.  For example, one project may interpret "_" to mean private to
> a given file whereas another might interpret it to mean private to a
> given class.  Trying to intermix code that differs in such a way would
> be tricky.
> 2) There is nothing to "grep" for in order generate a list of all
> private methods.  This makes it difficult to create tools that parse and
> display perl object hierarchies.
> 3) There might be some performance gains by perl that could be made if
> it was known that a given subroutine could not be invoked a outside of a
> given file, assuming a reference to it was not returned.

Using method #1 would be universal (there is no such creature "public
anonymous method"), and it is grep'able (pattern like "my .* sub").

Why would you want ANOTHER interesting use of "my", given that this one
works?



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

Date: 25 May 1999 08:21:35 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: In favor of extending "my" to apply to subroutines as well as variables
Message-Id: <374ab1ef@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, elliotsl@mindspring.com writes:
:Currently in perl there is no way of directly marking a
:subroutine/method as being private to a given file/module (assuming one
:module per file).  

I have good news and bad news.

The good news is that the next major release of Perl (5.006, expected
later this summer) will implement "my sub".  

The bad news is that it this is irrelevant to method calls.
A method call finds a subroutine by the name it holds in the 
symbol table of its referent.  If it's my(), it's not in the
symbol table.  If it's not in the symbol table, it's not a method.

Tell me, have you read what the perltoot manpage says about "Closures as
Objects"?  Also, I perceive that you are cursed by C++/Java-braindamage.
Have you read the new perltootc manpage?  It's a new tutorial that
shows how to cast off the chains of C++ so you can use simple, native
Perl idioms to manage class and object attributes in your Perl object
classes by revealing OO strategies and techniques a C++ programmer would
never imagine.

    POD
	http://language.perl.com/misc/perltootc.pod
    HTML
	http://language.perl.com/misc/perltootc.html
    POSTSCRIPT
	http://language.perl.com/misc/perltootc.ps
    MANPAGE
	http://language.perl.com/misc/perltootc.man
    ASCII TEXT
	http://language.perl.com/misc/perltootc.text

Until you stop asking "How can I do this C++/Java construct in Perl"
and instead start asking "Here's this task I need to do; now, how do I
do it in Perl", you'll be forever disappointed.  And vice-versa.

--tom
-- 
    "Winter is worth its wait in cold." --Larry Wall


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

Date: Tue, 25 May 1999 07:39:56 -0700
From: Jerome O'Neil <jeromeo@atrieva.com>
To: Bob Trieger <sowmaster@juicepigs.com>
Subject: Re: jerri rigged forms instead of CGI... bad?
Message-Id: <374AB63C.1406C157@atrieva.com>

Bob Trieger wrote:

> >> I generally just do a
> >> print >>EOD;
> >>    lots of HTML goes here
> >> EOD
> >
> >It's not bad form.  In many cases, it's preferable.
> 
> May I suggest you look at his code again.

I realize it's broken, but that wasn't the question.  Were it "Why does
this give me an error?", it would be more germaine to the answer to
which the fellow was looking.


-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: Tue, 25 May 1999 14:01:34 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: need an anti-leech script
Message-Id: <si7lpxckox.fsf@cre.canon.co.uk>

Henjo <henjo@deadlock.et.tudelft.nl> wrote:
> I'm constantly losing bandwidth because other people are linking
> directly to my files.

Your problem is that you are making your files available for other
people to link to.  Try removing the files.

-- 
Gareth Rees


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

Date: 25 May 1999 14:35:20 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: need an anti-leech script
Message-Id: <slrn7kld98.b5a.sholden@pgrad.cs.usyd.edu.au>

On 25 May 1999 07:50:20 -0700, Tom Christiansen <tchrist@mox.perl.com> wrote:
>     [courtesy cc of this posting mailed to cited author]
>
>In comp.lang.perl.misc, John Porter <jdporter@min.net> writes:
>:You might try checking the 'Referer' header (which in CGI is usually
>:the HTTP_REFERER environment variable), and deny the service to any
>:referer which is not on your own site.
>
>That's rude.  Fortunately, it's trivial to spoof.  Anybody who relies on
>the referrer is silly.  If he doesn't want it viewed, he should remove
>it from the net.

But it is probably a good enough solution if the server has smallish
bandwidth, and web pages from other unrelated sites without permission
keep linking to images, etc on that server. They are meant to be viewed,
just as part of the site they are made for, not for every other site
on the web. If someone wants to copy them then they can copy them and use
the copies surely...

Yes it's trivial to spoof, but it stops someone putting up a simple link
from their page, since they can't go and set the browsers of everyone who
might visit their site to spoof the Referer. A CGI script on the 'stealing'
site could get around it simply, but that would require effort and
probably knowledge not possessed by the average web page author...

You shouldn't have to do such a thing, but if your bandwidth is being 
sucked up by other people using your graphics or whatever on their sites
then it might be warranted.

The extra CGI overhead might be a bit expensive, but the web server might
have such functionality built in.

The better solution would be to set up a cron job or whatever that renames
all the files every so often and fixes up all the HREFs... Then again that
would cause needless downloading for cached files...

I'm guessing that is the problem the poster is worried about.

Looking at the logs and seeing the files that are affected and replacing just
those files with something ugly might be a good enough solution too...

-- 
Sam

compiling kernels is what I do most, so they do tend to stick to the
cache ;)	--Linus Torvalds


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

Date: Mon, 24 May 1999 13:11:22 -0500
From: "Jeremy Fowler" <jeremy@microlink.net>
Subject: O'Reilly's Programming Web Graphics with Perl & GNU Software - Has anyone gotten this script to work?
Message-Id: <7ic4pt$eqh$1@remarQ.com>

In Chapter 10: Web Graphics Cookbook, I haven't been able to get the
counter.pl script to work. It seems to get stuck on or about the forth
unless function:

unless ($referer =~ /http:\/\/($users)(.*)/) {
    exit $error->black_box('You do not have privilages to access this
counter.');
}

If I write it out word for word from the book it doesn't work (Perl doesn't
give any errors with -w and "use strict" is called, so it must be logic
errors). I've tryed all kinds of things including just commenting the
statement out all together but when I do that I get "Segmentation fault" and
the script doesn't run at all. Also, for some reason after I played with the
code a little, I get 3 other wierd error that makes no sense to me:
"Use of uninitiated value at ./counter.pl line 69, <COUNT> chunk 1."
"Use of uninitiated value at ./counter.pl line 73, <COUNT> chunk 1."
"Use of uninitiated value at ./counter.pl line 88, <COUNT> chunk 1."

What is a Segmentation fault? I can't find any refferance to what this is
anywhere.

Has anyone else tried running this script out of the book? Has anyone been
able to make it work?

If someone has an answer to any of these questions, please email me back if
you can help, since I am unable at this time to sort through 30,000
newsgroup posts to find an answer.

Thanks,
-Jeremy-
jeremy@microlink.net

Please visit my homepage at http://www.microlink.net/~jeremy/


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

Date: 24 May 1999 10:08:44 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Perl "constructors"
Message-Id: <xkfn1yuh2lv.fsf@valdemar.col.hp.com>

kaih=7HPvvhDXw-B@khms.westfalen.de (Kai Henningsen) writes:
> emschwar@rmi.net (Eric The Read)  wrote on 21.05.99 in <xkfvhdmgjy4.fsf@valdemar.col.hp.com>:
> 
> > And there's *still* no way to automatically die on an uncaught exception.
> 
> Huh? I must not be getting something here. How do you not die on an  
> uncaught die()? Seems a contradiction to me.

#!/usr/bin/perl -w

eval { die "ack!"; };

print "returning normally\n";
exit 0;
__END__

Since eval is perl's version of try, I'd expect the uncaught die() in
there to propogate upward, and cause a die() in the outer program-- if it
were really an exception.  Since it's not really an exception, it doesn't
require a catch (or, in the case of Perl, a "if($@) {...}".

-=Eric


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

Date: 24 May 1999 10:24:24 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Perl "constructors"
Message-Id: <xkfk8tyh1vr.fsf@valdemar.col.hp.com>

zenin@bawdycaste.org writes:
> Eric The Read <emschwar@rmi.net> wrote:
> 	It stores it one place, yes.  That does not in any way however,
> 	preclude the exception from taking many forms.  $@ can hold a
> 	blessed reference, thereby allowing it to hold any form of exception
>	class (or string) the user sees fit.

My bad.  Using a blessed reference, $@ is essentially no different from
saying "catch(IOException e) {...} catch (Exception e) { ... }

> : Until something like that's folded into the language itself,
> 
> 	It is.  Error.pm was originally built before $@ could hold a
> 	reference, but now it's just a pretty wrapper around the real
> 	internals.

Sorry, I'm stuck back on 5.004_04; I don't have Error.pm.  I concede
again.

> : there's still no way to automatically propagate exceptions.
> 
> 	Sure there is, just don't catch them.  When you do catch them by
> 	mistake, rethrowing them is trivial.

Er, I'm going to have to assume that that's in Error.pm somewhere.
Because otherwise, I don't see how a simple 

eval { die "d'OH!"; } ;

propogates that die outside the eval block.  Which seems to me (please
correct me if I'm wrong) what you're saying.

> : Right now, Perl can't assume that $@ has been blessed at all,
> 
> 	Does it matter?  Seriously.

I thought so, at the time.  Then I tried your next trick, and discovered
it works on non-blessed references, which I didn't expect.  Why?

> 	if ($@->isa("Some::Exception")) {

perlop.pm says that if the RHS of -> is a method name (isa, in this
case), the LHS, $@, must be either a blessed reference, (which in my
eval, above, it isn't), or a package name.  Given that "d'OH!" is not a
package (not that *I* know of, anyway :), and it's not a blessed
reference, how can this not cause at least one error?  Maybe two-- the
LHS is neither of the things it ought to be, and the RHS isn't a defined
function in *any* package.

Please note I'm not necessarily saying that it *should*-- though it
certainly looks to me like it ought to-- I just don't understand why it
doesn't.  And under the influence of strict.pm, no less!

> : And there's *still* no way to automatically die on an uncaught exception.
> 
> 	use Fatal;

$ perldoc Fatal   
No documentation found for "Fatal".

Again, this is probably because I'm using an older version of perl.  Yes, 
I've asked for it to be upgraded.  No, it's not likely to happen in the
near future.  Yes, I'm annoyed.

-=Eric


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

Date: 25 May 1999 10:15:21 -0400
From: Lewis Perin <perin@panix7.panix.com>
Subject: Re: Perl on Win32 - How can I hide the process?
Message-Id: <pc7lnednsli.fsf@panix7.panix.com>

Thomas/Shurflo <thomas@shurflo.com> writes:

> Actually I believe that option is to be used when STARTing another batch
> file(other than the calling batch file). And that's not the problem. I'm
> looking on how to hide the DOS box that Perl uses when it starts.
> Lewis Perin wrote:
> 
> > Thomas/Shurflo <thomas@shurflo.com> writes:
> >
> > > Anyone know how I can hide the process (dos box) that starts when I run
> > > a Perl script? It could take a while to run and I don't want users
> > > seeing it.
> > >
> > > I've been through the manuals and the newsgroups.
> >
> > In a DOS box on the NT or 9X system you use, type
> >
> >   start /? | more
> >
> > and you'll see the info you seek.

I don't have a 9X machine handy, but on my NT machine "start /min"
works for all executables, not just batch files.

Cheers, Lew


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

Date: 25 May 1999 15:20:08 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Printers
Message-Id: <374ab198@newsread3.dircon.co.uk>

Arthur Merar <amerar@unsu.com> wrote:
> 
> 
> Hello,
> 
> I am fairly new to Linux.  I just installed Red Hat 5.2.  My network
> consists of a Windows 98 box, my Linux box and an HP LJ 4M+ network
> printer.
> 

And what exactly does this have to do with Perl ? I think you must have
made a typo with the newsgroup name - I think you want a group in
the comp.os.linux.* hierarchy.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 25 May 1999 13:49:57 GMT
From: John Porter <jdporter@min.net>
Subject: Re: re-webifying strings for GET methods
Message-Id: <7ie9q5$rd4$1@nnrp1.deja.com>

In article <374A1A5B.4278@acwilm.com>,
  younggs@acwilm.com wrote:
>
> Does anyone have a code snippet for re-webifying plain text?
> I want to create some HTML on the fly that includes links made from
> database text. For instance if
>   my $str="cool stuff at #E-13."  (just a stupid example, of course)
> so I would need create
>   <a href="http://somesite.com?str=cool+stuff+at+%23E-13">

If you are using CGI.pm, you can call the subroutine named
CGI::escape.  Given a string, it returns the properly escaped form
of it.

The "official" way, and more flexible, is to use the URI::Escape
package.  perldoc URI::Escape for more info.

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Tue, 25 May 1999 05:21:37 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: removings " "s from strings
Message-Id: <13qdi7.j8k.ln@magna.metronet.com>

Daniel Vesma (daniel.vesma@thewebtree.com) wrote:

: >If I'm not mistaken, this is in the FAQ. To prevent any more braindamage,
: >I suggest you to keep it within reach :)


: Thanks lots, do you mean the URL of the newsgroup. 


   No.


: If so, can you point me
: to the URL? I don't see the message,
                          ^^^^^^^^^^^


   I dunno what you're talking about.

   I think you don't know what we're talking about either  :-)



   The Perl Frequently Asked Questions (FAQ) are *included* with
   the perl distribution.

   If you have perl installed, you should have some version of the
   FAQs already on your hard disk somewhere.

   Find out where they are on your system, and use them often.



   If you must go the slower route, then you can access the FAQs at:

      http://language.perl.com/faq/index.html


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 25 May 1999 13:58:41 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Return of array
Message-Id: <7ieaag$rpg$1@nnrp1.deja.com>

In article <374A9E8F.2270F562@webline.dk>,
  Kaare Rasmussen <kar@webline.dk> wrote:
>
> Trying to make an OO module with a subprocedure that assigns a
reference
> to an array to $self{'var'}
> Something like
>
> sub sub {
>  my @var = qw(var1 var2 var3);
>  $selv->{'var'} = \@var;
> }

Yes, this should work fine.


> How can I dereference $selv->{'var'} after sub sub has been called?

Like this:

sub sub {
  my @var = @{ $selv->{'var'} };
}

Please read perldoc perlref, perllol, and perldsc.

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Tue, 25 May 1999 10:12:10 -0400
From: digital kensai <kensai@nortel.com>
Subject: Re: Return of array
Message-Id: <374AAFBA.A8C7324E@nortel.com>

Kaare Rasmussen wrote:

> Hi
>
> Trying to make an OO module with a subprocedure that assigns a reference
> to an array to $self{'var'}
>
> Something like
>
> sub sub {
>  my @var = qw(var1 var2 var3);
>  $selv->{'var'} = \@var;
> }
>
> How can I dereference $selv->{'var'} after sub sub has been called?

You have it exactly.  You don't even have to explicitly use a return
statement
(see perlsub manpage).  Here's an example:

ArrayRef.pm
###########
package ArrayRef;

sub new { return bless {}; }

sub retArr {
        my @var = qw(1 2 3);
        $self->{'var'} = \@var;
#return $self->{'var'}; # this is optional
}

1;

arraytest.pl
##########
#!/usr/bin/perl -w

use strict;

require('ArrayRef.pm');

my ($a, $arrayref);

$a = ArrayRef->new;
$arrayref = $a->retArr;

print @{$arrayref}->[0];   #prints 1



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

Date: 25 May 1999 15:40:04 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: simple question
Message-Id: <374ab644@newsread3.dircon.co.uk>

David Cassell <cassell@mail.cor.epa.gov> wrote:
> John Callender wrote:
>> 
>> Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
>> > Howie <noone@home.com> wrote:
>> 
>> >> noone@home.com (Howie) wrote:
>> >> >simple question, but I can't seem to find a reference to it. How do I convert
>> >> >a string to lowercase?
>> 
>> > $email = lc($email);
>> 
>> Anyway, I'm curious about something: It looks to me like this person is
>> thinking of downcasing a bunch of email addresses. My understanding of
>> email addressing conventions is that while it is safe to treat the
>> hostname part of an email address as case-insensitive, to do so with
>> the username part (the part to the left of the @, I mean) runs the risk
>> of rendering a case-sensitive address nondeliverable. I'm curious to
>> know if this bit of folklore I picked up somewhere is actually true,
>> and if so, what sorts of systems might display this sort of behavior,
>> and what people think a reasonable guess would be as to how widespread
>> such behavior is in the general population of email addresses.
>> 
>> So, is there anyone out there who:
>> 
>> 1) knows, or at least has an informed opinion on, the answer, and
>> 2) is actually following this thread, and
>> 3) is willing to violate the subject-matter norms by following up, and
>> 4) hasn't already killfiled me for my off-topic blather?
> 
> I would categorize myself as fulfilling points 2,3, and 4.
> I too have been 'told' that some addresses are case-sensitive.
> But, even with X400 addresses, I have not seen one actually
> fail due to an upper-case/lower-case translation.  Still, that
> could have been due to the gateway/OS at the other end, instead
> of a true X400 resolution.  Nor have I seen a difference when
> sending e-mail to people using particularly-reviled win32-based
> mail systems whose names will be avoided to spare more flamewars
> here.
> 
> I'm sure someone will direct us to the proper RFC, though. 
> At least you don't have to worry about this with addresses
> like *@qz.to .  :-)
> 

Yes - rfc822 :

6.2.4.  DOMAIN-DEPENDENT LOCAL STRING

        The local-part of an  addr-spec  in  a  mailbox  specification
        (i.e.,  the  host's  name for the mailbox) is understood to be
        whatever the receiving mail protocol server allows.  For exam-
        ple,  some systems do not understand mailbox references of the
        form "P. D. Q. Bach", but others do.

And yes X400 systems are case sensitive - try sending mail to someone
at Associated Press with altered case ...

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 25 May 1999 10:36:05 -0400
From: "Khan, Fatima (EXCHANGE:SKY:6S34)" <gsoamst@americasm01.nt.com>
Subject: substituting string with current date
Message-Id: <374AB555.DDBE3467@americasm01.nt.com>

Hello..

I'm trying to do a simple substitution.  Replacing a string with the
current date.

my program grabs the contents of a file, looks for a string matching
/dat.*/ and substitutes with the current date.
I invoke 'date' by using the system function i.e system("date +%Y%m&d)

the file contains the date hard coded like so: Date = 19820506
(yyyymmdd)

so I have

<snip>

if ($_ = /Dat.*/) {
      $_ = s/\d.*/system("date +%Y%m%d");
}

the digits following "Date=" in my file become substituted
with "system('date +%y%m%d')".

How can I substitute it with what the function should do?

fatima.





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

Date: 25 May 1999 14:52:40 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: substituting string with current date
Message-Id: <slrn7kle9o.b5a.sholden@pgrad.cs.usyd.edu.au>

 Khan, Fatima (EXCHANGE:SKY:6S34) <gsoamst@americasm01.nt.com> wrote:
>Hello..
>
>I'm trying to do a simple substitution.  Replacing a string with the
>current date.
>
>my program grabs the contents of a file, looks for a string matching
>/dat.*/ and substitutes with the current date.
>I invoke 'date' by using the system function i.e system("date +%Y%m&d)
>
>the file contains the date hard coded like so: Date = 19820506
>(yyyymmdd)
>
>so I have
>
><snip>
>
>if ($_ = /Dat.*/) {
>      $_ = s/\d.*/system("date +%Y%m%d");
>}
>
>the digits following "Date=" in my file become substituted
>with "system('date +%y%m%d')".

No it doesn't. Not with that code anyway...

$_ = is not what you want. Your missing a / as well. Y ne y.

Have a look at the perlop documentation (perldoc perlop) for information
on the use of s/// and how to evaluate the substitution...

Have a look at perlfunc documentation (perldoc -f system) for information
on why system() does not do what you want.

Have a look at perlop again for information on how to capture the output of
an external program, like the system documentation tells you to.

Have a look at the perlre documentation for information on why \d.* is
probably not what you want to replace (though it might be I guess).

-- 
Sam

So I did some research. On the Web, of course. Big mistake...
	--Larry Wall


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

Date: Tue, 25 May 1999 10:10:29 -0400
From: Craig Ciquera <craig@mathworks.com>
Subject: Re: XS programming (HELP!) newbie...
Message-Id: <374AAF54.66E70093@mathworks.com>

The "Panther Book"  (a.k.a. Advanced Perl Programming) by O'reilly is
pretty good for this sort of thing.

Craig

"D. Emilio Grimaldo Tunon" wrote:

> Didimo Emilio Grimaldo Tunon wrote:
> >
> > Hi XS*,
> >     I am just beginning to get into Perl Extension programming (XS),
> > have read the various manual pages and have gotten something basic
> > working but I have the following questions:
> >
> > 1. The perlxstut man page says that during 'make install' it is
> >    installed in the Perl's system directory (/usr/lib/perl5/...)
> >    but what about being able to install it in 'user space'? say
> >    $HOME/perllib/ ? is that possible? I would hope so, that way
> >    one can try these binary modules before actually installing
> >    them on the system (among other applications...)
> >
> > 2. I have a Perl function that I invoke like:
> >
> >        &SetRequest(\$var1, \@array, \%hash);
> >
> >    but I haven't figured out how to get the thing to either
> >    let var1 be known to the caller or get elements (in the XS)
> >    from the array. The array has strings.
> >
> >    Could somebody give me a short example of how to have the
> >    proper XS stub for this function? what about getting the
> >    string elements of the array? I figured out how to get the
> >    length of the array but that's it :( and if it is not much
> >    to ask (for the sake of an example) obtaining the key and
> >    value of the hash. Both the array and the hash are actually
> >    references-to..
> >
> >    I think that will give me a quick start, in the meantime
> >    I will read the man pages again but I haven't found any
> >    useful, practical example out of it...
> >
>
>      All questions still unanswered, the manual pages left
> them unanswered as well, web search on Perl+XS did not lead
> to anything useful either (only HTML versions of XS manual
> pages). Any true XS tutorial out there with real world
> examples?
>
> --
> D. Emilio Grimaldo Tunon       Compuware Europe B.V. (Uniface Lab)
> Software Engineer              Amsterdam, The Netherlands
> emilio_tunon@nl.compuware.com  Tel. +31 (0)20 3126 516
> *** The opinions expressed hereby are mine and not my employer's ***



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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 5773
**************************************

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