[23550] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5758 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 6 09:05:47 2003

Date: Thu, 6 Nov 2003 06:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 6 Nov 2003     Volume: 10 Number: 5758

Today's topics:
    Re: "pack" perldoc error? (Anno Siegel)
        Bug in 5.8.0? . op is very slow <matthias_weckman@hotmail.com>
    Re: Bug in 5.8.0? . op is very slow (Anno Siegel)
    Re: Bug in 5.8.0? . op is very slow <kalinaubears@iinet.net.au>
    Re: Bug in 5.8.0? . op is very slow <simon.andrews@bbsrc.ac.uk>
    Re: Bug in 5.8.0? . op is very slow <kalinaubears@iinet.net.au>
    Re: Converting a list join to a scaler/string (Sam Holden)
    Re: Converting a list join to a scaler/string (Malcolm Dew-Jones)
        embedding perl within perl.... (suraj)
    Re: embedding perl within perl.... <bart.lateur@pandora.be>
    Re: embedding perl within perl.... (suraj)
    Re: equivalent perl for sed command ..newbie question (Anno Siegel)
        Execute JavaScript from within Perl (bruno)
    Re: I think what I need is a backreference but it doesn <pinyaj@rpi.edu>
    Re: I think what I need is a backreference but it doesn (Sara)
    Re: I think what I need is a backreference but it doesn (Sara)
    Re: Insert file date created into a variable <grazz@pobox.com>
    Re: math operations (Anno Siegel)
    Re: MIME::Lite on ActivePerl <bart.lateur@pandora.be>
    Re: Need Some Error Help <michael.korte@materna.de>
    Re: Need Some Error Help <usenet@morrow.me.uk>
    Re: Need Some Error Help (Anno Siegel)
    Re: Please ignore (this is a test) <jurgenex@hotmail.com>
    Re: Pls point me in the right direction - hide e-mail a (Malcolm Dew-Jones)
        Speech recognition! <someone@somewhere.com>
    Re: Speech recognition! (Anno Siegel)
        Subnet / Subnet Mask ---> IP calculation (kielhd)
    Re: Subnet / Subnet Mask ---> IP calculation (Anno Siegel)
    Re: Subnet / Subnet Mask ---> IP calculation <nobull@mail.com>
    Re: what is @$? <bart.lateur@pandora.be>
    Re: what language is this? <tore@aursand.no>
    Re: what language is this? (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 6 Nov 2003 10:06:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: "pack" perldoc error?
Message-Id: <bod6f1$n78$1@mamenchi.zrz.TU-Berlin.DE>

J. Romano <jl_post@hotmail.com> wrote in comp.lang.perl.misc:

[...]

>       $packedString = pack("a10",$text);
>       $text2 = unpack("A10",$packedString);
> 
> I packed the text with "a" because I wanted to pad the remaining
> spaces with null characters, and I unpacked the same string with "A"
> because, according to the documentation, "A" strips trailing spaces
> and nulls.
> 
>    So as long as the $text variable doesn't have any trailing spaces
> (and assuming it's not longer than 10 characters), $text2 should
> always be the same as $text, right?
> 
>    Well, no, it's not.  Apparently, if $text ends with any number of
> newlines (like "Hello!\n\n\n\n"), the newlines will get stripped off

 ...and also tabs, and other white-space characters.  Apparently, "space"
is used in the sense of "any white-space character" here.  That could
be made clearer, but isn't unheard-of.

>    Another thing I found that was not correct was in the perldoc for
> "pack".  It explicitly says:  'When packing, "a", and "Z" are
> equivalent.'  However, I found  (at least on Linux and
> Win32-ActiveState) that "Z" will always null-terminate a string, even
> if it means an extra character of the string gets cut off.

Yes, the equivalence seems to be restricted to the case where both
formats are long enough to allow at least one trailing zero.  If it
isn't, "Z" forces a null byte, but "a" doesn't.  This certainly
deserves explicit mention, though it *is* described elsewhere in the
doc.

Anno


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

Date: Thu, 06 Nov 2003 13:06:55 +0100
From: Matthias Weckman <matthias_weckman@hotmail.com>
Subject: Bug in 5.8.0? . op is very slow
Message-Id: <3faa395e$0$137$e4fe514c@dreader6.news.xs4all.nl>

Hi all,

I hope you may be able to shed some light on this.
I'm using ActiveState Perl 5.8.0 (build 806) on Windows 2000, and 
noticed that slurping a file was very slow compared to the old 5.6.1.

I narrowed it down to the . operator taking a lot of time, see the 
script below.

I tried searching the web for some info on this, but couldn't find 
anything on Google, bugs.perl.org or activestate.com.

Is this an issue with ActiveState's build only? Or is it a 5.8.0 issue 
in general? Do you know if it has been fixed in 5.8.1?
Is there a way to improve this?

Unfortunately I do not have access to other versions of perl on other 
platforms, so I can't compare.

Thanks,
Matthias

---8<---

use strict;
use warnings;
use Benchmark qw(timeit timestr);

my $c = 10;
my $t = timeit ($c, q!
		my $x = '';
		my $y = 'x' x 10000;
		my $z = 0;
		while($z < 7000000)
		{
			 $z+=10000;
			 $x .= $y;
		}
	!
);
print "$c loops of concat took:",timestr($t),"\n";

__END__
Results for ActiveState Perl 5.8.0 build 806 On Win2K SP4:
10 loops of concat took:34 wallclock secs (19.13 usr + 13.54 sys = 32.67 
CPU) @  0.31/s (n=10)

Results for ActiveState Perl 5.6.1 build 635 On Win2K SP4:
10 loops of concat took: 1 wallclock secs ( 0.39 usr +  0.03 sys =  0.42 
CPU) @ 23.81/s (n=10)




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

Date: 6 Nov 2003 12:44:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Bug in 5.8.0? . op is very slow
Message-Id: <bodfmv$bd$1@mamenchi.zrz.TU-Berlin.DE>

Matthias Weckman  <matthias_weckman@hotmail.com> wrote in comp.lang.perl.misc:

[concatenation is slow]

> use strict;
> use warnings;
> use Benchmark qw(timeit timestr);
> 
> my $c = 10;
> my $t = timeit ($c, q!
> 		my $x = '';
> 		my $y = 'x' x 10000;
> 		my $z = 0;
> 		while($z < 7000000)
> 		{
> 			 $z+=10000;
> 			 $x .= $y;
> 		}
> 	!
> );
> print "$c loops of concat took:",timestr($t),"\n";
> 
> __END__
> Results for ActiveState Perl 5.8.0 build 806 On Win2K SP4:
> 10 loops of concat took:34 wallclock secs (19.13 usr + 13.54 sys = 32.67 
> CPU) @  0.31/s (n=10)
> 
> Results for ActiveState Perl 5.6.1 build 635 On Win2K SP4:
> 10 loops of concat took: 1 wallclock secs ( 0.39 usr +  0.03 sys =  0.42 
> CPU) @ 23.81/s (n=10)

Well, that's a ridiculous time difference.  I don't see anything similar
on a linux box -- 5.6.1 and 5.8.0 run your benchmarks in similar time
for me.

Anno


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

Date: Thu, 06 Nov 2003 23:43:59 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Bug in 5.8.0? . op is very slow
Message-Id: <3faa42ce$0$1755$5a62ac22@freenews.iinet.net.au>

Matthias Weckman wrote:

> 
> ---8<---
> 
> use strict;
> use warnings;
> use Benchmark qw(timeit timestr);
> 
> my $c = 10;
> my $t = timeit ($c, q!
           my $x = '0' x 7000000;
           $x = '';
>         my $y = 'x' x 10000;
>         my $z = 0;
>         while($z < 7000000)
>         {
>              $z+=10000;
>              $x .= $y;
>         }
>     !
> );
> print "$c loops of concat took:",timestr($t),"\n";
> 
> __END__
> Results for ActiveState Perl 5.8.0 build 806 On Win2K SP4:
> 10 loops of concat took:34 wallclock secs (19.13 usr + 13.54 sys = 32.67 
> CPU) @  0.31/s (n=10)
> 
> Results for ActiveState Perl 5.6.1 build 635 On Win2K SP4:
> 10 loops of concat took: 1 wallclock secs ( 0.39 usr +  0.03 sys =  0.42 
> CPU) @ 23.81/s (n=10)
> 

Dunno what the exact problem is but I'm finding the same with AS perl on 
2k SP3.

5.6.1 takes around 0.8 seconds
5.8.0 around 23 seconds

With the alterations (above) to your script, I find it runs about 10 
times faster on 5.8.0, but 2.5 times slower on 5.6.1.

ie:
5.6.1 takes around 1.9 seconds
5.8.0 around the same (1.9 seconds).

Looks like it has something to do with the way memory is being allocated 
- more to do with the fact that $x needs more and more memory, rather 
than the '.' operator per se.

Cheers,
Rob


-- 
To reply by email u have to take out the u in kalinaubears.



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

Date: Thu, 06 Nov 2003 12:56:54 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Bug in 5.8.0? . op is very slow
Message-Id: <bodgen$bvj$1@south.jnrs.ja.net>

Matthias Weckman wrote:
> Hi all,
> 
> I hope you may be able to shed some light on this.
> I'm using ActiveState Perl 5.8.0 (build 806) on Windows 2000, and 
> noticed that slurping a file was very slow compared to the old 5.6.1.
> 
> I narrowed it down to the . operator taking a lot of time, see the 
> script below.
>
> use strict;
> use warnings;
> use Benchmark qw(timeit timestr);
> 
> my $c = 10;
> my $t = timeit ($c, q!
>         my $x = '';
>         my $y = 'x' x 10000;
>         my $z = 0;
>         while($z < 7000000)
>         {
>              $z+=10000;
>              $x .= $y;
>         }
>     !
> );
> print "$c loops of concat took:",timestr($t),"\n";
> 
> __END__
> Results for ActiveState Perl 5.8.0 build 806 On Win2K SP4:
> 10 loops of concat took:34 wallclock secs (19.13 usr + 13.54 sys = 32.67 
> CPU) @  0.31/s (n=10)
> 
> Results for ActiveState Perl 5.6.1 build 635 On Win2K SP4:
> 10 loops of concat took: 1 wallclock secs ( 0.39 usr +  0.03 sys =  0.42 
> CPU) @ 23.81/s (n=10)


I can confirm this on my Win32 boxes.

5.8.0 (AS Build 806) 23 wallclock secs
5.6.1 (AS Build 635)  1 wallclock sec

 ..but not under Linux

5.8.0 (Linux) 0 wallclock secs
5.6.1 (Linux) 0 wallclock secs

 ...so it looks like an AS thing.  I don't have any other 5.8 AS builds 
to try out though so it may be just a 635 problem.

Simon.



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

Date: Fri, 07 Nov 2003 00:05:44 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Bug in 5.8.0? . op is very slow
Message-Id: <3faa47e7$0$1743$5a62ac22@freenews.iinet.net.au>

Simon Andrews wrote:

> 
> ...so it looks like an AS thing.  I don't have any other 5.8 AS builds 
> to try out though so it may be just a 635 problem.
> 

I was using builds 626 and 802 - so it looks like the anomaly has been 
there for a while - and possibly still is :-)



Cheers,
Rob


-- 
To reply by email u have to take out the u in kalinaubears.



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

Date: 6 Nov 2003 05:05:24 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Converting a list join to a scaler/string
Message-Id: <slrnbqjlkk.79p.sholden@flexal.cs.usyd.edu.au>

On Thu, 06 Nov 2003 04:23:29 GMT, sdfgsd <footnipple@indiatimes.com> wrote:
> 
> The end goal is to build an SQL INSERT:
> 
> my @fields = qw(Name Address City State Zip Phone);
> my @quoted = map {"'$_', "} @fields;
> my $insert = join ' ', @quoted;
> 
> The problem is that I need $insert to be an actual string so that I can
> concatenate it with a set of parenthesis and the rest of the INSERT. I then
> need to push these INSERTS into a file for later use.
> 
> The expected output if I were to print $insert:   ('name', 'address', ...)

And that's what you'll get (well you want get the parenthesis and you'll
have a trailing comma - which can be fixed by moving the comma to the
join.

Tack: 
print "$insert\n"; 
after those four lines of code and you'll get:

'Name',  'Address',  'City',  'State',  'Zip',  'Phone',

I can't see how that is not an "actual string".

As I said in my first reply:

What result do you want?

What result did you get?

-- 
Sam Holden


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

Date: 5 Nov 2003 22:23:37 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Converting a list join to a scaler/string
Message-Id: <3fa9e8e9@news.victoria.tc.ca>

Sam Holden (sholden@flexal.cs.usyd.edu.au) wrote:
: On Thu, 06 Nov 2003 03:40:27 GMT, sdfgsd <sdfg@sdg.com> wrote:

: Is that your real email address?

: Do you have permission from the Strategic Decisions Group to
: use that address.

$ dig sdg.com any
 ...
;; ANSWERS:
sdg.com.        172800  NS      ns22.customer.level3.net.


-> level3

I would also recommend you don't use the sdg address - but for quite
different reasons.



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

Date: 6 Nov 2003 07:09:32 GMT
From: bhide@yahoo.com (suraj)
Subject: embedding perl within perl....
Message-Id: <bocs3c$nuk$1@coset.qualcomm.com>

Hello,

i have a strange situation. i am writing a perl extension on win32 with perl 
5.6 from activestate.

however, this might be a general situation somebody might get into and hence 
hoping some perl gurus might be able to answer me.

1. i have written a XS extention in C++ which provides some functionality. i 
wrote a small test perl script and everything works fine.

2. however, now i have to enhance the functionality in the C++ layer of this 
extension so that it does some code execution/expression parsing at runtime. i 
wanted to use the perl engine to do this since perl is so flexible and 
powerful.

3. so i tried to embed perl in the way described in the perl embed man pages 
and so now i have a perl extension embedding perl inturn. it compiled ok but 
now crashes at random places when i hit that code. 

does anybody know if this is possible at all? is there any help about this in 
any manpages. i tried couple of them but most of them talk about using perl in 
a C/C++ executable. but my situation is not this straight forward. i have perl 
using a C++ extension which tries to embed perl in turn.

thanks for any help,
suraj bhide.



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

Date: Thu, 06 Nov 2003 07:43:18 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: embedding perl within perl....
Message-Id: <8oujqvkgpmssjda9mldbf407svbjjmcph0@4ax.com>

suraj wrote:

>1. i have written a XS extention in C++ which provides some functionality. i 
>wrote a small test perl script and everything works fine.
>
>2. however, now i have to enhance the functionality in the C++ layer of this 
>extension so that it does some code execution/expression parsing at runtime. i 
>wanted to use the perl engine to do this since perl is so flexible and 
>powerful.
>
>3. so i tried to embed perl in the way described in the perl embed man pages 
>and so now i have a perl extension embedding perl inturn. it compiled ok but 
>now crashes at random places when i hit that code. 

How about using callbacks in perl, to call the primary perl interpreter,
instead of embedding another one? A bit like how HTML::Parser, and
XML::Parser::Expat work. These modules provide ways to invoke user
supplied subs, but you needn't go that far, and just call subs defined
in your own module.

-- 
	Bart.


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

Date: 6 Nov 2003 07:53:26 GMT
From: bhide@yahoo.com (suraj)
Subject: Re: embedding perl within perl....
Message-Id: <boculm$pcs$1@coset.qualcomm.com>

>
>How about using callbacks in perl, to call the primary perl interpreter,
>instead of embedding another one? A bit like how HTML::Parser, and
>XML::Parser::Expat work. These modules provide ways to invoke user
>supplied subs, but you needn't go that far, and just call subs defined
>in your own module.
>
>-- 
>        Bart.

how do i do this? can this be done from C++? what are the function calls to be 
used to get hold of the primary perl interpreter?

thanks,
suraj



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

Date: 6 Nov 2003 09:28:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: equivalent perl for sed command ..newbie question
Message-Id: <bod47i$la1$1@mamenchi.zrz.TU-Berlin.DE>

Ben Morrow  <usenet@morrow.me.uk> wrote in comp.lang.perl.misc:
> 
> arena318@yahoo.com (walter) wrote:
> > Now I know
> > 
> >     perl -p -e 's/exp1/exp2/g' file
> > 
> > is equivalent to
> > 
> >     sed -e 's/exp1/exp2/g' file
> 
> Except that Perl's regexes are better :)
> 
> > But I can't realize what's the perl equivalent to
> > 
> >     sed -e '/exp1/,/exp2/d' file
> 
> perl -ne'print unless /exp1/.../exp2/'
> 
> See perldoc perlop for .. and ..., and the differences between them.

Alternatively, use the program s2p, which comes with the Perl distribution.
It translates sed scripts to Perl scripts.  In this case it comes up with
a whole lot of code for what can apparently be done in a single line, but
it does so automatically.

Anno


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

Date: 6 Nov 2003 04:09:30 -0800
From: bskorepa@yahoo.com (bruno)
Subject: Execute JavaScript from within Perl
Message-Id: <f542e1ac.0311060409.1305b8ad@posting.google.com>

How do I execute Javascript from within perl?

What I want to do:
I have a perl script that downloads webpages and analyzes them.
One of these pages just sends a lot of raw data. A long javascript
program generates the page using document.write. I would like to read
this page.

My system: win2000, activeperl 5.8
I have downloaded javascript.pm.
I have downloaded js-1.5-rc5.tar.gz and compiled it with VC 6.0, which
resulted in 2 files: js32.dll, jsshell.exe.

Where do I have to copy the dll-file to use it with perl?
What else do I have to do?
Anybody doing this on a windows-system?


thanx, Bruno.


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

Date: Thu, 6 Nov 2003 00:55:54 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Sara <genericax@hotmail.com>
Subject: Re: I think what I need is a backreference but it doesn't ever match
Message-Id: <Pine.SGI.3.96.1031106004020.55498A-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On 5 Nov 2003, Sara wrote:

>For example, I have
>
>CAT1 
>DOG2
>MOUSE
>EEL
>CAT1 is ALFIE
>DOG2 is FRED
>
>Say the result I want is
>
>CAT1 is ALFIE
>DOG2 is FRED
>MOUSE
>EEL
>
>I tried something like:
>
> s/^(\w+\d)(.+)\n\1 is ([^\n]+)\n/$1 is $3$2/gsm;

It will match, but it won't match ALL the cases you want.  The reason is
because the regex will have matched PAST "DOG2" after it's finished
substituting "CAT1".  One solution is to use look-aheads, which allow you
to match things in a string without actually consuming them in the string.

In case you don't know what I meant, let me give another example:

  $s = "abc def ghi abc ghi";
  $s =~ s/(\S+)(.*?)\1/$1($2)/g;

This turns $s into "abc(def ghi) ghi".  It doesn't do anything with the
ghi...ghi pair, because the regex reads "abc def ghi abc", so the next
time the regex tries matching, there are no matches starting at any point
in the string past the remaining " ghi".

Here's one way to do it with look-aheads in ONE regex:

  s{
    ^ (\w+\d)
    (?:
      (?= \n (?: .* \n )* \1 \x20 is \x20 (.+) )
      |
      \x20 is \x20 .+ \n
    )
  }{ $2 ? "$1 is $2" : "" }egmsx;

There's a bit of work in there.  Basically, the regex matches one of two
things.  If it matches "FOO1 is BLAH\n", it replaces that with nothing.
Otherwise, if it matches "FOO1" and sees that a newline, followed by some
lines, followed by "FOO1 is BLAH", it CAPTURES the "BLAH", and replaces
the original "FOO1" with "FOO1 is BLAH".

The /e is needed because the replacement is code to be executed, and the
/x is there to allow me to write the regex with abundant whitespace.
(That's why ACTUAL spaces have been replaced with \x20.)

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: 6 Nov 2003 05:10:48 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: I think what I need is a backreference but it doesn't ever match
Message-Id: <776e0325.0311060510.ef31eb3@posting.google.com>

tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnbqj3f5.234.tadmc@magna.augustmail.com>...
> Sara <genericax@hotmail.com> wrote:
> 
> > I tried something like:
> > 
> >  s/^(\w+\d)(.+)\n\1 is ([^\n]+)\n/$1 is $3$2/gsm;
> > 
> > which runs with no errors, yet never matches anything.
>                                  ^^^^^^^^^^^^^
> 
> Yes it does.
> 
> Why didn't you post a short and complete program that we can run
> that illustrates your problem?
> 
> Something like:
> 
> -----------------------
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> $_ = 'CAT1
> DOG2
> MOUSE
> EEL
> CAT1 is ALFIE
> DOG2 is FRED
> ';
> print "before: $_";
> 
> print "-----\n";
> 
> s/^(\w+\d)(.+)\n\1 is ([^\n]+)\n/$1 is $3$2/gsm;
> print "after : $_";
> -----------------------
> 
> Since it outputs a changed $_, the s/// *did* match.
> 
> So we aren't seeing what you are seeing, which makes it much
> harder to fix what you are seeing...
> 
> 
>    1 while s/^(\w+\d)(.+\n)\1 is ([^\n]+)\n/$1 is $3$2/sm;

Yes I misstated that- it does do ONE match. I didn't post a short
program to illustrate this sorry- this is actually a very tiny part of
a HUGE program, and the actual program operates on an infinitely more
complicated set of data. I can't possibly send you what I'm seeing.
SOrry the others gave me some useful pointers however- no problems
mate!

G


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

Date: 6 Nov 2003 05:12:43 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: I think what I need is a backreference but it doesn't ever match
Message-Id: <776e0325.0311060512.61d78822@posting.google.com>

Jeff 'japhy' Pinyan <pinyaj@rpi.edu> wrote in message news:<Pine.SGI.3.96.1031106004020.55498A-100000@vcmr-64.server.rpi.edu>...
> [posted & mailed]
> 
> On 5 Nov 2003, Sara wrote:
> 
> >For example, I have
> >
> >CAT1 
> >DOG2
> >MOUSE
> >EEL
> >CAT1 is ALFIE
> >DOG2 is FRED
> >
> >Say the result I want is
> >
> >CAT1 is ALFIE
> >DOG2 is FRED
> >MOUSE
> >EEL
> >
> >I tried something like:
> >
> > s/^(\w+\d)(.+)\n\1 is ([^\n]+)\n/$1 is $3$2/gsm;
> 
> It will match, but it won't match ALL the cases you want.  The reason is
> because the regex will have matched PAST "DOG2" after it's finished
> substituting "CAT1".  One solution is to use look-aheads, which allow you
> to match things in a string without actually consuming them in the string.
> 
> In case you don't know what I meant, let me give another example:
> 
>   $s = "abc def ghi abc ghi";
>   $s =~ s/(\S+)(.*?)\1/$1($2)/g;
> 
> This turns $s into "abc(def ghi) ghi".  It doesn't do anything with the
> ghi...ghi pair, because the regex reads "abc def ghi abc", so the next
> time the regex tries matching, there are no matches starting at any point
> in the string past the remaining " ghi".
> 
> Here's one way to do it with look-aheads in ONE regex:
> 
>   s{
>     ^ (\w+\d)
>     (?:
>       (?= \n (?: .* \n )* \1 \x20 is \x20 (.+) )
>       |
>       \x20 is \x20 .+ \n
>     )
>   }{ $2 ? "$1 is $2" : "" }egmsx;
> 
> There's a bit of work in there.  Basically, the regex matches one of two
> things.  If it matches "FOO1 is BLAH\n", it replaces that with nothing.
> Otherwise, if it matches "FOO1" and sees that a newline, followed by some
> lines, followed by "FOO1 is BLAH", it CAPTURES the "BLAH", and replaces
> the original "FOO1" with "FOO1 is BLAH".
> 
> The /e is needed because the replacement is code to be executed, and the
> /x is there to allow me to write the regex with abundant whitespace.
> (That's why ACTUAL spaces have been replaced with \x20.)


Whoa lookaheads and backrefs in one regex! Thanks so much for this
tip- and you're correct I'm not familair with them. I'm studying yuor
example which indeed looks pertinant.

Thanks,
G


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

Date: Thu, 06 Nov 2003 05:15:22 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Insert file date created into a variable
Message-Id: <KNkqb.2106$88.1752@nwrdny03.gnilink.net>

Ben Morrow <usenet@morrow.me.uk> wrote:
> Tore Aursand <tore@aursand.no> wrote:
>> Remember, however, that you cannot expect ctime to be the creation
>> time of the file;
> 
> I think you probably can on Win32?

Right -- some different flavors of ctime are listed in "perlport".

    mtime and atime are the same thing, and ctime is creation time
    instead of inode change time. (Mac OS).

    ctime not supported on UFS (Mac OS X).

    ctime is creation time instead of inode change time  (Win32).

    [...]

    mtime, atime and ctime all return the last modification time.
    Device and inode are not necessarily reliable.  (RISC OS)

-- 
Steve


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

Date: 6 Nov 2003 10:34:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: math operations
Message-Id: <bod83t$o8a$1@mamenchi.zrz.TU-Berlin.DE>

Fred  <news@group.com> wrote in comp.lang.perl.misc:
> Hello
> I need to do some calculations using math operator like
> element of
> overlap
> summation
> and others in this link 
> http://whatis.techtarget.com/definition/0,,sid9_gci803019,00.html

That site describes about 120 standard (and less-than-standard) mathe-
matical symbols.

As a side note, they demonstrate the summation symbol using a divergent
infinite series (sum( 1/n, n = 1 .. infinity)).  This isn't outright
wrong, but it doesn't bode well for the mathematical awareness of the
authors.

> does perl support those operations? is there an add on module or use 
> another language?

Do you really expect someone to go through them all and check what Perl
supports and what it doesn't?

Perl is a general-purpose computing language, it supports the usual
arithmetic operations and transcendental functions.  Specific modules
(to be found on CPAN) will support other mathematical operations.

If you need general support for mathematical operations, go for a
language designed for that purpose, like Mathematica or Maple.  But
those cost money...

Anno


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

Date: Thu, 06 Nov 2003 07:39:04 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: MIME::Lite on ActivePerl
Message-Id: <4vtjqv4cfqi2dtcp3l2kaagavnv0e5173m@4ax.com>

Ben Morrow wrote:

>You don't, unless you want to send MIME email.
>
>You do need something to send mail, probably Net::SMTP.

MIME::Lite is a lot easier to set up to send mail, than Net::SMTP is,
even for messages that don't use MIME. The advantage of it is that it
can use several ways to send mail, and hides the dirty details.

To the OP: yes, MIME::Lite can be used on Windows. In particular in the
newest update, several features to make your life easier on Windows,
have been added.

-- 
	Bart.


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

Date: Thu, 6 Nov 2003 08:00:38 +0100
From: "Michael Korte" <michael.korte@materna.de>
Subject: Re: Need Some Error Help
Message-Id: <bocrin$sb8$1@pentheus.materna.de>


"Gary Hartl" <the-smtpguy@cogeco.ca> schrieb im Newsbeitrag My error is as
follows:

>>[Wed Nov  5 08:41:59 2003] mach10.pl: Can't call >>method "fields"
>>without a package or object reference >>at /usr/lib/perl5/5.8.0/SkyIm
>>port.pm line 1548, <INFILE> line 7.

>>Line 1548 is:
>>foreach $field ($cloneUser->fields()){
>>                               $newUser->set_attribute($field,
>>$cloneUser->get_attribute($field));
>>                        }

It seems like you did not initialize the object $cloneUser.
just make a "print $cloneUser;" somwhere and have a look. In case it is an
Object, it might look like :
PACKAGENAME:HASH=0x1234f

somtimes I had this problem when I get object from an array. I solved this
by checking every value if it really is an Object.
eg :
if($object=~/PACKAGENAME=/){
    # do something
}

HTH

Michael




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

Date: Thu, 6 Nov 2003 08:06:38 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Need Some Error Help
Message-Id: <bocvee$f6m$1@wisteria.csv.warwick.ac.uk>


"Michael Korte" <michael.korte@materna.de> wrote:
> somtimes I had this problem when I get object from an array. I solved this
> by checking every value if it really is an Object.
> eg :
> if($object=~/PACKAGENAME=/){

Euurgh! 

if(ref($object) eq 'PACKAGENAME')
 
or, better,

if($object->isa("PACKAGENAME"))

Ben

-- 
  Joy and Woe are woven fine,
  A Clothing for the Soul divine       William Blake
  Under every grief and pine          'Auguries of Innocence'
  Runs a joy with silken twine.                                ben@morrow.me.uk


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

Date: 6 Nov 2003 11:23:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Need Some Error Help
Message-Id: <bodave$o8a$3@mamenchi.zrz.TU-Berlin.DE>

Ben Morrow  <usenet@morrow.me.uk> wrote in comp.lang.perl.misc:
> 
> "Michael Korte" <michael.korte@materna.de> wrote:
> > somtimes I had this problem when I get object from an array. I solved this
> > by checking every value if it really is an Object.
                                  ^^^^^^^^^^^^^^^^^^^
> > eg :
> > if($object=~/PACKAGENAME=/){
> 
> Euurgh! 

Agreed.

> if(ref($object) eq 'PACKAGENAME')

Yes.

> or, better,
> 
> if($object->isa("PACKAGENAME"))

That "better" needs qualification.  If the question is whether
$object is an object at all, as implied above, ->isa will issue a
fatal run-time error if it isn't.  Not good.

If we know that $object is blessed into *something*, ->isa is indeed
the way to see whether it is directly or indirectly of the right type.
But that wasn't the question here.

Anno


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

Date: Thu, 06 Nov 2003 05:32:01 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Please ignore (this is a test)
Message-Id: <l1lqb.1911$p9.1244@nwrddc02.gnilink.net>

Default@User.net wrote:
> Testing please ignore this message.

Your wish is my command:  *PLONK*

jue




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

Date: 5 Nov 2003 22:00:06 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Pls point me in the right direction - hide e-mail address
Message-Id: <3fa9e366@news.victoria.tc.ca>

Doesn't Matter (pissoffspammers@aol.com) wrote:
: Greetings
: I am not looking for a spambot killer or an obfuscator, what I need
: is something that will achieve the following.  Could someone pls point
: me at a suitable script.
: I run a site which, in part, allows a runaway child or their parents to
: communicate with each other by messages,  I would like them to be
: able to do this by e-mail however, neither side, and particularily the
: child side should have their e-mail address divulged.
: What I need is basically a simple form with a text box and a 'Send Message'
: button that, in the background in fact sends an e-mail without anyone being
: able to see where the e-mail is actually going to, neither in the status bar
: or by viewing the source.
: Is this possible in Perl or am I better to have all the e-mails directed to
: us and
: we re-send them on.  Surely something like this though can be automated.
: Similiar, I guess, to how it is done on the 'dating' websites.
: Any pointers gratefully received.

Various sites run anonymous mail services.  I do not know what "packaged"
code they use, but I would investigate those sites (like maybe ask someone
who runs one) to find what you can.



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

Date: Thu, 6 Nov 2003 11:43:38 -0000
From: "Bigus" <someone@somewhere.com>
Subject: Speech recognition!
Message-Id: <bodc5b$kmm@newton.cc.rl.ac.uk>

Perhaps partly OT here, but does anyone know of good (and pref. free) speech
recognition software, that can output a text string that could be read and
acted upon by a Perl script? For that matter, can Perl be made TSR so that
it sits and "listens" for input, such as text from a speech recog software?

Bigus




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

Date: 6 Nov 2003 11:56:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Speech recognition!
Message-Id: <bodcss$o8a$4@mamenchi.zrz.TU-Berlin.DE>

Bigus <someone@somewhere.com> wrote in comp.lang.perl.misc:
> Perhaps partly OT here, but does anyone know of good (and pref. free) speech
> recognition software, that can output a text string that could be read and
> acted upon by a Perl script?

Search the CPAN for "speech".  There are a few hits.

>                              For that matter, can Perl be made TSR so that
> it sits and "listens" for input, such as text from a speech recog software?

TSR (terminate and stay resident) appears to be a DOS technique to hold
programs in memory.  Perl is a programming language, TSR doesn't apply.

If the question is whether a Perl program can be made TSR, I don't know.
You can certainly keep a Perl program running in the background, waiting
for input from some other program.  See "perldoc perlipc" for that.

Anno


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

Date: 6 Nov 2003 02:06:20 -0800
From: kielhd@freenet.de (kielhd)
Subject: Subnet / Subnet Mask ---> IP calculation
Message-Id: <10a4173d.0311060206.6ca708c8@posting.google.com>

Hi NG,

I'm looking for a small script which would return all possible IPs
within a given Subnet and corresponding Subnet Mask.
ie:	input: Subnet 10.152.186.0, Subnet Mask 255.255.255.192
	output: 10.152.186.0, 10.152.186.1, 10.152.186.2 ... 10.152.186.63

Thanks!
Henning


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

Date: 6 Nov 2003 10:14:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Subnet / Subnet Mask ---> IP calculation
Message-Id: <bod6ua$n78$2@mamenchi.zrz.TU-Berlin.DE>

kielhd <kielhd@freenet.de> wrote in comp.lang.perl.misc:
> Hi NG,
> 
> I'm looking for a small script which would return all possible IPs
> within a given Subnet and corresponding Subnet Mask.
> ie:	input: Subnet 10.152.186.0, Subnet Mask 255.255.255.192
> 	output: 10.152.186.0, 10.152.186.1, 10.152.186.2 ... 10.152.186.63

What have you tried so far?

We help people with their Perl programs, but we don't do contract work.
Find a newsgroup with "jobs" in the title for that.

Anno


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

Date: 06 Nov 2003 12:05:58 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Subnet / Subnet Mask ---> IP calculation
Message-Id: <u9wuadln15.fsf@wcl-l.bham.ac.uk>

kielhd@freenet.de (kielhd) writes:

> I'm looking

When you say "I'm looking" can you explain what form this looking has
taken?  Perhaps we could then advise you on how to look more
effectively.

There's a module to do exactly what you describe in the usual place
(see FAQ).

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


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

Date: Thu, 06 Nov 2003 07:24:26 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: what is @$?
Message-Id: <rgtjqvcfmmurb28vqd9qhuv7sj8q2deds2@4ax.com>

Abigail wrote:

>I've never understood why it says 'require Exporter'. Why delay 
>compiling Exporter to run-time? I don't see what's wrong with:
>
>    use Exporter ();

There's nothing wrong with use, though the parens are a bit easy to
forget. I don't think calling Exporter's import, if you forget them,
will do your module any good, as it's the same method that actually does
the importing for your module.

And "run time" is a bit of an exageration. As Importer is virtually
always invoked from within a module, it is at runtime for the module,
which is still the time your module is use()d. That is still at compile
time for the main script.

-- 
	Bart.


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

Date: Thu, 06 Nov 2003 11:05:30 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: what language is this?
Message-Id: <pan.2003.11.06.00.37.00.219470@aursand.no>

On Wed, 05 Nov 2003 23:36:51 +0000, Abigail wrote:
>>> in this language it is
>>> |xOr(a,b)|
>>>

>> Fred, you've given virtually no data.  What you've described could
>> cover literally hundreds (hell, thousands) of languages, *including*
>> Perl if the program in question defined an "xOr" subroutine.

> Well, it might be possible to define an 'xOr' subrouting in Perl, it's
> not possible to define your own operators.

Well.  They could be constants? :-)


-- 
Tore Aursand <tore@aursand.no>


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

Date: 6 Nov 2003 11:10:22 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: what language is this?
Message-Id: <boda6u$o8a$2@mamenchi.zrz.TU-Berlin.DE>

Tore Aursand  <tore@aursand.no> wrote in comp.lang.perl.misc:
> On Wed, 05 Nov 2003 23:36:51 +0000, Abigail wrote:
> >>> in this language it is
> >>> |xOr(a,b)|
> >>>
> 
> >> Fred, you've given virtually no data.  What you've described could
> >> cover literally hundreds (hell, thousands) of languages, *including*
> >> Perl if the program in question defined an "xOr" subroutine.
> 
> > Well, it might be possible to define an 'xOr' subrouting in Perl, it's
> > not possible to define your own operators.
> 
> Well.  They could be constants? :-)

I'm not sure why you say this.  A constant is a subroutine and its name
must be a valid Perl identifier.  You know that, don't you?

Anno


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 5758
***************************************


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