[16707] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4119 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 24 14:05:39 2000

Date: Thu, 24 Aug 2000 11:05: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: <967140316-v9-i4119@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 24 Aug 2000     Volume: 9 Number: 4119

Today's topics:
    Re: A Proposal for BaseLib module (was Re: Modifying @I <mischief@motion.thispartfake.net>
        RE: direct screen access..... <chris@inta.net.uk>
        Environment variable SNAFU <pbarone@harris.com>
    Re: Environment variable SNAFU <lr@hpl.hp.com>
    Re: File handling and manipulation from function, help  <lr@hpl.hp.com>
    Re: fork (Abigail)
        help me decipher PERL <avisingh@my-deja.com>
    Re: help with simple regexp - does my head in <ren.maddox@tivoli.com>
    Re: help with simple regexp - does my head in <ren.maddox@tivoli.com>
    Re: help with simple regexp - does my head in <ren.maddox@tivoli.com>
        HELP!- Writing perl script <simon@nospam.edincc.co.uk>
    Re: HELP!- Writing perl script <care227@attglobal.net>
        How to sort time? zbernie@my-deja.com
    Re: How to sort time? (brian d foy)
    Re: How to sort time? (Greg Bacon)
        Implicit passing of arrays with prototypes <phrxy@csv.warwick.ac.uk>
    Re: Implicit passing of arrays with prototypes (Greg Bacon)
    Re: Just another silly post. <care227@attglobal.net>
    Re: Just another silly post. (brian d foy)
        Looking for Training Course <kliquori@my-deja.com>
    Re: Looking for Training Course <care227@attglobal.net>
    Re: Looking for Training Course (brian d foy)
    Re: newbie:? string sub through an array (Teodor Zlatanov)
    Re: Perl vs. other scripting languages <godzilla@stomp.stomp.tokyo>
    Re: Perl vs. other scripting languages <smerr612@mailandnews.com>
        Quick way to determine if a method is implemented in OO (Jeffrey Horn)
    Re: Quick way to determine if a method is implemented i (brian d foy)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 24 Aug 2000 11:34:38 -0500
From: "Chris Stith" <mischief@motion.thispartfake.net>
Subject: Re: A Proposal for BaseLib module (was Re: Modifying @INC...)
Message-Id: <sqajkfbpt91172@corp.supernews.com>


"Hasanuddin Tamir" <hasant@trabas.com> wrote in message
news:8o2lh4$s75$1@nnrp1.deja.com...
> In article <39a4b3d5@news.victoria.tc.ca>,
>   yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote:
> > Hasanuddin Tamir (hasant@trabas.com) wrote:
> > : In article <sq8n506bt91153@corp.supernews.com>,
> > :   "Chris Stith" <mischief@motion.thispartfake.net> wrote:
> > : >
> > : > "Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
> > : > news:39a41d62@news.victoria.tc.ca...
> > : > > hasant@trabas.com wrote:

> This thread didn't go as expected since you seemed to only
> quote the problem part. But I also realized that I have put
> misleading subject and that people tend to quick-scanning
> part of (specially long) ng message. If this is not true, I'm
> sorry, never meant to blame anyone but myself.

The solutions provided do apply to your requirements.
Just because someone snips a portion of your message
doesn't mean they aren't interested in it. I snip for
brevity and clarity. If I feel that the readers of my post
will get a clear understanding of what I'm posting without
including the full original post, I'll do that. In fact, this post is an
example. I'll respond to one of your other points
without including the original, because I'm confident that
my prose is clear enough to stand on its own since I'll
allude to the original without actually quoting it. This
is one way, in fact, that people have been communicating
for millennia.

I'm not sure why, when you ask us to discuss the usability,
viability, and desirability of a new module and we offer
simpler alternatives, you seem to get defensive and point
out that we were not discussing the module. As a matter of fact, it's pretty
close to impossible to express the
opinion that the module is unneccessary and make a
strong argument to that effect without pointing out
alternatives. Since some of us pointed out alternatives
which would be simpler than using a module, let alone
creating and distributing one, I'd say that *was*
discussion about the module, or at least about thee need
for it, which is one of the things people normally discuss
when discussing a possible new module.

I'd never discourage someone from publishing a module
if they believe it will help others, but when you asked for
discussion, I, personally, and possibliy others as well
assumed you were asking for all of our thoughts on the
matter, not just how to do it in a module. If you weren't
asking for our opinions on whether or not we thought it
was a module we'd use, I'm sorry to have possibly
offended you by bringing up that topic. By all means,
go ahead and publish your module. I'm sure many
people will use it. I will not. Since you did call your post
a proposal, it would definitely seem to ask for comment
on the need for the module as well as how to implement
it.

> So I think I need to repost what I wanted to say in a new thread
> to make this straight (hopefully). I hope both of you, Chris and
> Malcolm, are still interested in discussing this matter.

I am interested in continuing the thread, but please do not
make it a new thread. That will confuse people's news
readers into displaying it separately, including mine. I have
this thread marked to watch, and I'd hate to miss the new
thread. I think there is a lot that could be gained by
discussion of this, and maybe we could help figure out
how to best implement the module, since you seem set
to do so. Please understand I have nothing against having
a module available to do this, I just think it wouldn't be
very crucial that it be done with a module as opposed to
by hand, since it's not that much code to add to each
program.

Chris Stith (Mr. Mischief) mr_mischief1@hotmail.com
Motion Internet mischief@motion.net
Never underestimate the power of sheer idiocy.




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

Date: Thu, 24 Aug 2000 16:11:12 +0100
From: "Chris Denman" <chris@inta.net.uk>
Subject: RE: direct screen access.....
Message-Id: <8o3e2o$43r$1@news2.vas-net.net>

I didn't say that I wanted the code to be portable.

I also didn't expect you to be helpful, but did expect you to be
condescending and pedantic.

I you can't be constructive, then be destructive elsewhere.

I find perl a language that allows me to express myself quite easily.  I
merely wanted to express my interest in programming pointless games in Perl,
just for the hell of it.

I had a good look around for the answer, to no avail.  This newsgroup has
genuine people that do want to help.  I thank all of those people who have
helped me in the past.

It's people like you that stop people wanting to learn.

All the best,

Chris Denman

(oh, if you post replies just to wind people up, then you do a good job and
it worked on me)

-----Original Message-----
From: Abigail <abigail@foad.org>
Newsgroups: comp.lang.perl.misc
Date: Thursday, August 24, 2000 3:23 AM
Subject: Re: Direct screen access


>Chris Denman (chris@inta.net.uk) wrote on MMDXLVIII September MCMXCIII in
><URL:news:8ntttl$19hl$1@news2.vas-net.net>:
>&& Is it possible to change the video adapter mode to, say, 320X200X256 ?
>
>Perhaps. But that highly depends on your system. What if you run your
>program on a headless box?
>
>&& I know the screen address is at a000 and is 64K in size (in 256 colour
>&& mode).
>
>Goodie. But that isn't very portable, is it?
>
>&& The reason being, is I would love to write a simple game in Perl (and
have
>&& done so years ago in C).
>
>You might want to write an XS program to write directly to certain memory
>addresses.
>
>
>Abigail
>--
>srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
>//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"





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

Date: Thu, 24 Aug 2000 11:32:36 -0400
From: Phil Barone <pbarone@harris.com>
Subject: Environment variable SNAFU
Message-Id: <39A54014.5881D546@harris.com>

Hi,
  How would you go about this? My problem is this. I've tried a few
nasty workarounds but nothing I'm happy with.

I have a perl script that creates a file that will contain environment
variables and their settings.
The file is similar to your average .cshrc file.

The question is how do I make use of variables set in this ".cshrc" file
from other scripts I want to execute AFTER I write this file out. The
scripts that I will execute may be perl or bourne or c shell.

--
Phil Barone (e-mail: pbarone@harris.com)
Oracle DBA
ICQ 34117606
IAS Program, Harris Corp




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

Date: Thu, 24 Aug 2000 10:47:12 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Environment variable SNAFU
Message-Id: <MPG.140eff7dd69bd96498acd7@nntp.hpl.hp.com>

In article <39A54014.5881D546@harris.com> on Thu, 24 Aug 2000 11:32:36 -
0400, Phil Barone <pbarone@harris.com> says...
> Hi,
>   How would you go about this? My problem is this. I've tried a few
> nasty workarounds but nothing I'm happy with.
> 
> I have a perl script that creates a file that will contain environment
> variables and their settings.
> The file is similar to your average .cshrc file.
> 
> The question is how do I make use of variables set in this ".cshrc" file
> from other scripts I want to execute AFTER I write this file out. The
> scripts that I will execute may be perl or bourne or c shell.

This isn't really a Perl question.  Here is the complete answer from 
perlfaq8:

I {changed directory, modified my environment} in a perl script. How 
come the change disappeared when I exited the script? How do I get my 
changes to be visible?

Unix

In the strictest sense, it can't be done -- the script executes as a 
different process from the shell it was started from. Changes to a 
process are not reflected in its parent, only in its own children 
created after the change. There is shell magic that may allow you to 
fake it by eval()ing the script's output in your shell; check out the 
comp.unix.questions FAQ for details.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 24 Aug 2000 10:31:01 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: File handling and manipulation from function, help please?
Message-Id: <MPG.140efbb1b5bf6c6f98acd5@nntp.hpl.hp.com>

In article <39A534F6.CCD266A5@attglobal.net> on Thu, 24 Aug 2000 
10:45:10 -0400, Drew Simonis <care227@attglobal.net> says...
> arvind_kuk@hotmail.com wrote:

 ...

> > sub subCall {
> > my($filename) = @_;
> 
> Better written (IMO) as my $filename = shift;  
> As it is right now, $filename is set to 1.  Certainly not what you
> want.  

Err, no.  It is set to $_[0], the same as with the shift(), but non-
destructive to the argument list.  You overlooked the parentheses, which 
create list context for the declared variable.

I wouldn't choose to write it that way for one variable, but it is very 
easy to extend to two or more:

    my ($filename, $foobar) = @_;

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 24 Aug 2000 15:06:06 GMT
From: abigail@foad.org (Abigail)
Subject: Re: fork
Message-Id: <slrn8qaedj.tj3.abigail@alexandra.foad.org>

Jean-Damien Bouvier (wokup.balr005@rd.francetelecom.fr) wrote on MMDL
September MCMXCIII in <URL:news:39A50A65.8B03C1D6@rd.francetelecom.fr>:
\\ 
\\ I discovered Perl since 2 days and i'm facing my first serious problem :
\\ I want to launch a little java program from within my script and be able
\\ to kill it later. As the fork function is not implemented (under NT but
\\ the script have to work on both NT and Linux), I've no idea how to deal
\\ with it. 


Upgrade. Perl 5.6.0 does support fork() under NT.


Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: Thu, 24 Aug 2000 16:37:28 GMT
From: CyberEyes <avisingh@my-deja.com>
Subject: help me decipher PERL
Message-Id: <8o3j05$u74$1@nnrp1.deja.com>

Hi
I am less than a newbie to PERL CGI scripting. Can anybody help me
decipher the perl code below which is giving the error on the webserver
following the code and a possible resolve.

Thanks
Avatar
<code>
sub process_pdf
  {
    my($link, $title, $size, $score, $number) = @_;
    my($preview, $rvalue, $number);
    my($pdfpreview, $pdftitle, $pdfauthor, $pdfpages, $filename);
</code>
<error-msg>
[Thu Aug 24 10:13:46 2000] [error] [client 38.178.152.199] Premature
end of scri
pt headers: /opt/IBMHTTPServer/cgi-bin/search.cgi
"my" variable $number masks earlier declaration in same scope
at /opt/IBMHTTPSer
ver/cgi-bin/search.cgi line 623.
</error-msg>

<code>
$mgout .= &process_calendar($category_file[$i], $words, $start, $end);
		    $category_total[$i] = $total;
</code>
<error-msg>
Name "main::mgout" used only once: possible typo
at /opt/IBMHTTPServer/cgi-bin/s
earch.cgi line 375.
Use of uninitialized value at /opt/IBMHTTPServer/cgi-bin/search.cgi
line 460.
</error-msg>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 24 Aug 2000 10:24:15 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: help with simple regexp - does my head in
Message-Id: <m3bsyi7kdc.fsf@dhcp11-177.support.tivoli.com>

abigail@foad.org (Abigail) writes:

> Ren Maddox (ren.maddox@tivoli.com) wrote on MMDXLIX September MCMXCIII in
> :} Um... It doesn't seem like negative values for the number of
> :} iterations is doing what you think.  It looks like it causes each case
> :} (individually) to run for at least (in this case) 10 seconds.
> 
> Well, duh! That's why I used a negative number. It's doing exactly
> what it is supposed to be doing.

Certainly.
 
> :}                                                                But if
> :} you look at the values of n, they are substantially different.  So the
> :} cases are not being run the same number of times.
> 
> So? It also reports the number of times per second it ran, and both
> seconds are of equal lenght.

Agreed.

> :} Changing your -10 to 10_000_000 in your first benchmark shows 1 to be
> :} significantly faster than -1 (30% to 40%).
> 
> Really? Can we see the output of the benchmark? Considering you didn't
> read my results properly, I'm not taking your word for granted.


#!/opt/perl/bin/perl -w

    use strict;

    use Benchmark;

    use vars qw /@a/;

    @a = (1 => 2);

    timethese 10_000_000 => {
         1  =>  'my $a = $a [ 1]',
        -1  =>  'my $a = $a [-1]',
    };

__END__

Benchmark: timing 10000000 iterations of -1, 1...
        -1: 12 wallclock secs (12.85 usr +  0.02 sys = 12.87 CPU) @ 777000.78/s (n=10000000)
         1:  9 wallclock secs ( 9.12 usr +  0.02 sys =  9.14 CPU) @ 1094091.90/s (n=10000000)

> (And note that in my benchmark, the speed difference is about 15%).

A difference that seems worth noting, rather than focusing on the
absolute difference of 355 nanoseconds.  After all, if one version
took 1 nanosecond, and the other took 356 nanoseconds, that would
still be a very small difference -- until you run it millions of
times.  The percent difference seems more important.

However, I do want to reiterate that my final conclusion, in light of
the fact that the split dominates the performance by an order of
magnitude, was:

> :} In the end though, you are exactly right.  This shouldn't be a
> :} performance issue -- use the form that makes sense.  If you want the
> :} 1st (2nd) field, use 1.  If you want the last field, use -1.  If you
> :} know that the 1st (2nd) field is always the last field, then use
> :} whichever one you like.

Oh, and just for completeness, here is my version of the second
benchmark:

#!/opt/perl/bin/perl -w

    use strict;

    use Benchmark;

    use vars qw /$orig_field/;

    $orig_field = "monkey=cute";

    timethese 1_000_000 => {
         1  =>  'my $attrval = (split "=" => $orig_field, 2) [ 1]',
        -1  =>  'my $attrval = (split "=" => $orig_field, 2) [-1]',
    };

__END__

Benchmark: timing 1000000 iterations of -1, 1...
        -1: 10 wallclock secs ( 8.36 usr +  0.01 sys =  8.37 CPU) @ 119474.31/s (n=1000000)
         1:  9 wallclock secs ( 8.60 usr +  0.01 sys =  8.61 CPU) @ 116144.02/s (n=1000000)

I decreased the iterations by an order of magnitude to compensate for
the dominance of the split.  I do wonder, however, why adding the
split leads to the negative index being faster (if just barely)??

-- 
Ren Maddox
ren@tivoli.com


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

Date: 24 Aug 2000 10:35:03 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: help with simple regexp - does my head in
Message-Id: <m366oq7jvc.fsf@dhcp11-177.support.tivoli.com>

mgjv@verbruggen.comdyn.com.au (Martien Verbruggen) writes:

> On 23 Aug 2000 15:43:17 -0500,
> 	Ren Maddox <ren.maddox@tivoli.com> wrote:
> > abigail@foad.org (Abigail) writes:
> > 
> > > Well, yeah, but the difference is insignificant. 
> [snip]
> > >     Benchmark: running -1, 1, each for at least 10 CPU seconds...
> > >             -1:  9 wallclock secs (10.62 usr + -0.03 sys = 10.59 CPU)
> > >                  @ 445933.52/s (n=4722436)
>                        ^^^^^^^^^^^
> > >              1: 14 wallclock secs (10.52 usr +  0.00 sys = 10.52 CPU)
> > >                  @ 529952.57/s (n=5575101)
>                        ^^^^^^^^^^^
> > Um... It doesn't seem like negative values for the number of
> > iterations is doing what you think.  It looks like it causes each case
> 
> I doubt that Abigail doesn't know what it means. I could be wrong, but
> I doubt that as well. Maybe you are incorrect in assuming that Abigail
> thought what you think she thought. Maybe I am incorrect in assuming
> that Abigail knew what I think she knew. But again, I doubt that.
> 
> > (individually) to run for at least (in this case) 10 seconds.  But if
> > you look at the values of n, they are substantially different.  So the
> > cases are not being run the same number of times.
> 
> I think Abigail was probably comparing the two underlined numbers, and
> they are significantly different.

Ah.. but she said that the difference was insignificant, while I (and
you, it appears) felt that the difference was significant.  In light
of this difference, I did not spend an appropriate amount of effort
understanding the source of her 355 nanosecond figure, and instead
jumped to the incorrect conclusion that she was misusing the module.
I regret my error but feel that my subsequent analysis is still
correct.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 24 Aug 2000 10:31:56 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: help with simple regexp - does my head in
Message-Id: <m38ztm7k0j.fsf@dhcp11-177.support.tivoli.com>

kcivey@cpcug.org (Keith Calvert Ivey) writes:

> Um, I don't think Abigail's thinking what you think she's
> thinking.
> 
>     (1 s)/445933.52 - (1 s)/529952.57 = roughly 355 ns
> 
> just as Abigail said.

Yes, my bad.  I did consider that, but didn't follow through with the
math.  I was just unable to reconcile her position that the difference
was insignificant with the fact that 445933.52/s and 529952.57/s are
appreciably different percentage-wise.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Thu, 24 Aug 2000 15:35:31 GMT
From: "Simon" <simon@nospam.edincc.co.uk>
Subject: HELP!- Writing perl script
Message-Id: <7hbp5.434$NR3.42837@news1.cableinet.net>

Hi everyone

I'm looking for someone to write or help me write a perl script  that will
process data coming from an HTML form with and attachment.  Lots of people
have suggested using mime::lite.

The problem I am having is writing the script, I have a perl script which I
use all the time but it just processes form data.  Ideally I would like to
modify my existing script to handle the attachment.  I am interested in
learning more about perl but unfortunately I have a fast approaching
deadline.

May be able to offer some reward for this.

Thanks in anticipation

Simon
http://simonwebdesign.com







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

Date: Thu, 24 Aug 2000 11:55:59 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: HELP!- Writing perl script
Message-Id: <39A5458F.90F67D39@attglobal.net>

Simon wrote:
> 
> Hi everyone
> 
> I'm looking for someone to write or help me write a perl script  that will
> process data coming from an HTML form with and attachment.  Lots of people
> have suggested using mime::lite.
> 

What are you meaning?  A form with an attachment?  This isn't 
possible.  If you mean uploading a file via a web form, that
is handled quite nicely by CGI.pm.  MIME::Lite is, well, MIME.
MIME is not HTTP.

I suggest posting to comp.infosystems.www.authoring.cgi, where
this sort of question _might_ be better answered.

(With my appologies to the regular posters in that group)


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

Date: Thu, 24 Aug 2000 17:18:51 GMT
From: zbernie@my-deja.com
Subject: How to sort time?
Message-Id: <8o3ld5$184$1@nnrp1.deja.com>

How can you sort a time in the format hh:mm:ss?
For example, here's a code fragment that obtains the
time from the 8th column after the split, then gets
a running total.  What I need to do is print out the
times in decending order.

-Thanks!


  open(HFILE, $ARGV[0]) || die "Can't open file: $!\n";

    while (<HFILE>) {

      ($col1, $col2, $col3, $col4, $col5, $col6, $col7, $col8, $col9,
$col10) = split(/\t/, $_);


      ($hr, $min, $sec) = split(/:/, $col8);
      $rtotal += $sec + ($min * 60) + ($hr * 3600);

    }#end while

  close(HFILE);


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 24 Aug 2000 13:58:52 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: How to sort time?
Message-Id: <brian-ya02408000R2408001358520001@news.panix.com>

In article <8o3ld5$184$1@nnrp1.deja.com>, zbernie@my-deja.com posted:

> How can you sort a time in the format hh:mm:ss?

did you try a simple sort:

   @sorted = sort @times;

was that not what you needed?

you might also see the Perl FAQ on "How do I sort an array on anything"
or some such.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Thu, 24 Aug 2000 17:57:24 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: How to sort time?
Message-Id: <sqaog4gt9163@corp.supernews.com>

In article <8o3ld5$184$1@nnrp1.deja.com>,
     <zbernie@my-deja.com> wrote:

: How can you sort a time in the format hh:mm:ss?
: For example, here's a code fragment that obtains the
: time from the 8th column after the split, then gets
: a running total.  What I need to do is print out the
: times in decending order.

If the times are padded, e.g., five past one in the morning is 01:05:00,
then you can sort them with one of the following

    @sorted = sort { $b cmp $a } @times;
    @sorted = reverse sort @times;

Greg
-- 
I dream of a world where you can buy liquor, cigarettes and firearms at a
drive-through and use them all before you get home.  Basically anything that
gets rid of people, but FIRST, BUY MY BOOK!
    -- Scott Adams


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

Date: Thu, 24 Aug 2000 17:08:32 +0100
From: "John J. Lee" <phrxy@csv.warwick.ac.uk>
Subject: Implicit passing of arrays with prototypes
Message-Id: <Pine.SOL.4.21.0008241628480.14691-100000@mimosa.csv.warwick.ac.uk>


Why does this:

#!/usr/bin/perl -w

@list = (1, 2, 3);
foo(@list);

sub foo(\@) {
#    my @list = @{shift()};
    my @list = @_;
    print join ', ', @list;
}

output this:
1, 2, 3

whereas moving the # one line down to comment the second 'my' outputs
nothing at all?

In other words, why doesn't the prototype appear to work - isn't the \@
prototype supposed to give you a reference when you pass an array?

Thanks for any help


perl -v output:

This is perl, version 5.005_03 built for MSWin32-x86-object
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-1999, Larry Wall

Binary build 522 provided by ActiveState Tool
Corp. http://www.ActiveState.com
Built 09:52:28 Nov  2 1999


John





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

Date: Thu, 24 Aug 2000 18:02:47 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Implicit passing of arrays with prototypes
Message-Id: <sqaoq7cbt91106@corp.supernews.com>

In article <Pine.SOL.4.21.0008241628480.14691-100000@mimosa.csv.warwick.ac.uk>,
    John J. Lee <phrxy@csv.warwick.ac.uk> wrote:

: Why does this:
: 
: #!/usr/bin/perl -w
: 
: @list = (1, 2, 3);
: foo(@list);
: 
: sub foo(\@) {
: #    my @list = @{shift()};
:     my @list = @_;
:     print join ', ', @list;
: }
: 
: output this:
: 1, 2, 3

Because the compiler will not have seen foo()'s prototype when it
compiles the call to foo().  Either lay out your code in Pascal order
(define subs before calling them) or predeclare foo() like

    sub foo(\@);

    @list = (1, 2, 3);
    foo(@list);

    sub foo { ... }

Greg
-- 
One tequila, two tequila, three tequila, floor.
    -- George Carlin


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

Date: Thu, 24 Aug 2000 11:14:51 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Just another silly post.
Message-Id: <39A53BEB.BD826DE5@attglobal.net>

Policy Man wrote:
> 
> "Joe C. Hecht" wrote:
> 
> > > I have a challenge for you.
> >
> > Is this a homework assignment you need help with?
> 
> Does it strike you as one? If so, why?

Strikes me as inane.


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

Date: Thu, 24 Aug 2000 13:55:38 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Just another silly post.
Message-Id: <brian-ya02408000R2408001355380001@news.panix.com>

In article <39A5080F.3FB38B79@yahoo.com>, Policy Man <reljr_2@yahoo.com> posted:

> brian d foy wrote:
> 
> > In article <39A48859.B8FA1697@yahoo.com>, Policy Man <reljr_2@yahoo.com> posted:


> > > eval (<>)  ;

> > > apparently produces nothing.

> > give it some input.  see the docs on the <> operator.

> Brian, perhaps I'm unable to communicate the basic fact that
> this code must actually function inside a larger body of code. 

i think you are unable to communicate why i should care.  if you 
don't like the solution, ignore it.

> I am aware of the <> operator. I just don't see how it fits with the requirements I made.

i don't see how it doesn't.

you wanted a solution.  i gave you one.  don't cry because i got
around your contrived and stupid requirements.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Thu, 24 Aug 2000 15:20:53 GMT
From: kliquori <kliquori@my-deja.com>
Subject: Looking for Training Course
Message-Id: <8o3efq$oih$1@nnrp1.deja.com>

Does anyone know of a course I could attend for Perl? Preferably for
intermediate level and somewhere in the United States. I haven't been
able to find anything on the Web.

TIA
 ...Kevin


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 24 Aug 2000 11:53:12 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Looking for Training Course
Message-Id: <39A544E8.3B351CA@attglobal.net>

kliquori wrote:
> 
> Does anyone know of a course I could attend for Perl? Preferably for
> intermediate level and somewhere in the United States. I haven't been
> able to find anything on the Web.
> 
> TIA
> ...Kevin
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Wow.  How far did you look?  Did you check www.perl.com?
Or maybe the well known and respected Stonehenge Consulting?

http://www.stonehenge.com/perltraining/
http://training.perl.com/

I did a quick google websearch and found dozens of hits.  Looks
like you took the lazy way.  

*plonk*


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

Date: Thu, 24 Aug 2000 14:00:10 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Looking for Training Course
Message-Id: <brian-ya02408000R2408001400100001@news.panix.com>

In article <8o3efq$oih$1@nnrp1.deja.com>, kliquori <kliquori@my-deja.com> posted:

> Does anyone know of a course I could attend for Perl? Preferably for
> intermediate level and somewhere in the United States. I haven't been
> able to find anything on the Web.

then you didn't look at www.perl.org which lists several alternatives.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: 24 Aug 2000 13:58:53 -0500
From: tzz@iglou.com (Teodor Zlatanov)
Subject: Re: newbie:? string sub through an array
Message-Id: <39a5625d$1_1@news.iglou.com>

<8o0uof$s04$1@nnrp1.deja.com>:coughlan@gothaminteractive.com:comp.lang.perl.misc:Wed, 23 Aug 2000 16:39:46 GMT:quote:
: What's the easiest way to do a string subtritution of "A" for "B"
: throughout an array @myarray?

I like both
map { s/A/B/ } @myarray;
and
s/A/B/ foreach @myarray;

depending on the context they can both be useful.

I benchmarked the two approaches:
#!/usr/bin/perl

use Benchmark;


timethese(1000000,
{ 
 'map' => sub { @myarray = qw/A B C/; map { s/A/B/ } @myarray;  }, 
 'foreach' => sub { @myarray = qw/A B C/; s/A/B/ foreach @myarray;  }, 
});

   foreach: 46 wallclock secs (35.80 usr +  0.05 sys = 35.85 CPU) @ 27894.00/s (n=1000000)
       map: 62 wallclock secs (57.99 usr +  0.08 sys = 58.07 CPU) @ 17220.60/s (n=1000000)

so map is slower in this context.

-- 
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais


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

Date: Thu, 24 Aug 2000 09:11:21 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Perl vs. other scripting languages
Message-Id: <39A54929.784240C0@stomp.stomp.tokyo>

Martien Verbruggen wrote:

> Godzilla! wrote:

> [fsck. Am I sorry that your score expired just this morning.
> You've got a fresh, and this time more permanent one. tata]
 
> To anyone not yet clued in: Mussolini made more sense on his
> bad days than this troll on its good days.



Based on your posting history, El Duce, especially your 
misogynistic postings, I am not at all surprised you, 
like almost all others here, are a Mussolini worshipper.

Still, there are times your abhorrent misogynistic comments
remind me more of lady finger eating Idi Amin.

You will not silence this intellectual, El Duce.

Godzilla!


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

Date: Thu, 24 Aug 2000 16:57:41 GMT
From: Steven Merritt <smerr612@mailandnews.com>
Subject: Re: Perl vs. other scripting languages
Message-Id: <8o3k5o$vn5$1@nnrp1.deja.com>

In article <39A54929.784240C0@stomp.stomp.tokyo>,
  "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:

> You will not silence this intellectual, El Duce.
>
> Godzilla!

ROFLMAO!!  Gojira claiming to be an intellectual. That's like CmdrTaco
claiming to be a Perl hacker!

Steven
--
King of Casual Play
The One and Only Defender of Cards That Blow


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 24 Aug 2000 17:17:32 GMT
From: horn@wheel.cs.wisc.edu (Jeffrey Horn)
Subject: Quick way to determine if a method is implemented in OO module
Message-Id: <8o3lbc$e62@spool.cs.wisc.edu>

Given an OO module, what is the fastest (best?) way to determine if the module
implements a given method?

The specific case I have in mind is determining whether or not a DBD module
implements the 'reauthenticate' method.  Is there a way to check the internal
symbol table to look for given subroutines?

Any ideas are most appreciated!

-- Jeff
-- 
Jeffrey Horn (horn@cs.wisc.edu)        |BELZER,BERNHARDT,BOETTCHER,DRAVIS,FETTER
PHONE:(608) 846-1932                   |GAPINSKI,GAUGER,HARMS,HIRSCHINGER,HORNE
FAX:  (608) 846-1934                   |JUECH,KLAJBOR,KROIS,KRONING,LEMKE,RUNGE
http://www.cs.wisc.edu/~horn/horn.html |STOCK,TAUBERT,TRESKE,WILLMERT,ZILLMER


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

Date: Thu, 24 Aug 2000 13:59:36 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Quick way to determine if a method is implemented in OO module
Message-Id: <brian-ya02408000R2408001359360001@news.panix.com>

In article <8o3lbc$e62@spool.cs.wisc.edu>, horn@wheel.cs.wisc.edu (Jeffrey Horn) posted:

> Given an OO module, what is the fastest (best?) way to determine if the module
> implements a given method?

can() is the method you seek

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 4119
**************************************


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