[19044] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1239 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 3 18:10:36 2001

Date: Tue, 3 Jul 2001 15:10:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <994198216-v10-i1239@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 3 Jul 2001     Volume: 10 Number: 1239

Today's topics:
    Re: Module to read binary pgm files <mjcarman@home.com>
    Re: New babies to Perl - FREE Documentation Require (Dave Hoover)
    Re: onMouseover in Perl? <nospam@newsranger.com>
    Re: onMouseover in Perl? (BUCK NAKED1)
    Re: OT: GD::Graph, PNG files and slow loading in web br <tschmelter@statesman.com>
        parallel processes w/perl (abaxaba)
        parsing contents of html form w/net::smtp <e.quesada@verizon.net>
    Re: parsing contents of html form w/net::smtp <tony_curtis32@yahoo.com>
    Re: parsing contents of html form w/net::smtp <e.quesada@verizon.net>
    Re: parsing contents of html form w/net::smtp <e.quesada@verizon.net>
    Re: parsing contents of html form w/net::smtp <tony_curtis32@yahoo.com>
        Performance issues with Perl. (Sam Prince)
    Re: Performance issues with Perl. <djberge@uswest.com>
    Re: Perl 6:   ->   vs  . (Michael G Schwern)
    Re: Perl Script to Remove Email Attachment (Randal L. Schwartz)
    Re: Perl Script to Remove Email Attachment <gerard@NOSPAMlanois.com>
    Re: Please help newbie! <newsman@-takethisout-brol.org.uk>
        Protected Dowloads (SSI?) <member@dbforums.com>
    Re: ref($val) not returning anything? <tschmelter@statesman.com>
    Re: ref($val) not returning anything? <uri@sysarch.com>
    Re: ref($val) not returning anything? <mjcarman@home.com>
    Re: web fetching (Tony L. Svanstrom)
    Re: web fetching (BUCK NAKED1)
    Re: What do you guys think the language of the future w <tmbranno@oracle.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 03 Jul 2001 12:48:28 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Module to read binary pgm files
Message-Id: <3B42056C.8D7CAF9E@home.com>

Andrew wrote:
> 
> Sorry for re-posting this question - I posted it a week or so ago,
> but got sent away to somewhere with no news access and missed any
> replies that there may have been.

You can always check the archives at dejagoogle:
http://groups.google.com

> Basically I'm looking for a way to read a binary pgm file so that
> I can do some processing on it.  I have checked CPAN and found
> references to Image::Magick and Image::Imlib2.  I was unable to
> access any of the files or documentation for Image::Magick, and
> Image::Imlib2 seems like it's intended for Unix (I'm using WinNT).

If you can't (or aren't willing) to use the existing stuff then you'll
have to roll your own solution. The PGM format is really quite simple,
so it shouldn't be difficult. It might make an interesting exercise.

-mjc


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

Date: 3 Jul 2001 11:11:04 -0700
From: redsquirreldesign@yahoo.com (Dave Hoover)
Subject: Re: New babies to Perl - FREE Documentation Require
Message-Id: <812589bb.0107031011.54e75ef1@posting.google.com>

Kelvin Wong wrote:
> Greeting all,
> 
> I'm a new babies in Perl Programming and does anyone know where can i get
> the FREE documentation of learning Perl Programming?
> 
> Any suggested URL?
> 
> Thanks a lot! I appreciate your help!
> 
> Kelvin Wong

The Google Web Directory is yet another good starting point:

http://directory.google.com/Top/Computers/Programming/Languages/Perl/Documentation/Tutorials/

Have fun, this is a great language!

--
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave


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

Date: Tue, 03 Jul 2001 18:58:07 GMT
From: Bruce <nospam@newsranger.com>
Subject: Re: onMouseover in Perl?
Message-Id: <3Bo07.6101$Kf3.55362@www.newsranger.com>

>In article <3b4157c9@news.iprimus.com.au>,
>Henry Bafner <dexrix@hotmail.com> wrote:
>I seem to be getting errors everytime a onMouseover is activated, and
>doesn't seem to work.
>
><a href=something.html onmouseover=window.status='Something Here';return
>true>Something Here</a>
>
>Can onmouseovers be used in perl?
>

Yes, but the syntax shown is wrong.  It is shown as 

<a href=something.html onmouseover=window.status='Something Here';return
true>Something Here</a>

It should end up as 

<a href="something.html" onmouseover="window.status='Something Here';return
true;">Something Here</a>

The original lacks double quotes around your mouseover action and also the
semicolon after the return true.

Bruce


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

Date: Tue, 3 Jul 2001 15:08:31 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: onMouseover in Perl?
Message-Id: <1426-3B42263F-139@storefull-242.iap.bryant.webtv.net>

> It should end up as 
> <a href="something.html"   
> onmouseover="window.status='Something > Here';return true;">Something
Here</a> 
> The original lacks double quotes around > your mouseover action and
also the 
> semicolon after the return true. 
> Bruce   


This is OT; but your code is ALSO incorrect. NEVER forget to do an
onmouseOut!... that's a BAD mistake made by many web designers. It
should be...

<a href="something.html" onmouseOver="window.status='Something Here';
return true"
onmouseOut="window.status='Something Here'; return false">TEXT</a>

Can we now get back to Perl, please. :-)

HTH,
--Dennis



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

Date: Tue, 03 Jul 2001 18:05:21 GMT
From: Tim Schmelter <tschmelter@statesman.com>
Subject: Re: OT: GD::Graph, PNG files and slow loading in web browser
Message-Id: <3B420959.374CF4CE@statesman.com>

"Mr. Sunray" wrote:

> Hi all,
>
> Perl 5.6.1, Bughat 6.2, GD 1.33, GDGraph 1.33.  Possibly OT...
>
> I created a bar chart using the GDGraph module, in PNG format, that
> amounted to about 10k in size.  I tried both interlaced and
> non-interlaced.  When I open the file in a browser, it loads *very*
> slowly with both Netscape and IE.
>
> Is this because of the filesize?  The web browser?  Something to do with
> the way files are generated using GDGraph?  Is there a way to improve
> this (short of reducing the filesize)?
>
> Thanks in advance for any info.
>
> Regards,
>
> Mr. Sunray

Try generating a couple of trivial PNGs using GD--a box, a couple of lines,
etc. Do they still render slowly in the browser? Do PNGs of comparable size
generated via other means open the way you expect? Are you using versions of
IE & NN that "natively" support PNG files? For example, in NN 4.7, PNG
support is a plug-in (I assume; the browser displays a "loading plug-in"
status message when I use it to view a PNG image), and must be loaded every
session (? maybe every time?) the browser tries to display a PNG.

--
Tim Schmelter
Public Key available from http://www.keyserver.net
CAD7 2ABB 05A4 2F00 4CAE 7D2F 127C 129A 7173 2951




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

Date: 3 Jul 2001 13:23:45 -0700
From: msanderso@hotmail.com (abaxaba)
Subject: parallel processes w/perl
Message-Id: <b89e0a91.0107031223.45abaf0e@posting.google.com>

I'm working on an application being written entirely in perl and
javascript, with a DB backend.  As this app. won't be used by many
folks simultaneously, I am trying to do some things to make the server
work quicker.  Mod Perl is certainly one direction I'm moving in.  But
I'd also like to run parallel processes.  From what I read wrt fork,
the parent and child don't seem to run simultaneously.  I've heard
about doing a double-fork [ie, fork again from the child pid], but
can't seem to make this work.

IS there a way in perl to run simultaneous processes, [perhaps via
threads in v6], or is this beyond the abilities of the language?

TIA!

shawn


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

Date: Tue, 03 Jul 2001 18:08:47 GMT
From: "Scaramouche" <e.quesada@verizon.net>
Subject: parsing contents of html form w/net::smtp
Message-Id: <PSn07.3545$3R1.250273@paloalto-snr1.gtei.net>

first and foremost i'm a perl newbie.

i'm looking into formatting/passing the contents of an html (request) form
through email using perl.  i'm on a win32 system (win2Kserver) running
IIS50, my version of perl is v5.6.0 built for MSWin32.
i've been testing net::smtp and can successfully send a simple message such
as:

$smtp->datasend("this is a simple and trivial mail test msg !\n\n");

i was wondering however if i can use net::smtp to achieve this goal.  can
someone point me in the right direction?

thank you in advance for your help,
rick




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

Date: 03 Jul 2001 14:25:24 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: parsing contents of html form w/net::smtp
Message-Id: <877kxpddcr.fsf@limey.hpcc.uh.edu>


>> On Tue, 03 Jul 2001 18:08:47 GMT,
>> "Scaramouche" <e.quesada@verizon.net> said:

> first and foremost i'm a perl newbie.  i'm looking into
> formatting/passing the contents of an html (request)
> form through email using perl.  i'm on a win32 system

    > Subject: Re: parsing contents of html form w/net::smtp

Net::SMTP is a module which interfaces to an SMTP server
in order to send mail.

HTML parsing is another beastie altogether.

Receiving a <form> submission from somewhere and handling
it via e.g. CGI is also yet another beastie altogether.

> (win2Kserver) running IIS50, my version of perl is
> v5.6.0 built for MSWin32.  i've been testing net::smtp
> and can successfully send a simple message such as:

> $smtp->datasend("this is a simple and trivial mail test
> msg !\n\n");

> i was wondering however if i can use net::smtp to
> achieve this goal.  can someone point me in the right
> direction?

But you just said you're already successfully using
Net::SMTP.

Want to try this again? :-)

Also take a look at a module such as Mail::Sender which
could make your life rather easier.  If you want to send
MIME mail, look into the MIME::Lite module too.

t
-- 
Somebody light this monkey.  AAAAGGGHHHH!!  Bad monkey!



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

Date: Tue, 03 Jul 2001 19:47:41 GMT
From: "Scaramouche" <e.quesada@verizon.net>
Subject: Re: parsing contents of html form w/net::smtp
Message-Id: <xjp07.3720$3R1.319237@paloalto-snr1.gtei.net>

mr. curtis,
perhaps i should of been clearer.
a simple msg such as the one i successfully tested net::smtp with is but a
string fragment.  i would need to populate that section (body of email) with
the contents of several form fields so as to pass that information on
through an email transmission.

thank you,
rick

"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87elrxddjz.fsf@limey.hpcc.uh.edu...
> >> On Tue, 03 Jul 2001 18:08:47 GMT,
> >> "Scaramouche" <e.quesada@verizon.net> said:
>
> > first and foremost i'm a perl newbie.  i'm looking into
> > formatting/passing the contents of an html (request)
> > form through email using perl.  i'm on a win32 system
> > (win2Kserver) running IIS50, my version of perl is
> > v5.6.0 built for MSWin32.  i've been testing net::smtp
> > and can successfully send a simple message such as:
>
> > $smtp->datasend("this is a simple and trivial mail test
> > msg !\n\n");
>
> > i was wondering however if i can use net::smtp to
> > achieve this goal.  can someone point me in the right
> > direction?
>
> But you just said you're already successfully using
> Net::SMTP.
>
> Want to try this again? :-)
>
> Also take a look at modules such as Mail::Sender which
> could make your life rather easier.  If you want to send
> MIME mail, look into the MIME::Lite module too.
>
> t
> --
> Somebody light this monkey.  AAAAGGGHHHH!!  Bad monkey!




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

Date: Tue, 03 Jul 2001 19:56:47 GMT
From: "Scaramouche" <e.quesada@verizon.net>
Subject: Re: parsing contents of html form w/net::smtp
Message-Id: <3sp07.3725$3R1.326209@paloalto-snr1.gtei.net>

perhaps then net::smtp is not a feasible method to use for what i need to
accomplish.
i was afraid of that, it seemed too good to be true.

thank you for your most helpful input,
rick

"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:877kxpddcr.fsf@limey.hpcc.uh.edu...
>
> >> On Tue, 03 Jul 2001 18:08:47 GMT,
> >> "Scaramouche" <e.quesada@verizon.net> said:
>
> > first and foremost i'm a perl newbie.  i'm looking into
> > formatting/passing the contents of an html (request)
> > form through email using perl.  i'm on a win32 system
>
>     > Subject: Re: parsing contents of html form w/net::smtp
>
> Net::SMTP is a module which interfaces to an SMTP server
> in order to send mail.
>
> HTML parsing is another beastie altogether.
>
> Receiving a <form> submission from somewhere and handling
> it via e.g. CGI is also yet another beastie altogether.
>
> > (win2Kserver) running IIS50, my version of perl is
> > v5.6.0 built for MSWin32.  i've been testing net::smtp
> > and can successfully send a simple message such as:
>
> > $smtp->datasend("this is a simple and trivial mail test
> > msg !\n\n");
>
> > i was wondering however if i can use net::smtp to
> > achieve this goal.  can someone point me in the right
> > direction?
>
> But you just said you're already successfully using
> Net::SMTP.
>
> Want to try this again? :-)
>
> Also take a look at a module such as Mail::Sender which
> could make your life rather easier.  If you want to send
> MIME mail, look into the MIME::Lite module too.
>
> t
> --
> Somebody light this monkey.  AAAAGGGHHHH!!  Bad monkey!
>




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

Date: 03 Jul 2001 15:53:50 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: parsing contents of html form w/net::smtp
Message-Id: <873d8dd99d.fsf@limey.hpcc.uh.edu>


[ top-posting rearranged ]

>> On Tue, 03 Jul 2001 19:47:41 GMT,
>> "Scaramouche" <e.quesada@verizon.net> said:

> is but a string fragment.  i would need to populate that
> section (body of email) with the contents of several
> form fields so as to pass that information on through an
> email transmission.

"perldoc CGI" for details of CGI.pm and how to access
parts of an HTML form with param().

Pay close attention to the security aspects, esp. that of
tainted data.  See e.g.

  http://www.w3.org/Security/Faq/wwwsf4.html

which has links to more information as well.

hth
t
-- 
Somebody light this monkey.  AAAAGGGHHHH!!  Bad monkey!


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

Date: 3 Jul 2001 11:18:04 -0700
From: princestuart@yahoo.com (Sam Prince)
Subject: Performance issues with Perl.
Message-Id: <fd825acb.0107031018.5533a834@posting.google.com>

Hi,

   We use Perl 5.6 on UNIX HP machine and Oracle 8 database. To
connect to the database, we use DBI. The problem is, when we give
single requests the response time is around 0.9 seconds within the
system but when we give multiple requests the response time increases
abnormally. For example, sending 50 requests at the same time
increases the response time to almost 17 seconds for each request. The
delay time is mostly at the connect and execute routines. It looks as
if the requests are being processed one by one.
   Is the way DBI is supposed to work.? Or, are we doing something
wrong. Any insight on this problem that we are facing is greatly
appreciated.

Thank you.
Sam Prince.


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

Date: Tue, 03 Jul 2001 13:37:59 -0500
From: "Mr. Sunray" <djberge@uswest.com>
Subject: Re: Performance issues with Perl.
Message-Id: <3B421107.C2427DF9@uswest.com>

Sam Prince wrote:

> Hi,
>
>    We use Perl 5.6 on UNIX HP machine and Oracle 8 database. To
> connect to the database, we use DBI. The problem is, when we give
> single requests the response time is around 0.9 seconds within the
> system but when we give multiple requests the response time increases
> abnormally. For example, sending 50 requests at the same time
> increases the response time to almost 17 seconds for each request. The
> delay time is mostly at the connect and execute routines. It looks as
> if the requests are being processed one by one.
>    Is the way DBI is supposed to work.? Or, are we doing something
> wrong. Any insight on this problem that we are facing is greatly
> appreciated.
>
> Thank you.
> Sam Prince.

Sam,

No, that shouldn't happen.

Are you creating a new database handle for each request?  If so, why not
use the same database handle for multiple statement handles?  You avoid
the overhead of creating a new connection that way.

Also, could you clarify what you mean exactly by "50 requests at the same
time"?  Are you forking?  Threading?  Or are you just sending 50 reqests
serially, one after the other quickly?

Lastly, are you absolutely sure it's not Oracle's fault?

What version of DBI?  What version of DBD-Oracle?

Need more info.  Also, consider subscribing to dbi-users@perl.org

Regards,

Mr. Sunray



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

Date: 3 Jul 2001 14:03:31 -0700
From: stupid@pobox.com (Michael G Schwern)
Subject: Re: Perl 6:   ->   vs  .
Message-Id: <f002cdd6.0107031303.64e4f6bf@posting.google.com>

"Jim Melanson" <jim@perlservices.com> wrote in message news:<5TJ_6.7534$9m1.90143@localhost>... 
> The traffic lights article: 
> http://www.perl.com/pub/2001/05/22/trafficlights.html#1 
>  
> by Michael Schwern says that in Perl 6 the -> operator for method calls is 
> going to be replaced by the period (.). (See the footnotes). 
>  
> Does anyone know if they are keeping backwards compatability or we going to 
> have to re-write all our modules and scripts for Perl 6?? 
 
In a nutshell... 
 
1)  Yes, Perl 6 is going to break compatibility with Perl 5.  Once we
allowed ourselves this,
the flood gates opened. 
 
2)  No, you will *not* have to rewrite all your modules and scripts
for Perl 6.  Its not entirely clear how
we're going to pull this off in all cases, but we've got the major
ones down:
 
The "package" keyword is changing to "class".  If Perl 6 sees "package
Foo" it assumes it is dealing with a Perl 5 module and parses it as
such.  If it sees "class Foo" it assumes its a Perl 6 module.  So
that's how we neatly handle old modules.
 
As for scripts, a few ideas are being tossed around.  One idea is for
Perl 6 to be sensitive to how its named.  Say you've got
/usr/bin/perl6 and its symlinked to /usr/bin/perl.  If Perl 6 is
called as "perl" it runs as Perl 5.  If called as "perl6" it runs as
Perl 6.
 
Another little widget Tod mentioned is the p526 translator.  Just a
set of filters and parsers that automagically translates your Perl 5
code into Perl 6.  It might not be 100%, but it should work for most
cases.  In fact, people have already written things that go the other
way, they're translating certain bits of Perl 6 code into Perl 5 so we
can start experimenting.  The Bundle::Perl6 bundle on CPAN contains a
set of these sort of modules.
 
 
This is all still up in the air, but whatever happens there are two
definites:
 
1)  Perl 6 breaks compatibility with Perl 5. 
2)  You will NOT have to rewrite all your Perl 5 code (though we hope
you eventually will).


PS  For more details about how Perl 6 will look, read Damian Conway's
Exegesis 2
http://www.perl.com/pub/a/2001/05/08/exegesis2.html


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

Date: 03 Jul 2001 11:19:13 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl Script to Remove Email Attachment
Message-Id: <m1wv5p3mfy.fsf@halfdome.holdit.com>

>>>>> "Anthony" == Anthony  <adsouza@globix.com> writes:

Anthony> I am writing a perl script, that will need to remove an
Anthony> attachement if it meets certain criteria (amongst a lot of
Anthony> other things).  The script is finished except for the part to
Anthony> remove an attachement.

Anthony> I want to script to, if the email contains an attachment
Anthony> called WINMAIL.DAT to delete that attachment from the email,
Anthony> however, if they are any other attachments to keep them.

Anthony> I have tried using MIME-tools but have run into a truck load
Anthony> of problems and can;t seem to figure it out.

It's possible that my "MIME is a terrible thing to waste" SysAdmin
column will fit pretty close, at least for structure.  See

  <http://www.stonehenge.com/merlyn/UnixReview/col37.html>

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 03 Jul 2001 19:42:33 GMT
From: Gerard Lanois <gerard@NOSPAMlanois.com>
Subject: Re: Perl Script to Remove Email Attachment
Message-Id: <m3ith9dcir.fsf@localhost.localdomain>

merlyn@stonehenge.com (Randal L. Schwartz) writes:

> >>>>> "Anthony" == Anthony  <adsouza@globix.com> writes:
> 
> Anthony> I am writing a perl script, that will need to remove an
> Anthony> attachement if it meets certain criteria (amongst a lot of
> Anthony> other things).  The script is finished except for the part to
> Anthony> remove an attachement.
> 
> Anthony> I want to script to, if the email contains an attachment
> Anthony> called WINMAIL.DAT to delete that attachment from the email,
> Anthony> however, if they are any other attachments to keep them.
> 
> Anthony> I have tried using MIME-tools but have run into a truck load
> Anthony> of problems and can;t seem to figure it out.

Anthony,

I don't think you understand that once you parse your message
with MIME::Parser and ignore the winmail.dat file (as I showed
you how to do previously), that you then need to construct 
a new MIME message out of the remaining parts.


> It's possible that my "MIME is a terrible thing to waste" SysAdmin
> column will fit pretty close, at least for structure.  See
> 
>   <http://www.stonehenge.com/merlyn/UnixReview/col37.html>

Randal,

The various "parse" methods of the MIME::Parser class return
the root node of a MIME::Entity *tree*.

In 99.99999% of the cases, the MIME-encoded mail (or Usenet) messages 
you encounter will be "flat" (ie, a single part or list of parts).

All the example programs that come with the MIME-Tools distribution
use recursion to walk the entity tree.

In fact, if you look at the source for the dump_skeleton method
in the MIME::Entity class, you will see that it is itself recursive.

Anyway, the OP has posted this question three times in the past
week or so.  He got somewhat close during his second attempt, but 
unfortunately for the momemnt he seems to have given up on MIME::Parser.
Hopefully your article can get him back on the right track.

-Gerard
http://www.lanois.com/perl/


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

Date: Tue, 3 Jul 2001 21:00:22 +0100
From: "Robin Abrol" <newsman@-takethisout-brol.org.uk>
Subject: Re: Please help newbie!
Message-Id: <9ht8ae$b5o$1@news6.svr.pol.co.uk>

I tried changing the code, and got it to work by using the FindBin command
(which I found on a Perl site somewhere - more by luck than anything!).

Thanks for the tips.

I am now stuck with some other issues - see post above!

Cheers,

Robin


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.261 / Virus Database: 131 - Release Date: 06/06/2001




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

Date: Tue, 03 Jul 2001 20:15:17 GMT
From: bartok <member@dbforums.com>
Subject: Protected Dowloads (SSI?)
Message-Id: <pJp07.3306$rK3.229539@news1.onlynews.com>

I am trying to create a script that manages the downloading of
individual files. I don't just want the perl program to forward the user
to a new location when they meet the correct criteria (password/IP
address/payment), I want the download to be done from within the script.
My current best effort locks the folder with the downloads in from all
but a user on the host computer (ie no direct download via internet).
The the script then runs on the computer and, after cheacking the
criteria, accesses and prints the relevant file. eg for pdf's:

print "Content-type: application/pdf\n\n"; open(DOWNLOAD_FILE,
"<$download_file") or die "Opening: $!"; while(<DOWNLOAD_FILE>){ print
$_ or die "Printing: $!"; } close(DOWNLOAD_FILE) or die "Closing: $!";

The problem with this is that the file will be called the name of the
script - and hence will not have the correct suffix (.pl not .pdf).
Also, it does not force the file to be downloaded - in Nescape it is
simply displayed by default. Also, there are probably security holes.
Any thoughts would be appreciated. I've heard there may be a solution
involving SSI or TK or something ... Thanks!




--
Posted via dBforums, http://dbforums.com


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

Date: Tue, 03 Jul 2001 18:31:24 GMT
From: Tim Schmelter <tschmelter@statesman.com>
Subject: Re: ref($val) not returning anything?
Message-Id: <3B420F76.67086810@statesman.com>

Michael Carman wrote:

> Mike Eggleston wrote:
> >
> > I have some code that assigns a literal to a scalar.
> > On the scalar I use ref and test for SCALAR.
> > The function ref() does not return anything
> > (as if its returning undef).
> >
> > my($val);
> > $val = 'a literal';
> > if(ref($val) eq 'SCALAR') {
> [snip]
>
> $val is a scalar, not a reference to a scalar. There's a difference!
>
> ref() tells you whether or not an expression contains a reference, and
> if so, what type of thing it refers to. It returns undef here because
> $val isn't a reference.
>
> -mjc

I've noticed that, when printing out references in scalar context, the
scalar value is a string containing the class into which the object was
blessed, if any, and a memory address:

    C:\> perl -MCGI::Pretty -e 'my $r = CGI::Pretty->new(); print
qq($r\n)'
    CGI::Pretty=HASH(0x176f070)

    C:\>perl -e "my $r = []; print qq($r\n)"
    ARRAY(0x176f09c)

    C:\>perl -e "my $r = {}; print qq($r\n)"
    HASH(0x176f09c)

    C:\>perl -e "my $r = \'123'; print qq($r\n)"
    SCALAR(0x17652a4)

and so on.

So, some questions, hopefully answered by someone with a better grasp of
Perl internals than I possess:

1) How system-dependent is that behavior? Other than the obvious memory
address differences, would that value interpolate the same on whatever
platform Perl happened to be running on?

2) If that is standardized behavior, how likely is that behavior to change
in future versions of Perl (Perl Apocalypse hasn't gotten to Chapter 8,
yet)?

3) The biggie: Is it useful to know? I really can't think of any reason to
care, beyond snooping memory addresses (or possibly writing some
obfuscated JAPHs....hmm).

--
Tim Schmelter
Public Key available from http://www.keyserver.net
CAD7 2ABB 05A4 2F00 4CAE 7D2F 127C 129A 7173 2951




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

Date: Tue, 03 Jul 2001 19:14:52 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: ref($val) not returning anything?
Message-Id: <x7r8vx6d03.fsf@home.sysarch.com>

>>>>> "TS" == Tim Schmelter <tschmelter@statesman.com> writes:

  TS> 1) How system-dependent is that behavior? Other than the obvious
  TS> memory address differences, would that value interpolate the same
  TS> on whatever platform Perl happened to be running on?

would you expect a C pointer to work on different architectures? in fact
a perl ref would not even make sense in another process. they are
process specific.

  TS> 2) If that is standardized behavior, how likely is that behavior
  TS> to change in future versions of Perl (Perl Apocalypse hasn't
  TS> gotten to Chapter 8, yet)?

i doubt that will change. it makes no sense unless you are sharing
things and they both map to the same exact virtual space (unlikely
unless you force it).

  TS> 3) The biggie: Is it useful to know? I really can't think of any
  TS> reason to care, beyond snooping memory addresses (or possibly
  TS> writing some obfuscated JAPHs....hmm).

know what? the address of a ref? it is useful when comparing two ref to
see if they are the same. you may not realize it but newer perls will
return an integer value for a ref in numeric context. this speeds up

	if ( $refa == $refb ) 

from the stringified code:

	if ( $refa eq $refb ) 

there are basically (almost) no uses for the value of a ref in perl
other than as the original ref. pointer math is not supported (unlike in
C) which saves you from all the segfaults.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Tue, 03 Jul 2001 15:26:56 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: ref($val) not returning anything?
Message-Id: <3B422A90.758EAC01@home.com>

Tim Schmelter wrote:
> 
> I've noticed that, when printing out references in scalar context,
> the scalar value is a string containing the class into which the
> object was blessed, if any, and a memory address:
[...]
> 1) How system-dependent is that behavior?

Not at all. (In my experience, at least.)

> 2) [H]ow likely is that behavior to change in future versions of
> Perl?

Nothing is ever guaranteed, but I doubt this would change. (And if it
did, it would likely go through a deprecation stage first.)
 
> 3) Is it useful to know? I really can't think of any reason to
> care, beyond snooping memory addresses (or possibly writing some
> obfuscated JAPHs....hmm).

In my experience, it's primarily useful for debugging. I find it to be
an excellent indication that I have failed to dereference something
properly. :)

It's also nice to know (via the perl debugger or Data::Dumper) what sort
or thing your working with. Even the address itself is useful sometimes
in identifying bugs where you've reused instead of reallocated, or vice
versa. Novices will sometimes do something analgous to this:

#!/usr/local/bin/perl -w
use strict;

my @x;
foreach my $i (0 .. 4) {
    @x = map {$_ * $i} (1 .. 3);
    push @a, \@x;
}

print "$_\n" foreach @a;
__END__
ARRAY(0x1b92a2c)
ARRAY(0x1b92a2c)
ARRAY(0x1b92a2c)
ARRAY(0x1b92a2c)
ARRAY(0x1b92a2c)

We can see that each element of @a gets a reference to the same chunk of
memory. Oops! @x should have been scoped _inside_ the foreach() loop.

I've never had occasion to use this as part of a program, though. One
place where it might also be useful is when writing XS code, but having
never done so myself this is pure speculation.

-mjc


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

Date: Tue, 03 Jul 2001 19:25:15 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: web fetching
Message-Id: <1evzn55.n4bbgf1087ajiN%tony@svanstrom.com>

Philip Newton <pne-news-20010703@newton.digitalspace.net> wrote:

> On Tue, 03 Jul 2001 09:57:11 GMT, tony@svanstrom.com (Tony L. Svanstrom)
> wrote:
> 
> > that guy's selling LWP::Simple, that comes with the installation of
> > Perl.
> 
> Not quite true; it's not in the source distribution (and the current
> pumpking has said he won't include it, though quite a few others have
> been borged in). However, it's in the ActivePerl distribution AFAIK, so
> if you're running ActivePerl (e.g. on Win32, Linux, or Solaris), you
> already have it.
> 
> But even if you don't, LWP::Simple is just a CPAN mirror away, for free.
> (Though you'd still have to write the script yourself.)

Ooops... I must have forgotten that I had to install it myself then,
but...

Either you download his examples, and pay him ten bucks for it, and then
you having to install LWP anyhow, or you do this:

% perl -MCPAN -e 'install LWP::Simple'
% man LWP::Simple

and then you have an example anyhow...


        /Tony
-- 
the truth is dead, faith is gone, reality killed... ruled by the plastic
laws of modern life we're pushed towards the hell of personal doubt,
betrayal, hate, lust and murder... the now has become an illusion, a
paradise of a dead tomorrow... (c)2000-2001 tony@svanstrom.com


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

Date: Tue, 3 Jul 2001 15:18:44 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: web fetching
Message-Id: <1425-3B4228A4-327@storefull-242.iap.bryant.webtv.net>

Interesting that this thread is here today. I was just trying to go into
the LWP module and write a "get" in plain perl without using socket or
LWP. Problem was that when I went into LWP::Simple, it requires LWP, and
LWP, in turn needs code from  other modules, so it would be a nightmare
for this rookie to gather all of the proper coding from the modules to
do a 'get' or 'getstore' in raw perl.

Why do this? Because not all servers have LWP.pm or Socket.PM, or they
don't allow you to install them.

I really do think LWP and the other modules it requires to work, SHOULD
be included in the main distribution.
 
Regards,
--Dennis



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

Date: 03 Jul 2001 12:25:10 -0700
From: Terrence Monroe Brannon <tmbranno@oracle.com>
Subject: Re: What do you guys think the language of the future will be?
Message-Id: <yujqofr1n7c9.fsf@ap555sun.us.oracle.com>

peter@abbnm.com (Peter da Silva) writes:

 : In article <9hm2gt$edvn6$1@id-22205.news.dfncis.de>,
 : Jochen Schmidt  <jsc@dataheaven.de> wrote:
 : > It is more like the natural languages I use, where a "symbol" _can_ have 
 : > multiple meanings.
 : 
 : Programming languages are not natural languages. They have some similiarities,
 : but designing features programming languages around those similarities is how
 : you get things like Perl.

yes, here's an example:

$host and return(501) or die "host not defined" ;

and here's another

print $_->{age} for (@person);

and another:

reshape_matrix if $optimize;

and one more:

$arg = shift or die usage;


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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


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