[19625] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1820 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 26 09:05:43 2001

Date: Wed, 26 Sep 2001 06:05:13 -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: <1001509513-v10-i1820@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 26 Sep 2001     Volume: 10 Number: 1820

Today's topics:
        a "private" installation of Perl <Peterca@btopenworld.com>
    Re: a "private" installation of Perl (Garry Williams)
        ActiveState: bytecode dumping in ASP <pwasik@go2.pl>
    Re: better if/else statement than this. <peb@bms.umist.ac.uk>
    Re: better if/else statement than this. (Martien Verbruggen)
    Re: Blank Lines <tintin@snowy.calculus>
    Re: Cannot run perl scripts in Apache when file opened  <andytolley@hotmail.com>
        CFP: Fourth German Perl-Workshop <richter@ecos.de>
    Re: Creating modules nobull@mail.com
    Re: emailing contents of text file (Stephane TOUGARD)
    Re: emailing contents of text file (Martien Verbruggen)
    Re: emailing contents of text file <dtweed@acm.org>
    Re: Excel-Graphs <bart.lateur@skynet.be>
        exec call | mpack evan.cooch@NOSPAMcornell.edu
    Re: exec call | mpack <Thomas@Baetzler.de>
    Re: faster execution <dtweed@acm.org>
    Re: faster execution (Martien Verbruggen)
    Re: Getting NULLS after a lockup from using up memory <iltzu@sci.invalid>
    Re: Goto and global variables (Tramm Hudson)
    Re: Goto and global variables (Mark Jason Dominus)
    Re: How can I use a filehandle indirectly? <bill.kemp@wire2.com>
        how to get perl invoke internet explorer and navigate w (Dav Lam)
    Re: how to get perl invoke internet explorer and naviga <Thomas@Baetzler.de>
    Re: Is there a better way to do this?? (Mark Jason Dominus)
    Re: Looking for OO/AUTOLOAD info <iltzu@sci.invalid>
        MIME::Lite problem <bill02115@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 26 Sep 2001 11:39:07 +0100
From: "Peter Cameron" <Peterca@btopenworld.com>
Subject: a "private" installation of Perl
Message-Id: <9osb8j$6ur$1@uranium.btinternet.com>

We have a Java application that performs some back end processing using Perl
5.005. Is it possible to create a private version of Perl that resides in
the Java application's directory. Some of the platforms that we've deployed
our software on have earlier versions of Perl (IRIX and Solaris 2.6 for
example). Installing the correct version was no problem, but it was still
hassle for the sys admins.

I've compiled Perl before (on SCO UnixWare) and know that it builds to
expect libraries etc. in a fixed location. Can this be circumvented by
setting environment variables in an already compiled distribution? The GNU R
software can be handled this way, so I'm hoping can Perl.

Cheers,
Peter





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

Date: Wed, 26 Sep 2001 13:02:37 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: a "private" installation of Perl
Message-Id: <slrn9r3kfd.9k0.garry@zfw.zvolve.net>

On Wed, 26 Sep 2001 11:39:07 +0100, Peter Cameron
<Peterca@btopenworld.com> wrote:

> We have a Java application that performs some back end processing
> using Perl 5.005. Is it possible to create a private version of Perl
> that resides in the Java application's directory. 

Yes.  Set -Dprefix=/path when you run Configure.  See INSTALL in the
distribution.  

-- 
Garry Williams


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

Date: Wed, 26 Sep 2001 12:29:15 +0200
From: Piotr Wasik <pwasik@go2.pl>
Subject: ActiveState: bytecode dumping in ASP
Message-Id: <3BB1ADFB.6080506@go2.pl>

Hello Everyone,

I wanted my ASP Perl program to start up faster.

I created an ASP program (the only file, default.asp run a template: 
default.asp?url=/path/to/template.html). The most time-consuming phase 
of the IIS response is compilation. To avoid this, I try to put:
<%
open FH,"<c:/InetPub/wwwroot/program.plc";
eval "use ByteLoader 0.04;\n".join "",<FH>;
%>

but I don't know how to compile program.pl into program.plc and to have 
PerlScript specific variables like $::Server, $::Request, $::Response etc.

I guess the difference between perl.exe and PerlScript lies in these 
variables, so I can't use your recipe:
perl.exe -MO=Bytecode,-umain,-oprogram.plc program.pl
because the bytecode has no ASP specific OLEs ($::Server, $::Request, 
$::Responce etc.)

I tried to compile it from ASP:
<%
$ARGV[0]="program.pl";
use O qw(Bytecode -umain -oprogram.plc);
%>
But the script can't find program.pl and thus the output is zero-length.

I also tried:
<%
$ARGV[0]="c:/InetPub/wwwroot/program.pl";
use O qw(Bytecode -umain -oprogram.plc);
%>
but the O module raises an error, the same if slashes are windowsish:\\.

I thought the O module program may do the compilation this way:
<%
open FH,"c:/InetPub/wwwroot/program.pl";
eval "use O qw(Bytecode -umain -oprogram.plc);\n".join "",<FH>"
%>
but I seem to be wrong, too.

Unfortunatelly, I am not a YAPH and I see nothing in O module sources
(I see no $ARGV, no open for reading and no eval...), I am sorry.

Looking forward for anyone's answer and thanking you in advance,
Piotr Wasik



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

Date: Wed, 26 Sep 2001 09:48:40 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: better if/else statement than this.
Message-Id: <3BB19668.EB6DBE25@bms.umist.ac.uk>

"Randal L. Schwartz" wrote:
> 
> >>>>> "Ren" == Ren Maddox <ren@tivoli.com> writes:
> 
> >> for (map { sprintf "%x", $_ } 0..15 ) {
> >> print "$_ is ", substr(unpack("B*", pack "h*", $_), 0), "\n";
> >> }
> 
> Ren> (I assume you meant "4" instead of "0" on that substr, as before.)
> 
> Yes.  Too hasty at posting.
> 
> Ren> How about just:
> 
> Ren>   printf "%x is %04b\n", $_, $_ for 0..15;
> 
> Works fine if you have 5.6.x.  A lot of production machines I have
> around here are still 5.5.3.

Seems to work fine with my 5.5.3 version of Perl...  What's wrong with
it?

Paul


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

Date: Wed, 26 Sep 2001 19:33:07 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: better if/else statement than this.
Message-Id: <slrn9r386j.8ai.mgjv@martien.heliotrope.home>

On Wed, 26 Sep 2001 09:48:40 +0100,
	Paul Boardman <peb@bms.umist.ac.uk> wrote:
> "Randal L. Schwartz" wrote:
>> 
>> >>>>> "Ren" == Ren Maddox <ren@tivoli.com> writes:
>> 
>> Ren>   printf "%x is %04b\n", $_, $_ for 0..15;
>> 
>> Works fine if you have 5.6.x.  A lot of production machines I have
>> around here are still 5.5.3.
> 
> Seems to work fine with my 5.5.3 version of Perl...  What's wrong with
> it?

$ perl5.00503 -w
printf "%x is %04b\n", $_, $_ for 0..2;
__END__
Invalid conversion in printf: "%b" at - line 1.
0 is %04b
Invalid conversion in printf: "%b" at - line 1.
1 is %04b
Invalid conversion in printf: "%b" at - line 1.
2 is %04b

Are you sure you tried this with 5.005_03 (5.5.3)?

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | I used to have a Heisenbergmobile.
Commercial Dynamics Pty. Ltd.   | Every time I looked at the
NSW, Australia                  | speedometer, I got lost.


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

Date: Wed, 26 Sep 2001 22:56:58 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: Blank Lines
Message-Id: <Chks7.20$WC4.775238@news.interact.net.au>


"MiKyung81" <mikyung81@aol.com> wrote in message
news:20010925183025.01461.00000765@mb-fz.aol.com...
> Hi,
>     I'm trying to read from a file and would like to skip if it's just
blank
> line... I've tried it in many different ways but would get me into
infinite
> loop.  Any ideas??
> Also, is there a one line command that would do...
> while(EXPRESSION) {
>   .
>   .
>   if (Expression)   #Fails, then goto the end of while stmt(message line)
>   .
>   .
>   message();
> }

while (<>) {
    next if (/^$/);
    ...
}




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

Date: Wed, 26 Sep 2001 08:48:58 +0100
From: "IICS" <andytolley@hotmail.com>
Subject: Re: Cannot run perl scripts in Apache when file opened via Samba
Message-Id: <1001491129.16583.0.nnrp-10.c1ed7194@news.demon.co.uk>

Doesnt Windoze use the wrong end of line terminators (\r\n isnt it) and *nux
only uses \n

Ive had this problem before and its basically to do with the above.  If you
open the same file on your linux box and check the end of the line you might
find you have got ^M at the end of each line.

There is a way of stripping out the characters from the linux command line
but you will have to ask one of the linux boffins what it is, other than
that you could manually remove them using the linux text editor.

Hope this Helps.

IICS

"AcCeSsDeNiEd" <dillon@rm_accessdenied.darktech.org> wrote in message
news:3bad902e.4418892@news.cyberway.com.sg...
> On Mon, 17 Sep 2001 15:13:58 GMT, jonadab@bright.net (Jonadab the
Unsightly One) wrote:
>
> >are you using
> >Notepad or something?  (Repeat this mantra: "dontusenotepad")
>
> Notepad was just one of them.
>
>
> >Now, if a program opens, reads, and then closes a file
> >and *then* Apache can't read it, that would have to be
> >a Samba problem, I think.
>
> I can open a file, and close it without saving it, still gives the
problem.
> I can even save it and close it, no joy
>
> I think it might be a Samba problem.
> But in the meantime, what I do is copy the file to my local
> drive, then edit from there. Later copy it to the samba/apache network
drive.
> No complaints here.
>
> To e-mail me, remove "rm_"




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

Date: Wed, 26 Sep 2001 10:58:12 +0000 (UTC)
From: "Gerald Richter" <richter@ecos.de>
Subject: CFP: Fourth German Perl-Workshop
Message-Id: <6ee5c24c11dcf3321c301e9185bcc49c.28252@mygate.mailgate.org>

                      Fourth German Perl-Workshop
                    http://www.perlworkshop.de/2002/

           Wednesday to Friday, February 13 - February 15, 2002
                                 at the
        Fachhochschule Bonn-Rhein-Sieg, Sankt Augustin near Bonn


The "Fourth German Perl-Workshop" is a non-profit conference for Perl
users and developers mostly covered by sponsors. It aims at fostering
exchange and social networking between Perl developers and advanced
Perl users in the German-speaking Perl community. 

We are looking for tutors and speakers at the Perl-Workshop.
Presentations will be:

  TUTORIALS: 3 hours (half-day)
  LONG TALKS: approx. 40 minutes
  SHORT TALKS: approx. 20 minutes

Topics are unlimited, but some suggestions include:

 * Databases (DBI, Access, replication, administration)
 * Data Munging
 * Graphics (Tk, GTk, controlling 3rd party software)
 * Hardware / Software Co-Design
 * Cryptographic ???
 * Little languages
 * Network
 * ART!  (Music, dance, poetry, mime, ...)
 * Refactoring
 * Sorting (for complex data)
 * System administration
 * Template Toolkits
 * Perl and the Web (CGI, HTML, mod_perl)
 * Text processing (XML, regular expressions)
 * Anything cool :)

If you wish to make a presentation, please mail your informal abstract
(plain ASCII text, 200-300 words) to "wsorga@perlworkshop.de" 

                          by September 30, 2001
                          ~~~~~~~~~~~~~~~~~~~~~

Extended abstract until 31.10.2001, final paper until 1.12.2001.

We would appreciate if you could forward this "Call for Papers" to
other interested people.

WsInfo mailing list
WsInfo@perlworkshop.de
http://www.ecos.de/mailman/listinfo/wsinfo




-- 
Posted from  [217.7.64.151] 
via Mailgate.ORG Server - http://www.Mailgate.ORG


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

Date: 26 Sep 2001 12:54:05 +0100
From: nobull@mail.com
Subject: Re: Creating modules
Message-Id: <u9wv2muox2.fsf@wcl-l.bham.ac.uk>

Benjamin Goldberg <goldbb2@earthlink.net> writes:

> Bart Lateur wrote:
> > 
> > nobull@mail.com wrote:
> > 
> > >+      *{"${callpkg}::EXPORT_OK"} = \@{$arg{EXPORT_OK} || []};
> > 
> > This does not do what you think it does.
> 
> It's possible that it simply does not do what *you think* he thinks it
> does.
> 
> In particular, if the user passes a string or a glob, then \@$foo will
> create an arrayref out of it.  I can't think of too many situations when
> this would be useful, but I don't see a problem with doing it.
> 
> Oh, I can sorta think of one... if somebody passes in something other
> than an arrayref as an argument, doing this will catch that mistake by
> raising an error.

Yep, Benjamin is bang on.  I often use \@$ref as an assertion to
raise an error if $ref not an arrayref.

Actually since I wrote this patch I've learnt that the "|| []" bit is
redundant as autovivification will take care of the
!defined($arg{EXPORT_OK}) case.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 26 Sep 2001 16:09:08 +0800
From: s_tougard@hotmail.com (Stephane TOUGARD)
Subject: Re: emailing contents of text file
Message-Id: <slrn9r3394.2d4.s_tougard@clipper.kirch>

In article <slrn9r2tkp.eug.mgjv@verbruggen.comdyn.com.au>, 
Martien Verbruggen wrote:
> 
> Many people here, probably most, won't agree with your teacher. If you
> want to write C, then use C. If you want to write Perl, then write
> Perl. Do you also process all your strings character by character? And
> don't you use hashes? After all, there are no hashes in C, and a C
> programmer might get confused if you use one. 

I don't care if a lot of people will agree or not with my opinion, I
think that write a Perl code easy to understand for a C coder is better
than use very specific functions of Perl.

> I must say, that comment is one of the dimmest ones I've seen in a
> while, relating to how to write Perl code.

There is more than one way to do it.

> Fine. But where do you draw the line? No hashes? No regexes? Which of
> these are easy enough to understand for aa C programmer:

I often work with C coders, they understand what is a hash but often
they do not understand what means undef $/ .




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

Date: Wed, 26 Sep 2001 18:53:04 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: emailing contents of text file
Message-Id: <slrn9r35rg.8ai.mgjv@martien.heliotrope.home>

On Wed, 26 Sep 2001 16:09:08 +0800,
	Stephane TOUGARD <s_tougard@hotmail.com> wrote:
> In article <slrn9r2tkp.eug.mgjv@verbruggen.comdyn.com.au>, 
> Martien Verbruggen wrote:
>> 
>> Many people here, probably most, won't agree with your teacher. If you
>> want to write C, then use C. If you want to write Perl, then write
>> Perl. Do you also process all your strings character by character? And
>> don't you use hashes? After all, there are no hashes in C, and a C
>> programmer might get confused if you use one. 
> 
> I don't care if a lot of people will agree or not with my opinion, I
> think that write a Perl code easy to understand for a C coder is better
> than use very specific functions of Perl.

I didn't say you should care. I said it was a silly attitude to take. Do
you encourage C code to be written so that Fortran programmers can
understand it? And Fortran so that Algol programmers can read it? And
Algo so that Intercal programmers know what it's about? And Intercal...
Ok, no one can read Intercal.

>> I must say, that comment is one of the dimmest ones I've seen in a
>> while, relating to how to write Perl code.
> 
> There is more than one way to do it.

But there are bad ways, and good ways. Forcing one language into another
language's coding model is almost invariably bad.

Each language has its own constructions, keywords, suntax, and most
importantly, idiom. Perl is one of the more flexible languages, which
allows you to do things in different ways. However, not all these ways
are equal. Wasting CPU cycles and memory by reading a file into an
array, and then joining that array into a single scalar is just not
elegant, and doesn't even come close to being the Right Thing(tm).

>> Fine. But where do you draw the line? No hashes? No regexes? Which of
>> these are easy enough to understand for aa C programmer:
> 
> I often work with C coders, they understand what is a hash but often
> they do not understand what means undef $/ .

I _am_ a C programmer. I work with loads of C programmers. They really
aren't as stupid as you think they are. Especially not once you've told
them where the documentation is. If they can't follow what's going on in
a Perl program, why are they reading it in the first place? To learn?
Wouldn't it be better to learn more and more correct Perl idiom then?

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | life ain't fair, but the root
Commercial Dynamics Pty. Ltd.   | password helps. -- BOFH
NSW, Australia                  | 


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

Date: Wed, 26 Sep 2001 13:03:11 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: emailing contents of text file
Message-Id: <3BB1D0C9.17819F9@acm.org>

Garry Williams wrote:
> <s_tougard@hotmail.com> wrote:
> > open(IN,"<file_email") or die $!;
> 
> Good that you check the result of open.  Bad that your error message
> will be quite ambiguous.

Not all that ambiguous; by leaving off the newline, the die will also
print the file and line number where it happened. In this case, since
the filename is hard-coded, that's all you need.

I often do something like this during script development, or for quickie
one-off scripts. Later, after the script is more polished, I'll go back
and add messages (or internal error handling) that make more sense from
the user's point of view.

-- Dave Tweed


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

Date: Wed, 26 Sep 2001 09:47:14 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Excel-Graphs
Message-Id: <en83rtov06ael04a5qjeaejmkl869vpild@4ax.com>

Christian Wanninger wrote:

>Does anyone know how to generate Excel-graphs with perl??

Only by controlling Excel, the app, through perl.

<http://aspn.activestate.com//ASPN/Reference/Products/ActivePerl/faq/Windows/ActivePerl-Winfaq12.html#make_chart>

-- 
	Bart.


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

Date: Wed, 26 Sep 2001 12:36:03 GMT
From: evan.cooch@NOSPAMcornell.edu
Subject: exec call | mpack
Message-Id: <3bb1cafa.52551636@newsstand.cit.cornell.edu>

Grettings -

I wrote several perl scripts for handling file upoads via a webpage,
using an exec function call to mpack to MIME encode the uploaded file
before mailing it to me. 

However, I'm not able to figure out an easy way to prevent the mail
coming in from 'nobody'. Basically, any process run by the perl script
assigns nobody as the owner, and thus any mail mpack sends out from
the exec(mpack) call comes in from nobody, which is a pain to
reply-to: I end up having to parse the note to find the users real
email address (which is a form variable), and then paste that in place
manually for the reply. 

Anyone know a simple workaround?

Thanks!



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

Date: Wed, 26 Sep 2001 15:00:23 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: exec call | mpack
Message-Id: <s4k3rtkum543khq7iu9ohf1hcscoj9ia8h@4ax.com>

On Wed, 26 Sep 2001 12:36:03 GMT, evan.cooch@NOSPAMcornell.edu wrote:
>I wrote several perl scripts for handling file upoads via a webpage,
>using an exec function call to mpack to MIME encode the uploaded file
>before mailing it to me. 

Any particular reason why you don't use MIME::Lite and Net::SMTP?

That way, you could set up a valid From: header for the body. 

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Wed, 26 Sep 2001 12:16:05 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: faster execution
Message-Id: <3BB1C5BF.926FB91B@acm.org>

venus wrote:
> The script runs halfway and stopped with the message:
> Segmentation fault (core dumped)

Not too surprising, given that %LOCATIONS must be pretty huge by
then. You're stuffing new values into it on every iteration of the
outer loop. Two changes:

1. The inner while loop should only be done once, before you enter
   the "while (<INPUT_FILE>)" loop.

2. You should invert the if and the foreach. There's no need to do
   the test on every iteration if the thing you're testing doesn't
   change:

while(my($k, $v) = each %LOCATION) {
    push @{$LOCATIONS{$v}}, $k;
}

while (<INPUT_FILE>) {
    s/^\s+//;
    s/\r?\n$//;
    ($city, $statecode, $countrycode, $date1, $max1, $min1, $cond1,
     $date2, $max2, $min2, $cond2,
     $date3, $max3, $min3, $cond3, $date4, $max4, $min4, $cond4,
     $date5, $max5, $min5, $cond5, $date6, $max6, $min6, $cond6 )
        = split (/,/);
  
    $location = "$city,$statecode,$countrycode";

    if (exists $LOCATIONS{$location}) {
        foreach (@{$LOCATIONS{$location}}) {
            print OUTPUT_FILE "$_,$date1,$max1,$min1,$cond1\n";
        }
    }
}

-- Dave Tweed


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

Date: Wed, 26 Sep 2001 22:42:03 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: faster execution
Message-Id: <slrn9r3j8q.8ai.mgjv@martien.heliotrope.home>

On Wed, 26 Sep 2001 12:16:05 GMT,
	Dave Tweed <dtweed@acm.org> wrote:
> venus wrote:
>> The script runs halfway and stopped with the message:
>> Segmentation fault (core dumped)
> 
> Not too surprising, given that %LOCATIONS must be pretty huge by
> then. You're stuffing new values into it on every iteration of the
> outer loop. Two changes:

Still surprising. Perl should not dump core simply because it can't get
memory anymore. In fact, it should exit with the message

  Out of memory!

or one of the related messages documented in perldiag. If it dumps core
because malloc returned NULL, it is a bug.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Little girls, like butterflies, need
Commercial Dynamics Pty. Ltd.   | no excuse - Lazarus Long
NSW, Australia                  | 


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

Date: 26 Sep 2001 11:56:48 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Getting NULLS after a lockup from using up memory
Message-Id: <1001505192.16810@itz.pp.sci.fi>

In article <9oqd05$frq$1@eskinews.eskimo.com>, Xeno Campanoli wrote:
>I wish there was more information about this.  Perhaps I need to read
>something on Linux.  Is there any README out there on this kind of
>failure for Linux or Unices in general?

We also wish there was more information.  You have not shown us any
code, and you still haven't described what a "null of varying length"
is.  How are we supposed to know what kind of failure you're talking
about?  We can't read your mind, you know.

(Speaking for myself, and probably for most people here who even bother
to read this thread.)

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post something,
we discuss its implications.  If the discussion happens to answer a question
you've asked, that's incidental."           -- nobull in comp.lang.perl.misc



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

Date: 26 Sep 2001 12:07:53 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Goto and global variables
Message-Id: <9osgep$571$1@sloth.swcp.com>

[ Posted and cc'd to cited author ]

David Scarlett <dscarlett@REMOVETHIS.optushome.com.au> wrote:
> "Tramm Hudson" <hudson@swcp.com> wrote in message
> >
> > Nor is my favorite use of this construct -- tail recursion.
>
> What exactly is tail recursion? Judging by your example I'd say that it's
> where, up until the last call, the functions don't return anything to their
> calling functions.

Exactly.  And the compiler can be smart enough to remove all traces of
the current function on the stack before making the call in "tail
position", so the stack never grows.  In my "my_map" example, only
one stack frame was used, regardless of how many items where in the
list.  A non-tail recursive call would have built n stack frames.

Google can tell you lots about it:

	http://www.google.com/search?q=%22tail+recursion%22

You'll note that most of the examples are in Scheme.  That is where
I learned about it, too.  You might also be interested in "continuation
passing style", something that Perl only sort of implements.

ObPerl: goto &name is a way to emulate a tail position call.  Which is
how this whole topic came up.  But ther Perl content is vanishingly
small, so follow-ups are set.

Trammell
-- 
  o   hudson@swcp.com                                         O___|   
 /|\  http://www.swcp.com/~hudson/          M 240.476.1373    /\  \_  
 <<   KC5RNF                                H 505.315.5133    \ \/\_\  
  0                                                            U \_  | 


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

Date: Wed, 26 Sep 2001 12:50:18 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Goto and global variables
Message-Id: <3bb1cf0a.2146$1e0@news.op.net>

In article <cias7.3907$98.19090@news1.rivrw1.nsw.optushome.com.au>,
David Scarlett <dscarlett@REMOVETHIS.optushome.com.au> wrote:
>> That's silly.  Perl probably uses almost as many parentheses as Lisp.
>
>Bah. It was funny at the time - he had a slide up with a piece of sample
>lisp code, and half the characters in it were parentheses. ;-)

That seems like an exaggeration, since even a simple expression like
(list x)  is only 25% parentheses.  I suspect you wouldn't know a
50%-parentheses text if you saw one.

On the other hand, I can show you real Perl code, not intended as a
joke, posted by someone else to this newsgroup in the last twelve
months, in which ten percent of the characters are backslashes.
Do you find that funny as well?




-- 
@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: Wed, 26 Sep 2001 13:38:40 +0100
From: "W K" <bill.kemp@wire2.com>
Subject: Re: How can I use a filehandle indirectly?
Message-Id: <G%js7.835$t97.9465@news.uk.colt.net>

>   How can I use a filehandle indirectly?
>
>     An indirect filehandle is using something other than a symbol in a
place
>     that a filehandle is expected. Here are ways to get indirect
>     filehandles:
>
>         $fh =   SOME_FH;       # bareword is strict-subs hostile
>         $fh =  "SOME_FH";      # strict-refs hostile; same package only
>         $fh =  *SOME_FH;       # typeglob
>         $fh = \*SOME_FH;       # ref to typeglob (bless-able)
>         $fh =  *SOME_FH{IO};   # blessed IO::Handle from *SOME_FH typeglob


I was under the impression that we didn't need to worry about how it works,
from 5.6 onwards
just
open ($fh ,"afile") or die "In pain $!";




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

Date: 26 Sep 2001 00:42:49 -0700
From: crud@hongkong.com (Dav Lam)
Subject: how to get perl invoke internet explorer and navigate with it?
Message-Id: <fc25f4f2.0109252342.377cd8c0@posting.google.com>

is it related the something like ole automation?
but i've searching through google and microsoft, but still found no clue
no documents is about the ole interface of the internet explorer?

what i'm trying to do now is just to invoke IE from perl, and let it
navigate a site and print the webpage out and that's it?

is perl capable to do this?

Thanks in advance


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

Date: Wed, 26 Sep 2001 09:46:27 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: how to get perl invoke internet explorer and navigate with it?
Message-Id: <eq13rtsutcfpoj8psc85d97ajgrspugmm3@4ax.com>

On 26 Sep 2001 00:42:49 -0700, crud@hongkong.com (Dav Lam) wrote:
>is it related the something like ole automation?

If you just need to launch IE, use `start $url`.

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Wed, 26 Sep 2001 11:23:36 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Is there a better way to do this??
Message-Id: <3bb1bab8.1ee1$2c@news.op.net>

In article <MPG.161af23bd6d5049c9897a8@news.edmonton.telusplanet.net>,
Carlos C. Gonzalez  <aperlprogrammer@yahoo.com> wrote:
>David Hilsee at davidhilseenews@yahoo.com said...
>> 
>> If you don't like a lot of action in your if clauses, then take the action
>> out.
>> 
>> %data = found('jacky@ardvark.com');
>> if ( not %data )...
>> 
>
>Thanks David.

You can get rid of the 'not':
        %data = found('jacky@ardvark.com');
        if (%data) {
          print $data{email_address};
        } else {
          print "Nothing there!\n";
        }

Under the circumstances, I think this is better than Uri's suggestion
of 'unless'.

-- 
@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: 26 Sep 2001 11:27:29 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Looking for OO/AUTOLOAD info
Message-Id: <1001502851.11944@itz.pp.sci.fi>

In article <eaa2c627.0109240730.2ea0feca@posting.google.com>, Aaron Sherman wrote:
>
> sub AUTOLOAD {my$s=shift;my$f=$AUTOLOAD;$s->xxx($f,@_) unless $f =~ /DESTROY/}
>
>So, what I'm trying to find out is... is this the way I *should* be
>doing auto-loaded methods?

Pretty much, yes.  If you wanted to squeeze out the last few drops of
performance gain, you could create stub methods at runtime, but I don't
think that would help much in your case.

Not that your code couldn't be made cleaner, mind you...

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post something,
we discuss its implications.  If the discussion happens to answer a question
you've asked, that's incidental."           -- nobull in comp.lang.perl.misc



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

Date: 26 Sep 2001 09:00:08 -0400
From: bill <bill02115@hotmail.com>
Subject: MIME::Lite problem
Message-Id: <9osjgo$rga$1@panix3.panix.com>



I'm having a problem with MIME::Lite.  I'm using it to send e-mails of
the form:

  Dear Dr. Foo:

  Attached please find the schedule for your upcoming visit.

  Sincerely,

  Dr. Bar

  < pdf attachment >

Everything works fine, including the attachment, but, at the receiving
end, the e-mail (as presented by Eudora) shows an unsightly header of
directives, like this:

  Content-Disposition: inline
  Content-Length: 326
  Content-Transfer-Encoding: binary
  Content-Type: text/plain

  Dear Dr. Foo:

  < etc. >

Such header do not appear when I send the e-mail (with the same
attachment) through Eudora.

The code in question looks like this (upper-case variables are pre-set
constants):

  my $msg = new MIME::Lite(From       => FROM,
			   To         => TO,
			   Subject    => SUBJECT,
			   'Reply-To' => REPLY_TO,
			   Type       => 'multipart/mixed');

  # I got the following settings from inspecting the equivalent mailing
  # as produced by Eudora.
  $msg->attr('content.type'    => 'text/plain',
	     'content.charset' => 'us-ascii',
	     'content.format'  => 'flowed');
  $msg->attach(Data => SALUTATION . "\n\n" . INTRO);

  $msg->attach(Type        => 'application/pdf',
	       Path        => PDF_FILE,
	       Disposition => 'attachment');

  $msg->send;

Any ideas on how to suppress the first set of headers?

Thanks,

bill


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

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


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