[29784] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1027 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 12 21:09:45 2007

Date: Mon, 12 Nov 2007 18:09: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           Mon, 12 Nov 2007     Volume: 11 Number: 1027

Today's topics:
    Re: Distributed RVS, Darcs, tech love (Marc Espie)
        How to play audio clips from Perl on OS X? <socyl@987jk.com.invalid>
    Re: Index of first and last non-"\xff" in a long string <krahnj@telus.net>
    Re: Index of first and last non-"\xff" in a long string <ben@morrow.me.uk>
    Re: Index of first and last non-"\xff" in a long string  w.c.humann@arcor.de
    Re: Index of first and last non-"\xff" in a long string  w.c.humann@arcor.de
    Re: Index of first and last non-"\xff" in a long string <ben@morrow.me.uk>
    Re: oddness in quotes (PerlMagick) <bik.mido@tiscalinet.it>
    Re: Remove slow debug prints with "ifdef" type of pre p <astewart1@cox.net>
    Re: Remove slow debug prints with "ifdef" type of pre p <tadmc@seesig.invalid>
    Re: sleep/fork/shell/SIGCHLD interaction problem <emschwar@pobox.com>
    Re: syntax question in dealing with .Net api <ben@morrow.me.uk>
    Re: syntax question in dealing with .Net api  trillich@gmail.com
    Re: syntax question in dealing with .Net api  trillich@gmail.com
    Re: To extract numbers from files with Perl <bik.mido@tiscalinet.it>
        Why /(word){0}/ does not work?  chacallot@gmail.com
    Re: Why /(word){0}/ does not work? <jurgenex@hotmail.com>
    Re: Why /(word){0}/ does not work? <No_4@dsl.pipex.com>
    Re: Why /(word){0}/ does not work? (Randal L. Schwartz)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 13 Nov 2007 00:36:15 +0000 (UTC)
From: espie@lain.home (Marc Espie)
Subject: Re: Distributed RVS, Darcs, tech love
Message-Id: <fharhv$2q7d$1@biggoron.nerim.net>

In article <1192998506.251127.172530@v29g2000prd.googlegroups.com>,
llothar  <llothar@web.de> wrote:
>On 21 Okt., 22:45, Lew <l...@lewscanon.com> wrote:
>
>> Evidence is that TeX development is dead.
>
>Exactly and Knuths only contribution to software development was the
>theory of
>"literate" programming. As i said for me algorithms are not software
>development,
>this is programming in the small (something left for coding apes), not
>programming
>in the large. There are no problems anymore with programming the
>small, sure you
>can try to develop Judy Arrays or another more optimized sorting
>algorithm, but
>this has no real world effect. It is theoretical computer science -
>well a few
>people seem to like this.

Boy, you really have to get a clue.

Apart from the fact that Knuth wrote a book series that is still THE
definitive series on computer algorithms (and that most people who need
these algorithms know those books... they document a fairly large set of
interesting facts about floating point arithmetic, and the designers of
cpu would do well to read them and not cut to many corners for IEEE754.
They also a document a large set of useful algorithms, some of them
fairly commonplace as soon as you need some efficiency), no, he hasn't
done anything smart.

No real world effect ? Ah! have a look inside your computer at some point.
You'll be surprised where you find those algorithms (your kernel is likely
to use some of them, for instance). And perl is probably better for 
Knuth's study of hash algorithms...

As far as TeX being `dead' goes, it's just finished, from Knuth's point of
view. It doesn't prevent TeX-based distributions from thriving (TeXlive
being the latest fad), and TeX-derived projects from going forward...


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

Date: Tue, 13 Nov 2007 00:14:08 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: How to play audio clips from Perl on OS X?
Message-Id: <fhaq8g$s65$1@reader1.panix.com>





I have a collection of very short audio clips (mostly numbers and
names of people) that I would like to be able to play entirely from
within a Perl script running on OS X; i.e. without invoking, e.g.
iTunes.  I would like to be able to play selections of multiple
clips from this collection in a seamless sequence, without any
pause at all in between them.

Any clues on how to do this would be much appreciated.

TIA!

kj

PS: The clips are currently in mp3 form, but I'd be happy to convert
(or even re-record) them if a different format would make this task
easier.

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


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

Date: Mon, 12 Nov 2007 19:57:10 GMT
From: "John W. Krahn" <krahnj@telus.net>
Subject: Re: Index of first and last non-"\xff" in a long string
Message-Id: <4738AFFE.FDC8EFF6@telus.net>

w.c.humann@arcor.de wrote:
> 
> I'm going through several PGM images, overlaying (i.e. ANDing) them
> and would also like to determine the bounding box. For that I need to
> find the first and last non-white (i.e. non-"\xff") pixel in every
> line. Now I have one line in a string $data (one pixel per character),
> possibly several 1000 charcters long. I tried 3 alternatives so far.
> All 3 work, but there may be even faster ways to do this:
> 
> # slow
> my $first = -1;
> 1 while substr($data, ++$first, 1) eq "\xff" and $first < $width - 1;
> my $last = $width;
> 1 while substr($data, --$last, 1) eq "\xff" and $last > $first;
> print STDERR "f: $first, l: $last, ";
> 
> # the match for $first2 is fast, but the one for $last2 is really slow
> my $first2 = length( ($data =~ /^(\xff+)/)[0] );
> my $last2 = $width - 1 - length( ($data =~ /(\xff+)$/)[0] );
> print STDERR "f2: $first2, l2: $last2, ";
> 
> # best solution so far. "tr" is the slowest part of this.
> # Is there a way without the "tr"?
> $data =~ tr|\x00-\xfe|\x00|;
> my $first3 = index  $data, "\x00";
> my $last3  = ($first3 > -1) ? rindex $data, "\x00" : -1;
> print STDERR "f3: $first3, l3: $last3, ";
> 
> print STDERR "\n";

Try this in your testing:

$data =~ /[^\xff].*[^\xff]/s and my ( $first, $last ) = ( $-[ 0 ], $+[ 0
] - 1 );



John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 12 Nov 2007 19:56:50 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Index of first and last non-"\xff" in a long string
Message-Id: <2pnm05-qi3.ln1@osiris.mauzo.dyndns.org>


Quoth w.c.humann@arcor.de:
> I'm going through several PGM images, overlaying (i.e. ANDing) them
> and would also like to determine the bounding box. For that I need to
> find the first and last non-white (i.e. non-"\xff") pixel in every
> line. Now I have one line in a string $data (one pixel per character),
> possibly several 1000 charcters long. I tried 3 alternatives so far.
> All 3 work, but there may be even faster ways to do this:

On my machine, the benchmark below gives

            Rate   subst   sloop    chop   match reverse   index       C
subst      403/s      --    -90%    -94%    -96%    -97%    -97%   -100%
sloop     4078/s    912%      --    -36%    -58%    -73%    -73%    -96%
chop      6340/s   1474%     55%      --    -35%    -58%    -59%    -94%
match     9754/s   2322%    139%     54%      --    -36%    -37%    -91%
reverse  15247/s   3686%    274%    140%     56%      --     -1%    -85%
index    15376/s   3718%    277%    143%     58%      1%      --    -85%
C       104065/s  25739%   2452%   1541%    967%    583%    577%      --

so index is probably the best you're going to get without using C.

Ben

#!/usr/bin/perl

use Benchmark qw/cmpthese/;

my $str = ("\xff" x 160) . ("f" x 10_000) . ("\xff" x 150);
my $len = length $str;

use Inline C => <<'EOC';

IV
unindex(SV *sv, const char *str)
{
    const char *pv;
    IV          len, i = 0;
    const char  chr = str[0];

    pv = SvPV(sv, len);
    while (pv[i] == chr) i++;

    return i;
}

IV
unrindex(SV *sv, const char *str)
{
    const char *pv;
    IV          len, i;
    const char  chr = str[0];

    pv = SvPV(sv, len);
    i = len - 1;
    while (pv[i] == chr) i--;

    return i;
}

EOC

cmpthese -3, {
    match => sub {
        local $_ = $str;
        # this is the fastest single match I can come up with
        /^((?>\xff*)).*[^\xff]((?>\xff*))$/;
        161 == 1 + $+[1] or die "\$+ failed: " . (1 + $+[1]);
        10_160 == $-[2] or die "\$- failed: " . $-[2];
    },
    index => sub {
        local $_ = $str;
        tr,\x00-\xfe,\x00,;
        161 == 1 + index $_, "\x00"
            or die "index failed: " . 1 + index $_, "\x00";
        10_160 == 1 + rindex $_, "\x00"
            or die "rindex failed: " . 1 + rindex $_, "\x00";
    },
    subst => sub {
        local $_ = $str;
        /[^\xff]/g;
        161 == pos or die "pos failed: " . pos;
        s/\xff+$//;
        10_160 == length or die "subst failed: " . length;
    },
    sloop => sub {
        local $_ = $str;
        /[^\xff]/g;
        161 == pos or die "pos failed: " . pos;
        1 while s/\xff$//; 
        10_160 == length or die "sloop failed: " . length;
    },
    chop => sub {
        local $_ = $str;
        /[^\xff]/g;
        161 == pos or die "pos failed: " . pos;
        1 while "\xff" eq chop;
        10_160 == 1 + length or die "chop failed: " . (1 + length);
    },
    reverse => sub {
        local $_ = $str;
        /[^\xff]/g;
        161 == pos or die "pos failed: " . pos;
        $_ = reverse;
        /[^\xff]/g;
        10_160 == (1 + $len - pos)
            or die "reverse failed: " . (1 + $len - pos);
    },
    C => sub {
        local $_ = $str;
        161 == 1 + unindex $_, "\xff"
            or die "unindex failed: " . (1 + unindex $_, "\xff");
        10_160 == 1 + unrindex $_, "\xff"
            or die "unrindex failed: " . (1 + unrindex $_, "\xff");
    },
};


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

Date: Mon, 12 Nov 2007 12:17:39 -0800
From:  w.c.humann@arcor.de
Subject: Re: Index of first and last non-"\xff" in a long string
Message-Id: <1194898659.839770.249150@k79g2000hse.googlegroups.com>

On Nov 12, 8:57 pm, "John W. Krahn" <kra...@telus.net> wrote:
>
> Try this in your testing:
>
> $data =~ /[^\xff].*[^\xff]/s and my ( $first, $last ) = ( $-[ 0 ], $+[ 0
> ] - 1 );

Thanks John,

at least a hundred times faster than my attempt at pattern matching --
but still several times slower than tr/index/rindex.

Wolfram



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

Date: Mon, 12 Nov 2007 12:37:27 -0800
From:  w.c.humann@arcor.de
Subject: Re: Index of first and last non-"\xff" in a long string
Message-Id: <1194899847.325655.221510@v3g2000hsg.googlegroups.com>

On Nov 12, 8:56 pm, Ben Morrow <b...@morrow.me.uk> wrote:
>
> On my machine, the benchmark below gives
>
>             Rate   subst   sloop    chop   match reverse   index       C
> subst      403/s      --    -90%    -94%    -96%    -97%    -97%   -100%
> sloop     4078/s    912%      --    -36%    -58%    -73%    -73%    -96%
> chop      6340/s   1474%     55%      --    -35%    -58%    -59%    -94%
> match     9754/s   2322%    139%     54%      --    -36%    -37%    -91%
> reverse  15247/s   3686%    274%    140%     56%      --     -1%    -85%
> index    15376/s   3718%    277%    143%     58%      1%      --    -85%
> C       104065/s  25739%   2452%   1541%    967%    583%    577%      --
>
> so index is probably the best you're going to get without using C.

Hey, some great ideas here, thanks Ben.

Glad I had already found the fastest pure-perl solution :-)
(but 'reverse' is so close, the order might change per run...)

'Inline C' is great but less portable, and I'm mainly using this on
win32.

Wolfram



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

Date: Mon, 12 Nov 2007 21:08:34 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Index of first and last non-"\xff" in a long string
Message-Id: <ivrm05-ds3.ln1@osiris.mauzo.dyndns.org>


Quoth w.c.humann@arcor.de:
> On Nov 12, 8:57 pm, "John W. Krahn" <kra...@telus.net> wrote:
> >
> > Try this in your testing:
> >
> > $data =~ /[^\xff].*[^\xff]/s and my ( $first, $last ) = ( $-[ 0 ], $+[ 0
> > ] - 1 );

D'oh! I knew my match didn't need to do so much backtracking...

> at least a hundred times faster than my attempt at pattern matching --
> but still several times slower than tr/index/rindex.

Interesting... which version of perl? With 
    This is perl, v5.8.8 built for i386-freebsd-64int

and adding this

    innerm => sub {
        local $_ = $str;
        /[^\xff].*[^\xff]/s;
        161 == ($-[0] + 1) or die "innerm \$+ failed: " . ($-[0] + 1);
        10_160 == $+[0] or die "innerm \$- failed: " . $+[0];
    },

to my previous benchmark, I get

           Rate  match  index innerm      C
match    9609/s     --   -41%   -53%   -91%
index   16398/s    71%     --   -21%   -85%
innerm  20641/s   115%    26%     --   -81%
C      109225/s  1037%   566%   429%     --

though seriously increasing the number of trailing "\xff"s causes both
'match' and 'innerm' to perform dramatically badly, so maybe this is an
artefact of my test string.

Ben



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

Date: Mon, 12 Nov 2007 23:42:50 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: oddness in quotes (PerlMagick)
Message-Id: <rmlhj354vv3io5e50cli3vu8ecp1c50irr@4ax.com>

On 12 Nov 2007 06:17:31 GMT, myicq <myicq2@3gmx.net4> wrote:

>My question is: I thought Perl did not differ between single and double 
>quotes, as long as used consistently in a string.

You thought wrong! See

  perldoc perlop


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Mon, 12 Nov 2007 14:59:19 -0800
From: Alan Stewart <astewart1@cox.net>
Subject: Re: Remove slow debug prints with "ifdef" type of pre processor pragma.
Message-Id: <lgmhj318l93515c1c16sovec5a48ss4gr9@4ax.com>

On Mon, 12 Nov 2007 06:00:01 -0800, kebabklubben.emp@gmail.com wrote:

>Hi!
>
>Is there a way to remove slow debug prints with some kind of "ifdef"
>type of pre processor pragma?
>
>They are to slow when I ran big batch jobs, but neat to have durinf
>development. Is there a way in Perl do define that debug prints are
>skipped without any loop overhead?
>
>Best Regards,
>Andreas Lundgren - Sweden

use Smart::Comments;

"Smart comments provide an easy way to insert debugging and tracking
code into a program. They can report the value of a variable, track
the progress of a loop, and verify that particular assertions are
true.

Best of all, when you're finished debugging, you don't have to remove
them. Simply commenting out the use Smart::Comments line turns them
back into regular comments."

Alan


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

Date: Mon, 12 Nov 2007 19:00:12 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Remove slow debug prints with "ifdef" type of pre processor pragma.
Message-Id: <slrnfjhtos.b6o.tadmc@tadmc30.sbcglobal.net>

kebabklubben.emp@gmail.com <kebabklubben.emp@gmail.com> wrote:

> Is there a way to remove slow debug prints with some kind of "ifdef"
> type of pre processor pragma?


No, but you can use constants, and let them be optimized away
by the compiler.


   use constant DEBUG => 0;

   if ( DEBUG ) {
      # code here is optimized away
   }


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Mon, 12 Nov 2007 12:44:16 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: sleep/fork/shell/SIGCHLD interaction problem
Message-Id: <87r6ivgsfj.fsf@pobox.com>

xhoster@gmail.com writes:
> Oy.  That forces me to know more about the system thing than I wish I had
> to know, at least for such a conceptually simple thing.  Not that that is
> surprising--there are limits to how much Perl can do to insulate me. malloc
> and free it does a good job of, but signals I guess are harder.

I am reminded of some commercial Unix kernel hackers who were
responsible for the signal handling code.  They had a pole 8 or 10
feet high with a sign on the top saying, "You must be THIS TALL to use
signals."  As much as possible, they included themselves in this rule.

-=Eric


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

Date: Mon, 12 Nov 2007 18:55:24 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: syntax question in dealing with .Net api
Message-Id: <s5km05-s62.ln1@osiris.mauzo.dyndns.org>

[newsgroups trimmed since my ISP doesn't carry microsoft.*, f'up set]

Quoth trillich@gmail.com:
> 
> we've got two apps, one in java, one in .Net, and we're trying to put
> some glue together to transfer data back and forth between them:
> 
> - reading data FROM the .Net application is easy
> - writing data TO the .Net application is a puzzle...
> 
> to read data from within VB, we can use syntax like VAR =
> OBJ.METHOD(PARAMS) and to write fields to an object from within VB
> it's also simple: OBJ.METHOD(PARAMS) = VAL.
> 
> only the read-style syntax works in exterior languages (Perl is our
> platform for proof-of-concept):
> 
> $val = $obj->method("param");
> 
> but the write-style syntax needs something different:
> 
> $obj->method("param") = $expr; # no way

I don't know much about .Net, but when you say 'fields' here are you
referring to what Microsoft call 'properties' in OLE/COM? In that case,
that standard way to access COM objects from Perl is to use the
Win32::OLE module, which provides the syntax

    $obj->LetProperty('method', 'param', $expr);

to perform what you are asking for above. See the docs for Win32::OLE.

Since the method/property distinction, in particular the concept of
'properties with arguments which are nevertheless assignable and
different from methods', is very much a VB thing, you will have to use
some sort of OLE-compatibility layer in other languages. I would have
thought most languages that run on Win32 would have a standard COM
binding, by now.

If you are talking to your .Net app through some means other than COM,
you will have to tell us more about what you are doing.

Ben



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

Date: Mon, 12 Nov 2007 22:27:57 -0000
From:  trillich@gmail.com
Subject: Re: syntax question in dealing with .Net api
Message-Id: <1194906477.225333.3320@v65g2000hsc.googlegroups.com>

On Nov 12, 12:55 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth trill...@gmail.com:
> > to read data from within VB, we can use syntax like VAR =
> > OBJ.METHOD(PARAMS) and to write fields to an object from within VB
> > it's also simple: OBJ.METHOD(PARAMS) = VAL.
>
> > only the read-style syntax works in exterior languages (Perl is our
> > platform for proof-of-concept):
>
> > $val = $obj->method("param");
>
> > but the write-style syntax needs something different:
>
> > $obj->method("param") = $expr; # no way
>
> I don't know much about .Net, but when you say 'fields' here are you
> referring to what Microsoft call 'properties' in OLE/COM? In that case,
> that standard way to access COM objects from Perl is to use the
> Win32::OLE module, which provides the syntax
>
>     $obj->LetProperty('method', 'param', $expr);
>
> to perform what you are asking for above. See the docs for Win32::OLE.

hmm. that doesn't look like...

waitaminit:

"""
    The SetProperty() method allows to modify properties with
arguments, which is not supported by the hash syntax. The hash form

            $Object->{Property} = $Value;

    is equivalent to

            $Object->SetProperty('Property', $Value);
"""

so... if we're reading values via

$stu = $students->Item( $ix );
$fname = $stu->Fields( 31 );

that implies that maybe we can do

$stu->LetProperty('Fields',31,'Beelzebub');

but there's no way that...

it works! it really works! hoorah!

big thanks, Ben, a blessing upon you and the horse you rode in on!



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

Date: Mon, 12 Nov 2007 22:29:58 -0000
From:  trillich@gmail.com
Subject: Re: syntax question in dealing with .Net api
Message-Id: <1194906598.147591.143650@o38g2000hse.googlegroups.com>

On Nov 12, 12:06 pm, trill...@gmail.com wrote:
> hi -- not sure where the best place would be to post this; please
> point me elsewhere if there's another list more apropos...
>
> we've got two apps, one in java, one in .Net, and we're trying to put
> some glue together to transfer data back and forth between them:
>
> - reading data FROM the .Net application is easy
> - writing data TO the .Net application is a puzzle...
>
> to read data from within VB, we can use syntax like VAR =
> OBJ.METHOD(PARAMS) and to write fields to an object from within VB
> it's also simple: OBJ.METHOD(PARAMS) = VAL.
>
> only the read-style syntax works in exterior languages (Perl is our
> platform for proof-of-concept):
>
> $val = $obj->method("param");
>
> but the write-style syntax needs something different:
>
> $obj->method("param") = $expr; # no way
>
> is there a standardized "write-to" syntax that non-VB languages can
> take advantages?
>
> $obj->method("param")->let($expr); # for example
> $obj->let($expr)->method("param"); # for example
> $obj->let_method("param",$expr); # for example
>
> anybody know a FAQ or URL that'll point us in the right direction?

SOLVED:

> > to read data from within VB, we can use syntax like VAR =
> > OBJ.METHOD(PARAMS) and to write fields to an object from within VB
> > it's also simple: OBJ.METHOD(PARAMS) = VAL.

> > only the read-style syntax works in exterior languages (Perl is our
> > platform for proof-of-concept):

> > $val = $obj->method("param");

> > but the write-style syntax needs something different:

> > $obj->method("param") = $expr; # no way

> I don't know much about .Net, but when you say 'fields' here are you
> referring to what Microsoft call 'properties' in OLE/COM? In that case,
> that standard way to access COM objects from Perl is to use the
> Win32::OLE module, which provides the syntax

>     $obj->LetProperty('method', 'param', $expr);

> to perform what you are asking for above. See the docs for Win32::OLE.

Win32::OLE manpage includes

"""
    The SetProperty() method allows to modify properties with
arguments, which is not supported by the hash syntax. The hash form

            $Object->{Property} = $Value;

    is equivalent to

            $Object->SetProperty('Property', $Value);
"""

so... if we're reading values via

$stu = $students->Item( $ix );
$fname = $stu->Fields( 31 );

that implies that maybe we can do

$stu->LetProperty('Fields',31,'Beelzebub');

but there's no way that...

it works! it really works! hoorah!



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

Date: Mon, 12 Nov 2007 23:41:17 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: To extract numbers from files with Perl
Message-Id: <8ilhj3502qsef7b3v9ieq7bik7s2i5n67s@4ax.com>

On Mon, 12 Nov 2007 01:39:46 GMT, Tad McClellan <tadmc@seesig.invalid>
wrote:

>That's what inplace editing is supposed to do.
>
>If that is not what you wanted done, then you should not have
>turned on inplace editing, in which case, you would have to
>handle the file naming in your own code.

Speaking of which, the wild feature request of the day is: ^I could
take a subref which will be passed a string (the original filename)
and should return a modified string.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Mon, 12 Nov 2007 13:56:06 -0800
From:  chacallot@gmail.com
Subject: Why /(word){0}/ does not work?
Message-Id: <1194904566.337473.153260@57g2000hsv.googlegroups.com>

Hi,

I use a monitoring application, which allow use of perl regexp to
filter which instance of something I want to monitor.
In some case I want to monitor everything except one instance.
Lets say it's every filesystem except /temp.
The monitoring software allow perl regexp but not negating them.

So I tried /(\/temp){0}/ but it doesnt work (every filesystem is
monitored /temp included).

Why is it it doesnt work?
Is /^(?:(?!\/temp).)*$/ my only chance to do this right? Looks insanly
obfuscated to me, but if you this it's the rite way to do it, I may
try to understand it ....

Regards,
Chacallot.



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

Date: Mon, 12 Nov 2007 22:17:09 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Why /(word){0}/ does not work?
Message-Id: <Fh4_i.2138$Z01.1443@trndny01>

chacallot@gmail.com wrote:
> So I tried /(\/temp){0}/ but it doesnt work (every filesystem is
> monitored /temp included).

The usual terminology for REs is "to match", not "to monitor". Therefore I 
am not sure about if you are complaining that /(\/temp){0}/  matches '/temp' 
or doesn't match '/temp'.

However, _I_ read /(\/temp){0}/ as zero consecutive matches of /(\/temp)/ 
which would match exactly the same strings as the empty RE //, e.g. it will 
match every string.

> Why is it it doesnt work?

But it does work. It matches zero repetitions of the preceeding RE.

jue 




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

Date: Mon, 12 Nov 2007 23:29:15 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: Why /(word){0}/ does not work?
Message-Id: <uaKdnZWLFpZEfKXanZ2dnUVZ8t7inZ2d@pipex.net>

chacallot@gmail.com wrote:

> The monitoring software allow perl regexp but not negating them.


    Does it allow you to set an action of "ignore"?

    If so, set a regex for /temp - action == ignore
    Then set a regex for the rest of life, doing what you want for it.



-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


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

Date: Mon, 12 Nov 2007 17:28:53 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: chacallot@gmail.com
Subject: Re: Why /(word){0}/ does not work?
Message-Id: <863avblyqy.fsf@blue.stonehenge.com>

>>>>> "chacallot" == chacallot  <chacallot@gmail.com> writes:

chacallot> So I tried /(\/temp){0}/ but it doesnt work (every filesystem is
chacallot> monitored /temp included).

Indeed.   The string "a" matches /a{0}/, because "a" has a match for zero
instances of 'a', which is the same as the empty string, which every string
has.

Why would you expect it to do something different?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V11 Issue 1027
***************************************


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