[13819] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1229 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 30 06:05:23 1999

Date: Sat, 30 Oct 1999 03:05:08 -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: <941277908-v9-i1229@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 30 Oct 1999     Volume: 9 Number: 1229

Today's topics:
    Re: "MS VB-like" perl editor? (Jan Dubois)
        Array reference processing (Harry Walker)
    Re: CDONTS and Perl? (Jan Dubois)
        counter vod@writemail.com
    Re: Drop the last item from the Environment string (CGI <wyzelli@yahoo.com>
    Re: FAQ 3.9: Is there an IDE or Windows Perl Editor? <gellyfish@gellyfish.com>
    Re: How do you strip spaces? (Abigail)
    Re: How the heck does this regex match? (Abigail)
    Re: How to use Perlscript from Visual Basic for Applica (Jan Dubois)
    Re: It is always like this here? <gellyfish@gellyfish.com>
    Re: simple regex question <skilchen@swissonline.ch>
    Re: simplifying a script <gellyfish@gellyfish.com>
    Re: simplifying a script (Abigail)
    Re: simplifying a script <vandenbNOSPAM@cistron.nl>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 30 Oct 1999 11:09:57 +0200
From: jand@activestate.com (Jan Dubois)
Subject: Re: "MS VB-like" perl editor?
Message-Id: <381eaae4.4307513@news3.ibm.net>

[mailed & posted]

Andreas Falley <afalley@emusic.com> wrote:

>Hi I'm wondering if anybody out there knows of any editor that does
>things like keeps an index
>of subroutines or methods such that you can just click on one and go to
>that part of the
>code. That was one thing I always liked about the Visual Basic
>environment...uh ...back
>when I did that sorta thing and dreamt of working for a company with a
>clue....uh before you
>start to hiss.

You can use Emacs with cperl-mode and imenu to get what you want.  It
doesn't really looks like a VB-Editor environment, but is much more
powerful. :-)

-Jan



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

Date: Sat, 30 Oct 1999 08:50:23 GMT
From: hw@netcomuk.co.uk (Harry Walker)
Subject: Array reference processing
Message-Id: <3819ea54.258480@nntp.netcomuk.co.uk>

I create an array reference of the form
$arrayref=\@array;

I then want to pass the array reference to a subroutine and let the
subroutine process each item in the array using a foreach loop. Is
this possible since I cannot get this to work.

Thanks for any help.

--
Harry Walker



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

Date: Sat, 30 Oct 1999 11:09:59 +0200
From: jand@activestate.com (Jan Dubois)
Subject: Re: CDONTS and Perl?
Message-Id: <3820ae21.5136025@news3.ibm.net>

[mailed & posted]

pinkelma@my-deja.com wrote:

>Is there anyway to send mail using CDONTS in a perl script (on NT
>Server with IIS 4.0), if so how.

Yes, it is possible.

You'll find sample code in the archives of the Perl-Win32-Users mailing
list.

-Jan



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

Date: Sat, 30 Oct 1999 08:27:29 GMT
From: vod@writemail.com
Subject: counter
Message-Id: <7vea5h$78i$1@nnrp1.deja.com>




i tried running counter with the
  #exec cgi=.. tag to
but the server ppl were not allowing me
now
i used
 #exec cmd=.., it got the fuking counter working.
but for some time only
there seems to be a hitch there too
can any one help me



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


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

Date: Sat, 30 Oct 1999 18:10:44 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Drop the last item from the Environment string (CGI)
Message-Id: <XayS3.1$cZ2.403@vic.nntp.telstra.net>

Larry Rosler <lr@hpl.hp.com> wrote in message
news:MPG.128428eb8673d98898a163@nntp.hpl.hp.com...
> In article <Q4vS3.17$MV2.2174@vic.nntp.telstra.net> on Sat, 30 Oct 1999
> 14:40:08 +0930, Wyzelli <wyzelli@yahoo.com> says...
>
>   ($names, $submits) = $names =~ /(.+)&(.+)/;
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com

OK.. I can see THAT this works, (and very well thank you Larry) but after a
couple of hours playing around with it I still can't see quite why something
so simple does just what it does.  Moreover I can't seem to get it to do
much else other than just that.

If I can attempt to put what I think it is doing into words...

Match 1 or more instances of anything, an &, and 1 or more anything.  The
first 'one or more anything' goes to $1, and the second to $2.

Why is it that it only effectively matches the last & in the string?  Even
when inside a while loop like so..

$_ = 'Mary=girl&Bob=boy&Fred=boy&Sam=girl&submits=1';
while (/(.+)&(.+)/g){
 push (@names, $1);
 push (@test, $2);
}

print "@names\n";
print "@test";
_____________________________

results in:

Mary=girl&Bob=boy&Fred=boy&Sam=girl
submits=1

Actually I may just  be suffering from a little information overload and not
able to see the forest for the trees. :-)

Still on the quest!

Wyzelli




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

Date: 29 Oct 1999 20:34:59 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: FAQ 3.9: Is there an IDE or Windows Perl Editor?
Message-Id: <7vd0dj$3ea$1@gellyfish.btinternet.com>

On Fri, 29 Oct 1999 09:17:49 -0700 Tim Westlake wrote:
> You can try ZEUS (www.zeusedit.com). Its a great little editor and
> comes with language files for PERL, Java, C, C++ etc. etc. and you can
> even create your own.
> 

No I dont think that we will - <http://www/perl.com/reference/query.cgi?editors>

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 30 Oct 1999 04:01:15 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How do you strip spaces?
Message-Id: <slrn81lctq.66b.abigail@alexandra.delanet.com>

Uri Guttman (uri@sysarch.com) wrote on MMCCLI September MCMXCIII in
<URL:news:x7emedcs5u.fsf@home.sysarch.com>:
?? >>>>> "A" == Abigail  <abigail@delanet.com> writes:
?? 
??   A> Uri Guttman (uri@sysarch.com) wrote on MMCCL September MCMXCIII in
??   A> <URL:news:x7ogdhdds3.fsf@home.sysarch.com>:
??   A> // >>>>> "A" == Abigail  <abigail@delanet.com> writes:
??   A> // 
??   A> //   A>     s/ (.*)/;
??   A> //   A>     local $_ = $1;
??   A> //   A>     y; ;;d;
??   A> //   A>     $_;
??   A> //   A>     /xs;
??   A> //           ^^
??   A> // 
??   A> // shouldn't the modifier be sex?
?? 
?? 
??   A> No. But it should be 'es'.
?? 
?? i knew the e was missing. but i can see why x is not needed though you
?? made it look like it would be. the regex itself has no extra chars while
?? the replacement is multiple lines of code. 


Please try it out with, and without the /x. You'll notice a difference.



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


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 30 Oct 1999 04:40:51 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How the heck does this regex match?
Message-Id: <slrn81lf82.66b.abigail@alexandra.delanet.com>

Larry Rosler (lr@hpl.hp.com) wrote on MMCCLI September MCMXCIII in
<URL:news:MPG.12842dc436caf69c98a164@nntp.hpl.hp.com>:
|| In article <slrn81kbn6.pp.joarmc@linux2.johnmckown.net> on Fri, 29 Oct 
|| 1999 23:33:59 +0000, John McKown <joarmc@linux2.johnmckown.net> says...
|| 
|| ...
|| 
|| > In a regular expression, the [] enclose a list of characters. The regular
|| > expression is matched if the string matches any ONE of the characters
|| > enclosed within the []. If you need to match a literal set of [], then
|| > you must "escape" both the [ and ] with a \ (backslash).
|| 
|| Not the ']'.  The only time that ']' must be escaped is to include it as 
|| a member of a character class, as any other than the first character in 
|| the class.  Escaping it elsewhere doesn't hurt, but 'must "escape"' is 
|| too strong.
|| 
|| >                        However, due
|| > to weird syntax, you must also escape the backlash in the assignment.
|| 
|| Not 'weird syntax' -- the wrong choice for quotes.
|| 
|| > So you most likely what something like:
|| > 
|| > $a="\\[ sdt_shel \\]"
|| 
||   $a = '\[ sdt_shel ]';


Of course, if you don't have meta chars inside the regex, why use a
regex?

    if (0 <= index $a => $b) { ... }


Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Sat, 30 Oct 1999 11:09:55 +0200
From: jand@activestate.com (Jan Dubois)
Subject: Re: How to use Perlscript from Visual Basic for Applications with Script Control
Message-Id: <381da867.3670758@news3.ibm.net>

[mailed & posted]

Tim Richardson <ter@my-deja.com> wrote:

> Here is an example of using Perl in Visual Basic for Applications.
>
>You need to get the Microsoft Script Control (free) from
>http://msdn.microsoft.com/scripting
>and of course the ActiveState Win32 Perl distribution, and don't change
>the default installation of PerlScript.
>
>I'm putting this here because I couldn't find any examples of this
>useful technique anywhere. This example works in Access.

Other techniques of calling Perl from VB would be:

- PerlEz
- Microsoft Scriptlets/Script Components
- PerlCOM/PerlCtrl from the Perl Development Kit

I've presented samples for some of these in my talk at this years Perl
conference.  You can find a comprehensive paper of the talk here:

    http://opensource.activestate.com/authors/jandubois/Perl/TPC3/fun.html

and the PowerPoint slides here:

    http://opensource.activestate.com/authors/jandubois/Perl/TPC3/cool.ppt

-Jan


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

Date: 29 Oct 1999 20:25:12 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: It is always like this here?
Message-Id: <7vcvr8$3e7$1@gellyfish.btinternet.com>

On 29 Oct 1999 17:50:44 GMT William wrote:
> Mark Bluemel <mark.bluemelNOmaSPAM@siemens.co.uk.invalid> wrote in article
> <000b8d9b.40a12527@usw-ex0101-001.remarq.com>...
>> I've been teaching myself Perl for a few weeks, with moderate success,
>> so I thought I'd join the newsgroup. After just one day, I'm more than
>> half inclined to drop out again. Large amount of traffic, huge
>> noise-to-signal ratio, cluelessness in abundance and a fair proportion
>> of abuse - these all add up to somewhere that I'm not feeling like
>> hanging round in.
>> 
>> Is it always like this, or have I picked a bad time?
> 
> Seems to be the worst in purely language-related newsgroups.
> I've found that, while the cluelessness is just as high,
> the newbie-toasting is less pronounced in newsgroups
> devoted to creating applications. Don't know why,

Lets swing this pointless thread around a little.

So you dont think that people make applications in Perl ?

You've missed the point - there is no *newbie* toasting here:
the feckless, the idiotic, the illiterate they get flamed ,,, but no-one
gets flamed simply for being new to the newsgroup,  you might question
who decides these criteria, but then ....

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 30 Oct 1999 07:22:21 GMT
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: simple regex question
Message-Id: <N0xS3.27694$m4.99410293@news.magma.ca>

Philip A. Viton <pviton@magnus.acs.ohio-state.edu> wrote in message
news:pviton.484.00134AA4@magnus.acs.ohio-state.edu...
>
> If I do
>
>   s|c:\\|d:\\|;
        ^    ^
        |    |
        |  here you 'escape' the special meaning
        |  of \ in a string litteral
        |
     here you 'escape' the special meaning
     of \ in a regexp

> within a script, I can change c:\  to d:\ .  I'd like to generalize
> this, so I can pass the two strings to a script in the command line.
> But if I pass, eg
>
>   myroutine.pl myfile.txt c:\\  d:\\
>
> and do
>
>    s|$ARGV[1]|$ARGV[2]|;
>
Here $ARGV[2] is no longer a string litteral, so the \ doesn't need to
be escaped. Therefore call it as:
   myroutine.pl myfile.txt c:\\  d:\

You could also try:
   s|\Q$ARGV[1]\E|$ARGV[2]|;
and then call it as
   myroutine.pl myfile.txt c:\ d:\




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

Date: 29 Oct 1999 20:42:56 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: simplifying a script
Message-Id: <7vd0sg$3ee$1@gellyfish.btinternet.com>

<dont cross-post to alt.perl>

In comp.lang.perl.misc Walter van den Berg <wvandenbergNOSPAM@ttpdiskad.nl> wrote:
> 
> Greg Bacon writes:
>> :
>> : >     my @table;
>> : >
>> : >     foreach my $file (@table_data) {
>> : >         local $/;
>> : >         open TD, $file or die "$0: open $file: $!";
>> : >         push @table, { file => $file, data => <TD> };
>> : >         close TD;
>> : >     }
>> :
>> : Hm, Greg? It doesn't work with me...
>>
>> Oh, crud.  Change the push line to
>>
>>     push @table, { file => $file, data => [ <TD> ] };
> 
> 
> 
> Er... Greg? It's better now, but it's not complete. It only puts one table
> in my file, but it should put in four. Sorry...
> 

Then why doesnt it ?


> 
>>
>> Exercise for the reader: if possible, process the table files one at
>> a time instead of slurping each of them; otherwise, prove that it's
>> impossible.
>>
> 
> In a month or so I'll be ready for that. I begun two days ago...
> 

Sit down read the documentation, chuck that dumb book out and learn.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 30 Oct 1999 03:58:31 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: simplifying a script
Message-Id: <slrn81lcok.66b.abigail@alexandra.delanet.com>

Jeff Pinyan (jeffp@crusoe.net) wrote on MMCCLI September MCMXCIII in
<URL:news:Pine.GSO.4.10.9910292105570.2694-100000@crusoe.crusoe.net>:
:: On Oct 29, Abigail blah blah blah:
:: 
:: >        my @table_data = map {"bobbhtml/TableData${_}.txt"} 1 .. 11;
:: 
:: This might be a bit nit-picky, but I bring up two points:
:: 
::   1.  useless { and } around _ in $_
::   2.  map in block format is slower than map in list format (here)

Well, I'd consider that a fault in Perl.... ;-)

:: Explained with the following benchmark:
:: 
::   use Benchmark qw( timethese );
::   timethese(100_000, {
::     'block' => q{
::       my @table_data = map {"bobbhtml/TableData${_}.txt"} 1 .. 11;
::     },
::     'block2' => q{
::       my @table_data = map {"bobbhtml/TableData$_.txt"} 1 .. 11;
::     },
::     'list' => q{
::       my @table_data = map "bobbhtml/TableData${_}.txt", 1 .. 11;
::     },
::     'list2' => q{
::       my @table_data = map "bobbhtml/TableData$_.txt", 1 .. 11;
::     },
::   });
:: 
:: 
::   Benchmark: timing 100000 iterations of block, block2, list, list2...
::        block: 38 wallclock secs (39.31 usr +  0.00 sys = 39.31 CPU)
::       block2: 37 wallclock secs (38.07 usr +  0.00 sys = 38.07 CPU)
::         list: 38 wallclock secs (38.52 usr +  0.00 sys = 38.52 CPU)
::        list2: 41 wallclock secs (37.97 usr +  0.00 sys = 37.97 CPU)
:: 
:: Again, this might be nitpicking it *just a little*.  But then again, I'm
:: an adolescent bastard.


You mean "bobbhtml/TableData${_}.txt" and "bobbhtml/TableData$_.txt"
are not compiled into the same optree, as often is claimed?

Or are you just measuring some noise?

Let's try it out....

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

    use strict;

    use Benchmark qw (timethese);

    sub doit ($);

    doit (25);

    my %results;
    while (<>) {
        /^\s*(\w+).* ([\d.]+)\s+cpu/ or next;
        push @{$results {$1}} => $2;
    }

    foreach my $key (sort keys %results) {
        my @arr  = sort {$a <=> $b} @{$results {$key}};
        my $avg  = do {local $" = "+";
                       eval ("@{$results{$key}}") / @{$results{$key}};};
        my $dev  = do {local $" = "+";
                       sqrt (eval ("@{[map {$_ * $_} @{$results{$key}}]}") /
                                    @{$results{$key}} - $avg * $avg)};
        printf "%6s ranges from %.2f to %.2f; average %.3f; o- = %.3f\n",
                $key, $arr [0], $arr [$#arr], $avg, $dev;
    }

    sub doit ($) {
        my $times = shift;

        my $pid = open STDOUT, "|-";
        return unless $pid;
        die "Fork failed: $!\n" unless defined $pid;

        foreach (1 .. $times) {
            timethese (100_000, {
              block => q {
                  my @table_data = map {"bobbhtml/TableData${_}.txt"} 1 .. 11;
              },
              block2 => q {
                  my @table_data = map {"bobbhtml/TableData$_.txt"} 1 .. 11;
              },
              list => q {
                  my @table_data = map "bobbhtml/TableData${_}.txt", 1 .. 11;
              },
              list2 => q {
                  my @table_data = map "bobbhtml/TableData$_.txt", 1 .. 11;
              },
            });
        }

        close STDOUT;

        exit;
    }

    __END__

 block ranges from 7.77 to 7.98; average 7.849; o- = 0.053
block2 ranges from 7.74 to 8.03; average 7.846; o- = 0.077
  list ranges from 7.60 to 7.82; average 7.695; o- = 0.055
 list2 ranges from 7.63 to 7.88; average 7.720; o- = 0.069


These figures don't really show that "${_}" is slower than "$_".



Abigail
-- 
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Sat, 30 Oct 1999 11:39:02 +0200
From: "Walter van den Berg" <vandenbNOSPAM@cistron.nl>
Subject: Re: simplifying a script
Message-Id: <7vee2u$h9d$1@voyager.cistron.net>

>
> And please, don't go by "Perl for Dummies", unless someone
> is holding your family hostage or something.  It doesn't
> explain as well as an intro book should, and it seems to
> want to make you afraid to program.  Try this web tutorial
> instead:
>     http://www.netcat.co.uk/rob/perl/win32perltut.html
>
> David
> --
> David Cassell, OAO                     cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician

Thanks for the advice, but I really need something like a dummie-book just
for introduction, to get through the tough stuff later on, just so I know a
little of what the "good" books are talking about. Really makes it easier
for me. What can i say - I'm a dummie.

(tutorial bookmarked and saved, thanks!)

Walter.




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

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


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