[9552] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3146 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 13 21:07:16 1998

Date: Mon, 13 Jul 98 18:00:43 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 13 Jul 1998     Volume: 8 Number: 3146

Today's topics:
    Re: "The opposite of read()" (M.J.T. Guy)
    Re: arrays and pattern matching (Ronald J Kimball)
    Re: Arrays (Martien Verbruggen)
    Re: compare arrays (M.J.T. Guy)
    Re: compare arrays (Craig Berry)
    Re: First meeting of Dallas.pm (Abigail)
    Re: First meeting of Dallas.pm (Ronald J Kimball)
    Re: forking on win32 (Tye McQueen)
    Re: HELP: Internet Database Design questions... (-)
    Re: HELP: Internet Database Design questions... (-)
    Re: How can you encrypt a CGI script on a server so it  (Martien Verbruggen)
    Re: How do chang groups (Martien Verbruggen)
    Re: Perl 4 compilation on Solaris 2.6 (Abigail)
    Re: Perl Beautifier Home Page (M.J.T. Guy)
    Re: Perl Beautifier Home Page (Ilya Zakharevich)
        Perl Question (ShearerUK)
    Re: PERL Tutorial Frank_Zhu@my-dejanews.com
    Re: Perl-HTML not interpreted (Martien Verbruggen)
    Re: Quickie: the number of occurences of a character in (Larry Rosler)
    Re: Reading Directories w/ Perl (Gabor)
        Readonly arrays <achoy@us.oracle.com>
    Re: Readonly arrays <rick.delaney@shaw.wave.ca>
    Re: Recommend me Perl! <p-fein@uchicago.edu>
    Re: Recommend me Perl! (Ronald J Kimball)
    Re: Recommend me Perl! (Gabor)
        talking to POP3 servers <smw3@doc.ic.ac.uk>
    Re: use Sys::Syslog tricks (Martien Verbruggen)
    Re: Using Perl to generate HTML Pages. (Craig Berry)
        Using Perl with DCOM <kbp1527@ihgp.lucent.com>
    Re: What's the substitute for #! /usr/bin/perl in Win32 (Ronald J Kimball)
    Re: Why is Dave operating here? (was Re: REPOST: Re: ) (Abigail)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 13 Jul 1998 23:28:58 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: "The opposite of read()"
Message-Id: <6oe57q$pv9$1@pegasus.csx.cam.ac.uk>

John Siracusa <macintsh@cs.bu.edu> wrote:
>Oh, and while I'm here, word on the street (heh) is that
>calling functions with &func is now deprecated.  Why?

I tend to avoid &func because it looks ugly.   But that's something
very different from being deprecated.    And of course, there are cases
where the & is essential.    As "perldoc perlsub" says

     A subroutine may be called using the "&" prefix.  The "&" is
     optional in modern Perls, and so are the parentheses if the
     subroutine has been predeclared.  (Note, however, that the
     "&" is NOT optional when you're just naming the subroutine,
     such as when it's used as an argument to defined() or
     undef().  Nor is it optional when you want to do an indirect
     subroutine call with a subroutine name or reference using
     the &$subref() or &{$subref}() constructs.  See the perlref
     manpage for more on that.)

Or are you referring to the special case where &func is used with no
arguments?

                                             If a subroutine is
     called using the "&" form, the argument list is optional,
     and if omitted, no @_ array is set up for the subroutine:
     the @_ array at the time of the call is visible to
     subroutine instead.  This is an efficiency mechanism that
     new users may wish to avoid.

I suppose that last sentence could be considered a mild deprecation.


Mike Guy


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

Date: Mon, 13 Jul 1998 20:40:24 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: arrays and pattern matching
Message-Id: <1dc4g8k.kom83itsj394N@bay2-93.quincy.ziplink.net>

Naomi Wyman <nwyman@mda.ca> wrote:

> I am trying to match a pattern based on values in an array, which are
> all strings. I'm thinking using something like: /(\b[@Types]+\b)\s+/i).

That won't even compile under recent versions of Perl:

In string, @Types now must be written as \@Types, near "(\b[@Types"

What exactly are you trying to do?

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 13 Jul 1998 22:48:00 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Arrays
Message-Id: <6oe2r0$388$2@comdyn.comdyn.com.au>

In article <6odcvi$jim$1@nnrp1.dejanews.com>,
	merzky@physik.hu-berlin.de writes:

> I guess he just declared something like
> my ($array);
> before, or used it in scalar context...

Like I pointed out in another post in this thread: $array, @array and
%array are different identifiers. They point to different things.
Using $array[$i] automatically means that you are referring to
element $i of the array denoted by @array. Not the scalar, not the
hash.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd.       | things get worse.
NSW, Australia                      | 


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

Date: 13 Jul 1998 23:49:07 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: compare arrays
Message-Id: <6oe6dj$qpp$1@pegasus.csx.cam.ac.uk>

Craig Berry <cberry@cinenet.net> wrote:
>Alberto Brosich (brosich@univ.trieste.it) wrote:
>
>: How can i compare two arrays other then with a loop?
>
>Short answer: You can't do it without looping.

Not strictly true.  (Or rather, you can get Perl to do the looping
for you.)    Using the techniques from the FAQ that Craig refers to
(untested code):

      @a_b{@a} = @b_a{@b} = ();
      delete @a_b{@b}, @b_a{@a};
      print "Same" unless keys %a_b + keys %b_a;


Mike Guy


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

Date: 13 Jul 1998 23:56:03 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: compare arrays
Message-Id: <6oe6qj$5ov$8@marina.cinenet.net>

M.J.T. Guy (mjtg@cus.cam.ac.uk) wrote:
: Craig Berry <cberry@cinenet.net> wrote:
: >Alberto Brosich (brosich@univ.trieste.it) wrote:
: >
: >: How can i compare two arrays other then with a loop?
: >
: >Short answer: You can't do it without looping.
: 
: Not strictly true.  (Or rather, you can get Perl to do the looping
: for you.)    Using the techniques from the FAQ that Craig refers to
: (untested code):
[snip]

Yes, I was speaking in the 'computational theory' mode, not the
'notational convenience' mode.  It *is* possible to sweep the looping
under the rug, in many cases.  But it's still going on, down there in the
darkness. 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 14 Jul 1998 00:14:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: First meeting of Dallas.pm
Message-Id: <6oe7tl$j68$7@client3.news.psi.net>

Randal Schwartz (merlyn@stonehenge.com) wrote on MDCCLXXVII September
MCMXCIII in <URL: news:8c3ec564dt.fsf@gadget.cscaper.com>:
++ >>>>> "Matthias" == Matthias Neeracher <neeri@iis.ee.ethz.ch> writes:
++ 
++ >> Yes, it's nice that all the new Perl Monger groups seem to be
++ >> following that fine old tradition established by the prototype PM
++ >> (NY.PM) of holding their meetings in a bar. :-)
++ 
++ Matthias> Hey, given your business investments, doesn't such a
++ Matthias> statement represent a conflict of interest? :-)
++ 
++ Only if we start LaGrande.pm.  And let me be the first to say, when I
++ visit LaGrande, the population of Perl Mongers goes from zero to one,
++ and when I leave, it's back to zero. :-)
++ 


I've tried many times to validate myself after registering on the
Perl Mongers webpage. Even after cutting & pasting the password
from the emails I get back, it keeps rejecting them as invalid.

Email about that remains unanswered.

Does anyone know if there is any competence around those Perl Mongers?



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Mon, 13 Jul 1998 20:54:25 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: First meeting of Dallas.pm
Message-Id: <1dc4hze.992d8n1m7o7u4N@bay2-93.quincy.ziplink.net>

Abigail <abigail@fnx.com> wrote:

> I've tried many times to validate myself after registering on the
> Perl Mongers webpage. Even after cutting & pasting the password
> from the emails I get back, it keeps rejecting them as invalid.

I just tried it, and it worked for me.  Are you sure you're entering the
same email address you used to register?

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 13 Jul 1998 18:30:55 -0500
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: forking on win32
Message-Id: <6oe5bf$jef@fohnix.metronet.com>

scott@softbase.com writes:
) 
) Absolutely not. Forking is *impossible* in Win32 because of
) differences in the process model. Think VMS when you think Win32.

I guess you never saw Eunice!  ;>

There are already versions of fork() [more accurately vfork()] that
run under Win32.  So far I don't think any of them cover the whole
of Win32, though.

There will probably never be one that allows multi-tasking via
just fork(), but that certainly isn't required for them to be
extremely useful for parts of the Perl community that are stuck
[by choice or not] on Win32 and perhaps useful to the original
poster [and non-Perl-users as well].

Scott probably already knew this and just chose a more literal
interpretation of "fork()" than I did.  I thought my interpretation
is probably more common among non-Unix-guru users of Perl under
Win32 and was worth mentioning.

[For those playing at home who never heard of Eunice, much less
saw it -- Eunice pretended to be Unix and ran undef VMS.  It
included fork(), um vfork(), that was implemented via longjmp(),
like most vfork()s, I would guess.]

We now return to the regularly scheduled newsgroup already in progress.
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Mon, 13 Jul 1998 23:23:05 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: HELP: Internet Database Design questions...
Message-Id: <35aa9523.19867848@nntp.idsonline.com>

Catherine Skidmore <eppie@interport.net> Said this:
>> >ooh. Access and ASP. or Access and Cold Fusion.
>> 
>> Oh my GOD.  No.
>
>care to defend that?

Sure.  If you plan on having an internet server, and you choose NT,
you are defeating yourself before you even start.   Sure, you'll be
able to get a room full of administrative and non-technical people to
make up some nice looking pages and hook your database into it, and
all kinds of things - but what will happen is that your NT server will
end up being down more often than it is up.  NT is unstable, it scales
horribly, it cannot handle medium traffic loads (even with a dual
pentium pro, which I've tried oh so hard to make work with NT)

What good is a "web server" that has all kinds of downtime?  If
someone tries to access your site when the server is down, they'll sit
there for a few seconds, get an "Unable to connect to remote host"
error message, find a search engine and locate one of your
competitors.  Simple fact.  

>> >an NT Box running IIS.
>> >
>> 
>> Argh.  New to computing?  Must be.
>
>wrong again.
>

Just because you've had a pc on your desk for a couple years does not
make you technically literate.  Using word, or netscape is not a
computer skill, it's being a computer user.  Being a computer user
does not qualify you to make suggestions about network environments.




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

Date: Mon, 13 Jul 1998 23:26:25 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: HELP: Internet Database Design questions...
Message-Id: <35aa96e7.20319984@nntp.idsonline.com>

2f3@my-dejanews.com Said this:

>John,
>
>I've got a different query:
>
>I'm having problems getting Perl to write to a plain text file (comma
>delimited database) and am not sure why. I think it may be the permissions,
>but they seem okay. Can you think of anything else I should check?
>

Is this happening through CGI?  If so, the permissions will need to be
a little different.  Your script will be running as "nobody" or
"httpd" or "www" or some other watered down user - you'll probably
need to add write to the group (chmod g+w filename)

Or, possibly the directory might be set incorrectly - try (but don't
keep it this way) chmod a+rwx directory_name   and see if it works.
Then start removing permissions from it until it stops working again,
because that is pretty promiscuous for a directory.




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

Date: 13 Jul 1998 22:59:44 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How can you encrypt a CGI script on a server so it will not get "stolen"?
Message-Id: <6oe3h0$388$3@comdyn.comdyn.com.au>

In article <35a69bca.92648931@nntp.idsonline.com>,
	root.noharvest.\@not_even\here.com (-) writes:
> John Layne <jpl@lanl.gov> Said this:

>>What would be the best way to protect my assets? I guess I could encrypt
>>the script on the server and have another password-protected script that
>>would decode it and then run it. Any ideas would be gratefully accepted.
>>I would imagine that this is an issue others have faced.
>>
> 
> I'm afraid there's really not much you can do here.  The only viable
> option is to go to the CPAN and install the perl compiler.  Then,
> compile the perl script and use the compiled binary and keep the
> "plain text" perl source to yourself.  However, I think your best bet
> is to simply operate with faith between you and your client.  

Ok, time for a pointer to the FAQ (Why hasn't anyone mentioned this yet?)

# perldoc perlfaq3
	How can I hide the source for my Perl program?

	Delete it. :-) Seriously, there are a number of (mostly
	unsatisfactory) solutions with varying levels of "security".
[snip]

/How can I compile my Perl program into byte code or C?


Compiling will NOT give you any 'protection'

This discussion has been here numerous times in the past. Please refer
to www.dejanews.com to find the threads.

> If you try to encrypt the script, and then write a script that
> decrypts it, anyone who wants to "steal" your source just needs to

Read the FAQ.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 
Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
NSW, Australia                      | 


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

Date: 13 Jul 1998 23:09:20 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How do chang groups
Message-Id: <6oe430$388$4@comdyn.comdyn.com.au>

In article <6odfs9$16d$1@supernews.com>,
	scotan@selinc.com (Scott Anderson) writes:
> I corrected a typo in my previous post. 
> The version of perl is 5.004.04 not 5.00.04.

5.004_04, I guess.

> Also, the problem doesn't seem to be NIS related (see below).

Then the question is no longer a perl question. You probably will have much more success if you take this to a group that talks about NIS, or maybe a Solaris group.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 75% of the people make up 3/4 of the
Commercial Dynamics Pty. Ltd.       | population.
NSW, Australia                      | 


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

Date: 14 Jul 1998 00:17:30 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl 4 compilation on Solaris 2.6
Message-Id: <6oe82q$j68$8@client3.news.psi.net>

Brad Skrbec (skrbec@cig.mot.com) wrote on MDCCLXXVII September MCMXCIII
in <URL: news:35AA4554.3C5DFB05@cig.mot.com>:
++ Hi all,
++ 
++ Due to many older scripts being written in Perl 4 here, we are looking
++ at building Perl 4 on Solaris 2.6 for backward compatibility.

That looks odd to me. The last version of perl4 predates Solaris 2.6 by
4 years or so. So, perl4 for Solaris 2.6 "for backwards compatibility"
doesn't seem an issue to me.

++ Unfortunately, Perl 4 is not overly compatible with the environment, and
++ there appear to be some problems  related to /usr/ucblib compatibility
++ libraries and the and dbm and flock calls.
++ 
++ Has anyone successfully compiled version 4.036 on Solaris 2.6?  If not,
++ can anyone clue me in on what Perl 4/Perl 5 incompatibility problems I
++ may run into?


I think it only works from /dev/drum



Abigail
-- 
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
          for (s;s;s;s;s;s;s;s;s;s;s;s)
              {s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'


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

Date: 13 Jul 1998 23:35:02 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6oe5j6$qbb$1@pegasus.csx.cam.ac.uk>

Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>[A complimentary Cc of this posting was sent to Tom Christiansen 
><tchrist@mox.perl.com>],
>who wrote in article <6ob8tc$76g$1@csnews.cs.colorado.edu>:
>> In comp.lang.perl.misc, ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
>> :Which proves nothing.  It is not Perl4, since it uses isn't_programmer
>> :without leading &, and is not Perl5 since it uses isn::t_programmer
>> :without ::.  Thus it is not Perl.
>> 
>> That's not the way things work.  Your logic is utterly wrong.
>
>You have been warned that you use bad programming practice:
>undocumented constructs.  If you choose to ignore this warning
>(calling names in between), it is your problem, not mine.

What undocumented constructs are you claiming Tom is using?
isn't_programmer is valid Perl5 and is documented to be the same as
isn::t_programmer.

Not a style I'd use myself (except in inherited Perl4 scripts), but
valid nonetheless.


Mike Guy


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

Date: 14 Jul 1998 00:34:34 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6oe92q$k9q$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to M.J.T. Guy
<mjtg@cus.cam.ac.uk>],
who wrote in article <6oe5j6$qbb$1@pegasus.csx.cam.ac.uk>:
> >You have been warned that you use bad programming practice:
> >undocumented constructs.  If you choose to ignore this warning
> >(calling names in between), it is your problem, not mine.
> 
> What undocumented constructs are you claiming Tom is using?
> isn't_programmer is valid Perl5 and is documented to be the same as
> isn::t_programmer.

It is documented indeed, but is documented as deprecated.  Thus not
Perl5.

> Not a style I'd use myself (except in inherited Perl4 scripts), but
> valid nonetheless.

*Still* valid.  This may change any moment, watch where you step ;-).
I would agree with Tom *if* he would conjecture that there is very low
probability that this particular feature goes earlier than 5.008.  But
he had chosen to call me names instead.

I support &pack'func() constructs in CPerl, since it is valid Perl4.
But not pack'func(), this would be too big an overhead.  (Hmm, on the
second though maybe not - it is a matter of searching for "'" instead
of searching for "&".  Now IF Emacs RE had lookbehind...  ;-)

Ilya


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

Date: 14 Jul 1998 00:25:28 GMT
From: sheareruk@aol.com (ShearerUK)
Subject: Perl Question
Message-Id: <1998071400252800.UAA08644@ladder03.news.aol.com>

I need help with something.

I am trying to include the statement
<!--#exec cgi="counter.cgi-->
on a dynamically produced html page

If I use the statement print "<!--#exec cgi="counter.cgi-->"\n;
where do I have to put the "\" to make it realize it is an ssi call and not a
comment?

Thanks

-Rob


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

Date: Tue, 14 Jul 1998 00:24:26 GMT
From: Frank_Zhu@my-dejanews.com
Subject: Re: PERL Tutorial
Message-Id: <6oe8fp$j75$1@nnrp1.dejanews.com>

Try http://www.perl.com, you will find what you want.

In article <35AA1BDA.B2A25E8B@dsccc.com>,
  JLEHMANN <JLEHMANN@dsccc.com> wrote:
> Are there any good PERL tutorials on the net?

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 13 Jul 1998 22:45:31 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl-HTML not interpreted
Message-Id: <6oe2mb$388$1@comdyn.comdyn.com.au>

In article <6odrgh$nem@masters0.internex.net>,
	"spamspamspamspam(Too much MP)" <spam@spam.com> writes:
> I've ran into something similar. Though rather new to PERL I was suprised to
> find out that when I was printing from inside sub MySub the calling form
> didn't receive the HTML I was trying to send. When I put it inside the main

The 'calling form' won't receive anything. All you can do in a CGI
program is read environment variables, read from STDIN, and print to
STDOUT. Of course, there are other things you _can_ do, but they have
nothing to do with CGI.

The 'calling form' is just a HTML page, most likely, but you don't
even know that. All you know is that the server started you up,
because it got a request for a URL that meant that it had to start you
up. All you know is that you either get stuff on STDIN (the POST
method) or you have to read certain environment variables (the GET
method) or maybe even both. In reaction, all you can do to communicate
is print to STDOUT.

> portion of code it did work. As such I just stuck in a variable and used an
> IF structure to return the HTML page(s).

This really has no bearing on the question. It just means that you
were doing something wrong. A CGI program written in perl is no
different from any other program written in perl. It just is subject
to the same limitations and caveats that any other CGI program is
subject to.

> Side note, this was written for an NT 4 box running IIS. Not my choise, but
> what I's stuck with.

Irrelevant.

It's nice of you to want to help, but you really should try reviewing
your own message, before posting, and see if it contributes anything.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd.       | clothes.
NSW, Australia                      | 


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

Date: Mon, 13 Jul 1998 16:44:29 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Quickie: the number of occurences of a character in a string
Message-Id: <MPG.10143bb4fbd3845198970a@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <wkoguth4dl.fsf@turangalila.harmonixmusic.com> on 13 Jul 1998 
16:39:50 -0400, Dan Schmidt <dfan@harmonixmusic.com> says...
 ...
> Benchmark: timing 500 iterations of Index, RegExp, RegExp2, Tr...
>      Index: 15 secs (14.67 usr  0.00 sys = 14.67 cpu)
>     RegExp: 27 secs (27.33 usr  0.00 sys = 27.33 cpu)
>    RegExp2: 21 secs (21.61 usr  0.00 sys = 21.61 cpu)
>         Tr:  2 secs ( 1.73 usr  0.00 sys =  1.73 cpu)
> 
> But that wasn't the original question anyway.  In the original
> question, the letter to search for wasn't determined until run-time.

And, as I posted earlier, that is easy to accomplish.  Here is my 
version of your benchmark (I don't have the wordlist):

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

my $a = 'abcdefg' x 100;
my $x = 'e';

timethese(1 << 12, {
	RegExp =>
    sub { my ($n,@temp); $n = scalar (@temp = $a =~ /$x/g) },
	RegExp2 => sub { my $n = () = $a =~ /$x/g },
	Index  => sub { my ($i,$n)=(0,0); $n++ while 
            ($i=index($a,$x,$i)+1) > 0 },
	Tr => sub { my $n = eval "$a =~ tr/$x//" },
});

Benchmark: timing 4096 iterations of Index, RegExp, RegExp2, Tr...
     Index: 23 secs ( 7.53 usr  0.07 sys =  7.60 cpu)
    RegExp: 28 secs ( 8.74 usr  0.07 sys =  8.81 cpu)
   RegExp2: 21 secs ( 6.63 usr  0.06 sys =  6.69 cpu)
        Tr: 12 secs ( 1.30 usr  0.05 sys =  1.35 cpu)

So the answer is, the fastest way to count the number of occurrences of a 
character in a string is to use tr///.  Just as it says in perlfaq4: "How 
can I count the number of occurrences of a substring within a string?"

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


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

Date: 14 Jul 1998 00:39:47 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Reading Directories w/ Perl
Message-Id: <slrn6qlaag.o0.gabor@guava.vmunix.com>

In comp.lang.perl.misc, marius77@my-dejanews.com <marius77@my-dejanews.com> wrote :
# I'm stumped on this and I'm sure there is a very easy solution so hopefully
# someone can help me out.  All I need to do is be able to look at a specific
# directory with my script and get all of the filenames within that directory. 
# It doesn't even need to recursively go through the whole directory tree.
# 
# I just want to be able to feed it a directory name and get the names of the
# files it contains...that's all.  Any help would be appreciated.  Thanks!!

You ought to have looked at the docs that come with Perl.  You would've
got an answer much faster.
try perldoc


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

Date: Mon, 13 Jul 1998 16:40:16 -0700
From: Allen Choy <achoy@us.oracle.com>
Subject: Readonly arrays
Message-Id: <35AA9AE0.8E90031F@us.oracle.com>

The perlmod page says that one can create scalar constants by doing
something like this:

*foo = \bar;

Is there an equivalent for arrays?

I've tried things like

*foo = \qw(a b c);

and

*foo = \('a', 'b', 'c');

but it doesn't work.

Thanks,

Allen




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

Date: Tue, 14 Jul 1998 00:55:09 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Readonly arrays
Message-Id: <35AAADC4.85D19663@shaw.wave.ca>

Allen Choy wrote:
> 
> The perlmod page says that one can create scalar constants by doing
> something like this:
> 
> *foo = \bar;
>

The right side is a scalar here, so $foo = 'bar'.  It is read only
because you can't write something like 
    'bar' = 'baz';
 
> Is there an equivalent for arrays?
> 
> I've tried things like
> 
> *foo = \qw(a b c);
> 
> and
> 
> *foo = \('a', 'b', 'c');
> 
> but it doesn't work.
> 

Here the right side is a list, not an array.  You cannot take a
reference to a list.  Both of the above are equivalent to

   *foo = (\a, \b, \c);# $foo = 'c'

Putting an array on the right hand side won't help because then you
won't have a constant,

   *foo = \@arry;#  @foo = @arry

since you can always write something like
   @arry = (1, 2, 3);

Sorry, you're out of luck.

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Mon, 13 Jul 1998 23:05:15 GMT
From: Peter A Fein <p-fein@uchicago.edu>
Subject: Re: Recommend me Perl!
Message-Id: <opg7m1huzbo.fsf@harper.uchicago.edu>

c960901@student.dtu.dk writes:

> I've never written a line of Perl, but I'm going to in the very near future.
> I need someone to recommend me -the best- Perl book available. What can Perl
> do? I've seen only little Perl code. Can it scan a directory for subdirs and
> files and return the names in a string array? Cause that's what I really
> need.

As it sounds like you've programmed before, let me suggest
_Programming Perl_.  Although I haven't used _Learning Perl_, I found
_Programming_, plus my experience in a few other languages to be more
than sufficient.

-- 
Peter A Fein                                           Summering in SF!
Home: 650-571-6476                                   Work: 650-628-2172
p-fein@uchicago.edu                             pfein@us.checkpoint.com


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

Date: Mon, 13 Jul 1998 20:40:26 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Recommend me Perl!
Message-Id: <1dc4gyy.6e7ihqwexs3kN@bay2-93.quincy.ziplink.net>

Tom Christiansen <tchrist@mox.perl.com> wrote:

> _Programming Perl_ (Wall, Christiansen, and Schwartz)

You forgot to mention Stephen Potter.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 14 Jul 1998 00:41:52 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Recommend me Perl!
Message-Id: <slrn6qlaed.o0.gabor@guava.vmunix.com>

In comp.lang.perl.misc, c960901@student.dtu.dk <c960901@student.dtu.dk> wrote :
# Hello there.
# 
# I've never written a line of Perl, but I'm going to in the very near future.
# I need someone to recommend me -the best- Perl book available. What can Perl
# do? I've seen only little Perl code. Can it scan a directory for subdirs and
# files and return the names in a string array? Cause that's what I really
# need.

Programming Perl by the master himself, Larry Wall.  Also, Christiansen
and Schwartz.


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

Date: Mon, 13 Jul 1998 13:08:30 +0100
From: Simon Wistow <smw3@doc.ic.ac.uk>
Subject: talking to POP3 servers
Message-Id: <Pine.LNX.3.96.980713130006.3918A-100000@pinga.doc.ic.ac.uk>


I apologise in adavnce if this causes mass groaning in the news group
but I only started learning Perl last weekend on a 6am ferry from
Ostende to Dover :/

I am writing a POP3toWeb script (I know there are loads out there
already but I'm doing it as a learning experience) and so far it will
connect, logon and receive single line messages from the server however
it all falls over when I try and  get multiline responses (in my case
the reply to the "TOP x 0" command).

My code looks something like this


<connect and login>
print S "TOP $message_no 0";   $a=<S>;
while (<S>){
	print $a;
	$a = <S>;}

I've tried 'while ($a=<S>){' and a few other thinsg but I only ever
seem to be able to get either the first line or it will just loop
continuously. Please help ...




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

Date: 13 Jul 1998 23:16:14 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: use Sys::Syslog tricks
Message-Id: <6oe4fu$388$5@comdyn.comdyn.com.au>

In article <iul2z8bg.fsf@ispnews.com>,
	Phil Crown <pcrown@ispnews.com> writes:
> What's required to get use Sys::Syslog working (Linux, FreeBSD,
> Solaris)?

Solaris example:

Entry in /etc/syslog.conf:

local7.notice                                   mgjv

program:

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

use Sys::Syslog;

openlog('test', 'pid', 'local7');
syslog('notice', 'just a test');
__END__

result:

Jul 14 09:15:03 timber test[22162]: just a test

Have you added an entry in the syslog.conf that you can use?

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.       | you come to the end; then stop.
NSW, Australia                      | 


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

Date: 13 Jul 1998 23:06:04 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Using Perl to generate HTML Pages.
Message-Id: <6oe3ss$5ov$6@marina.cinenet.net>

Andy Bold (bytealite@yahoo.com) wrote:
: > What I would like to know is how to call a perl function which produces
: > plain text output which can be imbedded into a HTML page!
: 
: If your hosting on a Unix box, take a look at the Apache WWW server with
: mod_perl and Perl::Embed.

Wow, it must be good, to be worth recommending four times in a row...

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Mon, 13 Jul 1998 12:57:19 -0500
From: Ketan Patel <kbp1527@ihgp.lucent.com>
Subject: Using Perl with DCOM
Message-Id: <35AA4A7F.E1C37D2@ihgp.lucent.com>

I am trying to use Perl on Win32 platform to communicate with a COM object.  One
of the methods of the COM object passes parameter by reference and it returns
result in this parameter.  How do I handle this in Perl?  I know how hard and
relative references work in Perl.  However, I am unable to get the result passed
by the COM method as one of the parameters.  Has anyone else faced this problem?
If so, can someone point me to a book or an article which discusses this. I know
that there is Perl Resource Kit for Win32 is coming out soon.  But, I can't wait
for it.

Thanks,
Ketan


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

Date: Mon, 13 Jul 1998 20:40:28 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: What's the substitute for #! /usr/bin/perl in Win32 Perl?
Message-Id: <1dc4hcd.eyhwup1nretlfN@bay2-93.quincy.ziplink.net>

<scott@softbase.com> wrote:

> > I'm using the ActiveState Win32 Perl on an NT 4.0 system... what do I
> > use in place of the first line (#! /usr/bin/perl) in Unix versions of
> > the script ?
> 
> You don't. NT doesn't support this "magic number" style of
> execution. 

Keep in mind that perl itself will still honor any command line switches
on the #! line.  At the very least, you could just do

#!perl -w -i.bak

or whatever.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 14 Jul 1998 00:08:00 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Why is Dave operating here? (was Re: REPOST: Re: )
Message-Id: <6oe7h0$j68$6@client3.news.psi.net>

John Stanley (stanley@skyking.OCE.ORST.EDU) wrote on MDCCLXXVII September
MCMXCIII in <URL: news:6odbe5$7hv$1@news.NERO.NET>:
++ In article <6ocbqa$31g$1@client3.news.psi.net>,
++ Abigail <abigail@fnx.com> wrote:
++ >++ When was the charter for this newsgroup changed to invite Dave? I don't
++ >++ recall any discussion asking for Dave's "help", and do not appreciate
++ >++ losing the ability to cancel my own articles.
++ >
++ >Since when do we invite people? 
++ 
++ Oh, Abigail. Do I read your question at face value and think you don't
++ know what Dave is, or is your question disengenuous? Do you really not
++ know that Dave is a program and not a person?
++ 
++ >And what makes you think you lose the
++ >ability to cancel your own articles?
++ 
++ Do you really not know how Dave works?
++ 
++ >To me, it looks like Dave is resurrecting rogue cancels. Unless you have
++ >the conception that all articles are yours and you should have the ability
++ >to cancel them all, I don't there's anything Dave is preventing you to do.
++ 
++ Except that when Dave controls a group, you don't get to cancel your own
++ articles, either. 
++ 

Except that I've cancelled one of my own postings in the period those
HipCrime postings were resurrected.

Guess what?

It didn't get resurrected.



Abigail
-- 
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-


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

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


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


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

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