[30989] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2234 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 25 03:09:53 2009

Date: Wed, 25 Feb 2009 00:09:15 -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           Wed, 25 Feb 2009     Volume: 11 Number: 2234

Today's topics:
    Re: debugging on stdout <no_th@nks.org>
    Re: debugging on stdout <no_th@nks.org>
    Re: debugging on stdout <ben@morrow.me.uk>
    Re: debugging on stdout <ben@morrow.me.uk>
    Re: debugging on stdout <tim@burlyhost.com>
        new CPAN modules on Wed Feb 25 2009 (Randal Schwartz)
        Simple regex question <amirovic@googlemail.com>
    Re: Simple regex question <noreply@gunnar.cc>
    Re: Simple regex question <ben@morrow.me.uk>
    Re: Strategy of ++/-- operator in Lists in perl <thepoet_nospam@arcor.de>
    Re: Strategy of ++/-- operator in Lists in perl <ben@morrow.me.uk>
    Re: utf8 and chomp <whynot@pozharski.name>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 25 Feb 2009 04:44:25 GMT
From: mike <no_th@nks.org>
Subject: Re: debugging on stdout
Message-Id: <m3y6vvyvkn.fsf@localhost.localdomain>



thanks for the help and suggestions.


> This feels like a race condition of some sort, but I can't see where it
> might be. What does your script do next? Can you use ps to examine what
> arguments actually get passed to the gmplayer-bin process? What happens
> if you take the temporary file out of the equation and just supply a
> literal string to mplayer? What happens if you use ordinary mplayer
> rather than gmplayer-bin? Can you give us a minimal *complete* script
> that reliably fails on your machine? Is there anything else different
> between the two environments: different environment vars, different
> shells, &c.? Does the program still succeed if you single-step in the
> debugger (run it with perl -d) rather than using Emacs?


   $video = $ARGV[0];
   $vid_resume = vid_position_file($video);
   if (-e $vid_resume) {
      $pid = open2(*reader, *writer, "gmplayer-bin -slave -quiet -ss `cat $vid_resume` $video") || die "Unable to open $1: $!";

--> what follows:

      unlink $vid_resume;
   }
#   else {
#      $pid = open2(*reader, *writer, "gmplayer-bin -slave -quiet $video") || die "Unable to open $1: $!";
#   }
   # new position will be recorded here:
   open(POS_FH, "> $vid_resume") || die "Unable to open $1: $!";
}
## otherwise bring up mplayer unloaded:
#else {
#   $pid = open2(*reader, *writer, 'gmplayer-bin -slave -quiet') || die "Unable to open $1: $!";
#}

clear_mplayer();

    .
    .   
    .
    
sub clear_mplayer {

   # ps'ing too fast is missing the "L" ("pages locked in memory"):
   sleep 5;
   
   my $video_pid = $pid; $video_pid++;
   my $running = `/bin/ps ax`;

   if ($running =~ /$video_pid\s+pts\/[0-9]+\s+(S|R)?L/) {
      writer->autoflush();
      while (! /Starting playback/) {
	 $_ = <reader>;
      }
      return 1;
   }
   else {
      return 0;
   }
}

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

1. once that sequence finishes the prog goes onto to other tasks and
   everything from this point on works as expected

2. the rest of the if/else is only commented while I've been looking at
   this problem (ensure either invocation uses the same one)

3. the problem isn't unlink - I ran with it commented and no change

4. I don't know what "writer->autoflush();" does but it was in the code I
   lifted from a web page so left it in (in or out doesn't seem to impact
   this -ss problem) 

5. mplayer whether started with a vid arg or not appears to start with two
   consecutive pids where the second indicates that a video is loaded or
   running - to guarantee I can find mplayer's responses to my queries I
   throw away everything up to "Starting..."; to guarantee I'll find 
   "Starting..." I don't look for it until the "L" in ps shows up.

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


wrt some of your easier suggestions:

- I tried plain mplayer, replacing cat with the pathname, added path to
g/mplayer bins and at best the video comes up running but ostensibly
ignoring -ss and at worst just comes up with video loaded but not
running. 

- I ordinarily use csh but tried bash and sh, same behavior.

- I did notice a couple times in the past couple days that a specific
invocation repeated would seem to start ok (don't recall if it was using
-ss) and at other times came up with the video stopped; I thought "that
can't be, I must've not been paying attn to how I started it."

so there must be something to this race condition thing; I don't know
anything about the open2 alternative you mentioned but will see if I can
manage using that instead and see what happens.


-- 


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

Date: Wed, 25 Feb 2009 05:07:44 GMT
From: mike <no_th@nks.org>
Subject: Re: debugging on stdout
Message-Id: <m3tz6jyuhu.fsf@localhost.localdomain>


I found the problem if you want to skip reading the rest.

that "clear_mplayer()" is not supposed to be by itself (it's not needed
for the else in if/else since there's no "Starting..." to chk for in
unloaded mplayer).

       unlink $vid_resume;
    }
 #   else {
 #      $pid = open2(*reader, *writer, "gmplayer-bin -slave -quiet $video") || die "Unable to open $1: $!";
 #   }
--> clear_mplayer();
    # new position will be recorded here:
    open(POS_FH, "> $vid_resume") || die "Unable to open $1: $!";
 }

--> is where it was originally.


but in messing around I had those lines reversed:

    # new position will be recorded here:
    open(POS_FH, "> $vid_resume") || die "Unable to open $1: $!";
--> clear_mplayer();


for some reason 'open POS_FH' appears to be overwriting $vid_resume (with
its -ss value), even though it follows two instructions - unlink (which
isn't causing the problem because I tried it commented) and the cat in
open2.  so open2(... -ss ) is reading an empty file.

when I put the lines back where they were in an earlier incarnation, the
sleep in clear_mplayer ostensibly ensured 'open POS_FH' hadn't written a
new $vid_resume before cat read from it.  and the script runs from cmd
line same as it does stepping through in cperl-db.

thanks - I probably never would've noticed this without posting.





> thanks for the help and suggestions.
> 
> 
> > This feels like a race condition of some sort, but I can't see where it
> > might be. What does your script do next? Can you use ps to examine what
> > arguments actually get passed to the gmplayer-bin process? What happens
> > if you take the temporary file out of the equation and just supply a
> > literal string to mplayer? What happens if you use ordinary mplayer
> > rather than gmplayer-bin? Can you give us a minimal *complete* script
> > that reliably fails on your machine? Is there anything else different
> > between the two environments: different environment vars, different
> > shells, &c.? Does the program still succeed if you single-step in the
> > debugger (run it with perl -d) rather than using Emacs?
> 
> 
>    $video = $ARGV[0];
>    $vid_resume = vid_position_file($video);
>    if (-e $vid_resume) {
>       $pid = open2(*reader, *writer, "gmplayer-bin -slave -quiet -ss `cat $vid_resume` $video") || die "Unable to open $1: $!";
> 
> --> what follows:
> 
>       unlink $vid_resume;
>    }
> #   else {
> #      $pid = open2(*reader, *writer, "gmplayer-bin -slave -quiet $video") || die "Unable to open $1: $!";
> #   }
>    # new position will be recorded here:
>    open(POS_FH, "> $vid_resume") || die "Unable to open $1: $!";
> }
> ## otherwise bring up mplayer unloaded:
> #else {
> #   $pid = open2(*reader, *writer, 'gmplayer-bin -slave -quiet') || die "Unable to open $1: $!";
> #}
> 
> clear_mplayer();
> 
>     .
>     .   
>     .
>     
> sub clear_mplayer {
> 
>    # ps'ing too fast is missing the "L" ("pages locked in memory"):
>    sleep 5;
>    
>    my $video_pid = $pid; $video_pid++;
>    my $running = `/bin/ps ax`;
> 
>    if ($running =~ /$video_pid\s+pts\/[0-9]+\s+(S|R)?L/) {
>       writer->autoflush();
>       while (! /Starting playback/) {
> 	 $_ = <reader>;
>       }
>       return 1;
>    }
>    else {
>       return 0;
>    }
> }
> 
> -------------
> 
> 1. once that sequence finishes the prog goes onto to other tasks and
>    everything from this point on works as expected
> 
> 2. the rest of the if/else is only commented while I've been looking at
>    this problem (ensure either invocation uses the same one)
> 
> 3. the problem isn't unlink - I ran with it commented and no change
> 
> 4. I don't know what "writer->autoflush();" does but it was in the code I
>    lifted from a web page so left it in (in or out doesn't seem to impact
>    this -ss problem) 
> 
> 5. mplayer whether started with a vid arg or not appears to start with two
>    consecutive pids where the second indicates that a video is loaded or
>    running - to guarantee I can find mplayer's responses to my queries I
>    throw away everything up to "Starting..."; to guarantee I'll find 
>    "Starting..." I don't look for it until the "L" in ps shows up.
> 
> -------------
> 
> 
> wrt some of your easier suggestions:
> 
> - I tried plain mplayer, replacing cat with the pathname, added path to
> g/mplayer bins and at best the video comes up running but ostensibly
> ignoring -ss and at worst just comes up with video loaded but not
> running. 
> 
> - I ordinarily use csh but tried bash and sh, same behavior.
> 
> - I did notice a couple times in the past couple days that a specific
> invocation repeated would seem to start ok (don't recall if it was using
> -ss) and at other times came up with the video stopped; I thought "that
> can't be, I must've not been paying attn to how I started it."
> 
> so there must be something to this race condition thing; I don't know
> anything about the open2 alternative you mentioned but will see if I can
> manage using that instead and see what happens.
> 
> 
> -- 

-- 


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

Date: Wed, 25 Feb 2009 05:32:34 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: debugging on stdout
Message-Id: <io1f76-gft.ln1@osiris.mauzo.dyndns.org>


Quoth mike <no_th@nks.org>:
> 
> > This feels like a race condition of some sort, but I can't see where it
> > might be. What does your script do next? Can you use ps to examine what
> > arguments actually get passed to the gmplayer-bin process? What happens
> > if you take the temporary file out of the equation and just supply a
> > literal string to mplayer? What happens if you use ordinary mplayer
> > rather than gmplayer-bin? Can you give us a minimal *complete* script
> > that reliably fails on your machine? Is there anything else different
> > between the two environments: different environment vars, different
> > shells, &c.? Does the program still succeed if you single-step in the
> > debugger (run it with perl -d) rather than using Emacs?
> 
> 
>    $video = $ARGV[0];
>    $vid_resume = vid_position_file($video);
>    if (-e $vid_resume) {
>       $pid = open2(*reader, *writer, "gmplayer-bin -slave -quiet -ss
> `cat $vid_resume` $video") || die "Unable to open $1: $!";
> 
> --> what follows:
> 
>       unlink $vid_resume;
>    }
> #   else {
> #      $pid = open2(*reader, *writer, "gmplayer-bin -slave -quiet
> $video") || die "Unable to open $1: $!";
> #   }
>    # new position will be recorded here:
>    open(POS_FH, "> $vid_resume") || die "Unable to open $1: $!";

I believe the problem is here. What is probably happening is

    open2 starts the shell, which starts successfully, and returns;
    perl moves on to unlink $vid_resume;
        if you comment out the unlink, perl moves on to delete the
        contents of $vid_resume using open ">";
    the shell runs cat;
    cat opens $vid_resume, which by this point either doesn't exist or
    is empty;
    mplayer is run with a blank -ss option.

When you are single-stepping, the shell has a chance to run cat and then
mplayer before the file disappears. Can you confirm that when mplayer
fails to start correctly, ps shows the wrong command line?

I will ask you again: why on earth are you keeping the offset in a file
at all? Just keep it in a variable.

Also, while I'm here:

    Don't use global filehandles.
    Use three-arg open.
    $1 doesn't hold anything useful at this point.
    Be consistent about your use of parentheses.
    && and || are booleans, 'and' and 'or' are for flow control.

    open(my $POS_FH, ">", $vid_resume)
        or die("Unable to open '$vid_resume': $!");

(I would omit both sets of parens, but that's a matter of style so
what's important is you pick a style and stick to it.)

> 3. the problem isn't unlink - I ran with it commented and no change

Right, but in any case you are immediately emptying the file, which has
the same effect.

> 4. I don't know what "writer->autoflush();" does but it was in the code I
>    lifted from a web page so left it in (in or out doesn't seem to impact
>    this -ss problem) 

See perldoc IO::Handle. It's a *really* bad idea to include bits of code
you don't understand. If you can't find out what they do, leave them out
and find some way to do what you need that you do understand.

If you are going to use bareword filehandles, I would *strongly*
recommend making them all uppercase. The rules for deciding whether
'writer' there is a filehandle, a package name or a sub call kind of
make my skin crawl, so it's much safer to keep filehandles uppercase,
package names mixed case and sub names lowercase.

> 5. mplayer whether started with a vid arg or not appears to start with two
>    consecutive pids where the second indicates that a video is loaded or
>    running - to guarantee I can find mplayer's responses to my queries I
>    throw away everything up to "Starting..."; to guarantee I'll find 
>    "Starting..." I don't look for it until the "L" in ps shows up.

You shouldn't need to mess about with ps: just read from mplayer's
output until it gets to "Starting...".

> - I tried plain mplayer, replacing cat with the pathname,

I didn't say 'replace cat with the pathname' I said 'replace cat with
the contents of the file'. That is:

    use File::Slurp qw/slurp/;

    my $vid_resume_contents = slurp $vid_resume;

    my $pid = open2(..., "mplayer ... -ss $vid_resume_contents ...")
        ...;

or read the file yourself if you don't want to use File::Slurp. I also
said it would be better to rework vid_position_file so that it returns a
string directly rather than a filename.

> - I did notice a couple times in the past couple days that a specific
> invocation repeated would seem to start ok (don't recall if it was using
> -ss) and at other times came up with the video stopped; I thought "that
> can't be, I must've not been paying attn to how I started it."

That's what race conditions do. Sometimes the scheduling happens just so
and the shell gets to read the file before perl kills it.

Ben



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

Date: Wed, 25 Feb 2009 05:39:09 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: debugging on stdout
Message-Id: <t42f76-gft.ln1@osiris.mauzo.dyndns.org>


Quoth mike <no_th@nks.org>:
> 
> I found the problem if you want to skip reading the rest.

Heh... I just posted a reply with the same answer...

> for some reason 'open POS_FH' appears to be overwriting $vid_resume (with
> its -ss value), even though it follows two instructions - unlink (which
> isn't causing the problem because I tried it commented) and the cat in
> open2.  so open2(... -ss ) is reading an empty file.

open2 runs a command in the background (that's the point) so the perl
program will continue before the shell has even started parsing the
command line. The root of your problem here is that you're using four
processes (perl, the shell, cat, and mplayer) where you only needed two.

> when I put the lines back where they were in an earlier incarnation, the
> sleep in clear_mplayer ostensibly ensured 'open POS_FH' hadn't written a
> new $vid_resume before cat read from it.  and the script runs from cmd
> line same as it does stepping through in cperl-db.

Strictly speaking this isn't safe. Even a five-second sleep isn't enough
to be certain cat has finished reading the file. Just get the value out
yourself beforehand.

Ben



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

Date: Tue, 24 Feb 2009 22:39:29 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: debugging on stdout
Message-Id: <CI5pl.57157$2h5.7221@newsfe11.iad>

mike wrote:

> when I put the lines back where they were in an earlier incarnation,
> the sleep in clear_mplayer ostensibly ensured 'open POS_FH' hadn't
> written a new $vid_resume before cat read from it.  and the script
> runs from cmd line same as it does stepping through in cperl-db.

Sorry I didn't read the entire thread, but I'm curious, what is the
specific purpose of sleep?  Do you want to actually wait for something
specific, such as allowing time for something to complete (hopefully),
or for other reasons?  If you want to ensure something completed, I'd
check the position against the size of the file (or data) remaining and
try and track how much has been read/output, and once it's complete
(once it's sent all of its data), then close/clear.  If you mean
something else, then I might just have to read the thread to make a
better suggestion (even for that previous one, really).
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


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

Date: Wed, 25 Feb 2009 05:42:26 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Feb 25 2009
Message-Id: <KFLx6q.1r2C@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Audio-ScratchLive-0.02
http://search.cpan.org/~capoeirab/Audio-ScratchLive-0.02/
v0.02 - this class provides simple way to read/write ScratchLIVE crates and databases 
----
BioPerl-db-1.6.0
http://search.cpan.org/~cjfields/BioPerl-db-1.6.0/
----
BioPerl-network-1.6.0
http://search.cpan.org/~cjfields/BioPerl-network-1.6.0/
----
BioPerl-run-1.6.0
http://search.cpan.org/~cjfields/BioPerl-run-1.6.0/
----
CPANPLUS-0.85_06
http://search.cpan.org/~kane/CPANPLUS-0.85_06/
API & CLI access to the CPAN mirrors 
----
Class-MOP-0.78
http://search.cpan.org/~drolsky/Class-MOP-0.78/
A Meta Object Protocol for Perl 5 
----
ClearPress-318
http://search.cpan.org/~rpettett/ClearPress-318/
Simple, fresh & fruity MVC framework - http://clearpress.net/ 
----
ClearPress-320
http://search.cpan.org/~rpettett/ClearPress-320/
Simple, fresh & fruity MVC framework - http://clearpress.net/ 
----
DBD-PgPP-0.06
http://search.cpan.org/~arc/DBD-PgPP-0.06/
Pure Perl PostgreSQL driver for the DBI 
----
Data-Domain-0.13
http://search.cpan.org/~dami/Data-Domain-0.13/
Data description and validation 
----
DateTime-Format-CLDR-1.03
http://search.cpan.org/~maros/DateTime-Format-CLDR-1.03/
Parse and format CLDR time patterns 
----
Email-Stuff-2.07
http://search.cpan.org/~rjbs/Email-Stuff-2.07/
A more casual approach to creating and sending Email:: emails 
----
Encode-compat-MIME-Header-ISO_2022_JP-0.01
http://search.cpan.org/~kazuho/Encode-compat-MIME-Header-ISO_2022_JP-0.01/
a compatibilty module for Encode::MIME::Header::ISO_2022_JP 
----
FCGI-Engine-0.06
http://search.cpan.org/~stevan/FCGI-Engine-0.06/
A flexible engine for running FCGI-based applications 
----
FCGI-Engine-0.07
http://search.cpan.org/~stevan/FCGI-Engine-0.07/
A flexible engine for running FCGI-based applications 
----
Fey-0.21
http://search.cpan.org/~drolsky/Fey-0.21/
Better SQL Generation Through Perl 
----
Fey-0.22
http://search.cpan.org/~drolsky/Fey-0.22/
Better SQL Generation Through Perl 
----
Frontier-Client-Easy-1.01
http://search.cpan.org/~dfreedman/Frontier-Client-Easy-1.01/
Perl extension for easy use of Frontier::Client 
----
Frontier-Client-Easy-1.02
http://search.cpan.org/~dfreedman/Frontier-Client-Easy-1.02/
Perl extension for easy use of Frontier::Client 
----
HTML-Parser-Simple-1.00
http://search.cpan.org/~rsavage/HTML-Parser-Simple-1.00/
Parse nice HTML files without needing a compiler 
----
HTTP-DAV-0.36
http://search.cpan.org/~opera/HTTP-DAV-0.36/
A WebDAV client library for Perl5 
----
HTTP-Engine-Middleware-0.09
http://search.cpan.org/~yappo/HTTP-Engine-Middleware-0.09/
middlewares distribution 
----
IO-Tty-1.08
http://search.cpan.org/~rgiersig/IO-Tty-1.08/
Low-level allocate a pseudo-Tty, import constants. 
----
IPC-MMA-0.53
http://search.cpan.org/~mackenna/IPC-MMA-0.53/
Shared Memory using Ralf Engelschall's mm library 
----
LaTeX-Table-0.9.14
http://search.cpan.org/~limaone/LaTeX-Table-0.9.14/
Perl extension for the automatic generation of LaTeX tables. 
----
Lexical-Types-0.01
http://search.cpan.org/~vpit/Lexical-Types-0.01/
Extend the semantics of typed lexicals. 
----
Mail-Builder-Simple-0.06
http://search.cpan.org/~teddy/Mail-Builder-Simple-0.06/
Send UTF-8 HTML and text email with attachments and inline images, eventually using templates 
----
Math-Int2Base-0.01
http://search.cpan.org/~bbaxter/Math-Int2Base-0.01/
Perl extension for converting decimal (base-10) integers into another number base from base-2 to base-62, and back to decimal. 
----
MediaWiki-Bot-2.1.1
http://search.cpan.org/~dcollins/MediaWiki-Bot-2.1.1/
a Wikipedia bot framework written in Perl 
----
MediaWiki-Bot-2.1.2
http://search.cpan.org/~dcollins/MediaWiki-Bot-2.1.2/
a Wikipedia bot framework written in Perl 
----
Moose-0.72
http://search.cpan.org/~drolsky/Moose-0.72/
A postmodern object system for Perl 5 
----
MooseX-Declare-0.06
http://search.cpan.org/~flora/MooseX-Declare-0.06/
Declarative syntax for Moose 
----
MooseX-Types-DateTimeX-0.04
http://search.cpan.org/~ecarroll/MooseX-Types-DateTimeX-0.04/
Extensions to MooseX::Types::DateTime 
----
MouseX-Object-Pluggable-0.021
http://search.cpan.org/~kitano/MouseX-Object-Pluggable-0.021/
Mouse port of MooseX::Object::Pluggable 
----
Net-FTPSSL-0.07
http://search.cpan.org/~cleach/Net-FTPSSL-0.07/
A FTP over SSL/TLS class 
----
Net-IMAP-Server-1.08
http://search.cpan.org/~alexmv/Net-IMAP-Server-1.08/
A single-threaded multiplexing IMAP server implementation, using Net::Server::Coro. 
----
Net-Interface-1.003
http://search.cpan.org/~miker/Net-Interface-1.003/
Perl extension to access network interfaces 
----
Normalize-0.31
http://search.cpan.org/~kakadu/Normalize-0.31/
normalize scores between 0 and 1. 
----
Parse-Dia-SQL-0.01
http://search.cpan.org/~aff/Parse-Dia-SQL-0.01/
Convert Dia class diagrams into SQL. 
----
Parse-Eyapp-1.141
http://search.cpan.org/~casiano/Parse-Eyapp-1.141/
Extensions for Parse::Yapp 
----
Path-Resolver-1.000
http://search.cpan.org/~rjbs/Path-Resolver-1.000/
go from "file" names to things 
----
Pod-POM-View-DocBook-0.01
http://search.cpan.org/~andrewf/Pod-POM-View-DocBook-0.01/
DocBook XML view of a Pod Object Model 
----
Prima-1.28
http://search.cpan.org/~karasik/Prima-1.28/
a perl graphic toolkit 
----
RDF-Converter-CSV-0.01
http://search.cpan.org/~arshad/RDF-Converter-CSV-0.01/
Converts comma separated CSV to RDF 
----
RTx-WorkflowBuilder-1.02
http://search.cpan.org/~clkao/RTx-WorkflowBuilder-1.02/
helper for configuring approval workflow in RT 
----
Readonly-XS-1.05
http://search.cpan.org/~roode/Readonly-XS-1.05/
Companion module for Readonly.pm, to speed up read-only scalar variables. 
----
SVN-Hooks-0.14.24
http://search.cpan.org/~gnustavo/SVN-Hooks-0.14.24/
A framework for implementing Subversion hooks. 
----
Search-Indexer-Incremental-MD5-0.05.18
http://search.cpan.org/~nkh/Search-Indexer-Incremental-MD5-0.05.18/
Incrementally index your files 
----
Simo-0.0805
http://search.cpan.org/~kimoto/Simo-0.0805/
Very simple framework for Object Oriented Perl. 
----
Simo-Error-0.0204
http://search.cpan.org/~kimoto/Simo-Error-0.0204/
Error object for Simo 
----
Simo-Wrapper-0.0206
http://search.cpan.org/~kimoto/Simo-Wrapper-0.0206/
Object wrapper to manipulate attrs and methods. 
----
Sphinx-Search-0.15
http://search.cpan.org/~jjschutz/Sphinx-Search-0.15/
Sphinx search engine API Perl client 
----
String-MatchInterpolate-0.03
http://search.cpan.org/~pevans/String-MatchInterpolate-0.03/
perform named regexp capture and variable interpolation from the same template. 
----
Term-ProgressBar-Simple-0.03
http://search.cpan.org/~evdb/Term-ProgressBar-Simple-0.03/
simpler progress bars 
----
Test-LoadAllModules-0.01
http://search.cpan.org/~kitano/Test-LoadAllModules-0.01/
do use_ok for modules in search path 
----
Test-LoadAllModules-0.011
http://search.cpan.org/~kitano/Test-LoadAllModules-0.011/
do use_ok for modules in search path 
----
Test-Synopsis-0.01
http://search.cpan.org/~miyagawa/Test-Synopsis-0.01/
Test your SYNOPSIS code 
----
Test-Synopsis-0.02
http://search.cpan.org/~miyagawa/Test-Synopsis-0.02/
Test your SYNOPSIS code 
----
WWW-Hanako-0.04
http://search.cpan.org/~hamano/WWW-Hanako-0.04/
Perl interface for Hanako(Pollen observation system at Japan) 
----
WWW-Hanako-0.05
http://search.cpan.org/~hamano/WWW-Hanako-0.05/
Perl interface for Hanako(Pollen observation system at Japan) 
----
WebService-Class-0.01
http://search.cpan.org/~haosan/WebService-Class-0.01/
WebService retrieve data for object 
----
WebService-Class-0.02
http://search.cpan.org/~haosan/WebService-Class-0.02/
WebService retrieve data by object. and have caching structure by file base or memcached base and more 
----
WebService-Class-0.03
http://search.cpan.org/~haosan/WebService-Class-0.03/
WebService retrieve data by object. and have caching structure by file base or memcached base and more 
----
Wiki-Toolkit-Plugin-Ping-0.03
http://search.cpan.org/~dom/Wiki-Toolkit-Plugin-Ping-0.03/
"ping" various services when nodes are written 
----
XML-Generator-1.02
http://search.cpan.org/~gugu/XML-Generator-1.02/
Perl extension for generating XML 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Tue, 24 Feb 2009 22:42:11 -0800 (PST)
From: "amirovic@googlemail.com" <amirovic@googlemail.com>
Subject: Simple regex question
Message-Id: <8ba6a45e-4665-4c3e-a7c6-fced29280e22@c36g2000yqn.googlegroups.com>

Hi,

I have a simple question but somehow I can't solve it myself:

my $var = "[ a a a a a a a a ]";

I'm working with Parse::Recdescent and would like to match this (it's
not about Parse::Recdescent but a general question):

rule: "["   /.*/   "]"

Now "/.*/" matches everything including the "]", but I'd like to match
every before "]". How should this be done?

Thanks a lot for any response,
Tom


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

Date: Wed, 25 Feb 2009 08:01:07 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Simple regex question
Message-Id: <70k8iuFb6ri5U1@mid.individual.net>

amirovic@googlemail.com wrote:
> 
> my $var = "[ a a a a a a a a ]";
> 
> I'm working with Parse::Recdescent and would like to match this (it's 
> not about Parse::Recdescent but a general question):
> 
> rule: "["   /.*/   "]"
> 
> Now "/.*/" matches everything including the "]", but I'd like to match 
> every before "]". How should this be done?

     $var =~ /\[(.*)]/;
     print "\"$1\"\n";

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Wed, 25 Feb 2009 07:58:01 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Simple regex question
Message-Id: <99af76-j8u.ln1@osiris.mauzo.dyndns.org>


Quoth "amirovic@googlemail.com" <amirovic@googlemail.com>:
> 
> I have a simple question but somehow I can't solve it myself:
> 
> my $var = "[ a a a a a a a a ]";
> 
> I'm working with Parse::Recdescent and would like to match this (it's
> not about Parse::Recdescent but a general question):
> 
> rule: "["   /.*/   "]"
> 
> Now "/.*/" matches everything including the "]", but I'd like to match
> every before "]". How should this be done?

The standard answer is /[^]]*/, though this gets tricky to generalise to
closing delimiters more than a single character long.

Ben



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

Date: Wed, 25 Feb 2009 06:33:54 +0100
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Strategy of ++/-- operator in Lists in perl
Message-Id: <49a4d828$0$32678$9b4e6d93@newsspool2.arcor-online.net>

sln@netherlands.com wrote:
> Below is a Perl code sample of using increment operator on variables in lists.
> Below that is a C++ equivalent.
> 
> The strategies are different for pre/post-increment as far as the list block,
> as are the outcomes.
> 
> Can anybody explain the logic in this? To me, they both look incorrect. C++
> possibly a little more so.

I'd say "perldoc perlop" explains that.

[snip]
Note that just as in C, Perl doesn't define when the variable is
incremented or decremented. You just know it will be done sometime
before or after the value is returned. This also means that modifying a
variable twice in the same statement will lead to undefined behaviour.
Avoid statements like:

     $i = $i ++;
     print ++ $i + $i ++;

Perl will not guarantee what the result of the above statements is.
[snap]

So any regularity in auto-inc/decs behaviour is just a side product
of the grammar rules and optimizations applied. Comparing undefined
behaviours is a moot point. Just try out your C++ snippet with
different compilers, and you'll notice that each one produces a
different output.

--------------- MSVC++ 2007 ------------------
3 3 2 3 1 3
2 2 2 2 0 0
4 4 4 4 2 2 4 4
2 2 1 1 2

--------- gcc version 3.4.4 / cygwin ---------
5 5 3 3 1 1
5 4 4 3 1 0
7 6 6 5 3 2 2 1
4 4 2 1 1


  > --------------------------------
> 
> ## some_lists.pl
> use strict;
> use warnings;
> 
> my ($p,@ar);
> 
> print "\n";
> $p = 0;
> printf ("%d %d %d %d %d %d \n",      $p++, ++$p, $p++, ++$p, $p++, ++$p);
> #                                     +1    +1    +1    +1    +1    +1
> #  going this way --->                 0           2           4
> #                                            6           6           6     <--- going this way
> $p = 0;
> printf ("%d %d %d %d %d %d \n",      $p++, $p++, ++$p, ++$p, $p++, $p++);
> #                                     +1    +1    +1    +1    +1    +1
> #  going this way --->                 0     1                 4     5     <--- going this way
> #                                                  6     6
> $p = 0;
> printf ("%d %d %d %d %d %d %d %d\n", $p++, $p++, ++$p, ++$p, $p++, $p++, ++$p, ++$p);
> #                                     +1    +1    +1    +1    +1    +1    +1    +1
> #  going this way --->                 0     1                 4     5
> #                                                  8     8                 8     8   <--- going this way
> $p = 0;
> printf ("%d %d %d %d %d\n",          $p++, ++$p, $p++, $p++, ++$p);
> #                                     +1    +1    +1    +1    +1   
> #  going this way --->                 0           2     3
> #                                            5                 5     <--- going this way
> $p = 0;
> @ar = ( $p++, $p++, ++$p, ++$p, $p++, $p++, ++$p, ++$p ); print "@ar\n";
> #         0     1                 4     5
> #                     8     8                 8     8
> 
> print "\n";
> $p = 0;
> @ar = ( $p++, $p++, ++$p, $p*=$p, $p++, $p=0, ++$p, ++$p ); print "@ar\n";
> $p = 0;
> @ar = ( $p++, $p++, ++$p, $p*=$p, $p++, $p++, ++$p, ++$p ); print "@ar\n";
> 
> 
> __END__
> 
> 
> /** C Equivalent **/
> 
> 
> int p = 0;
> printf ("%d %d %d %d %d %d \n",      p++, ++p, p++, ++p, p++, ++p);
> //                                         +1        +1        +1
> //                                    3         2         1           <--- going this way
> //   going this way --->                    3         3         3
> 
> p = 0;
> printf ("%d %d %d %d %d %d \n",      p++, p++, ++p, ++p, p++, p++);
> //                                              +1   +1
> //                                    2    2              0    0      <--- going this way
> //   going this way --->                         2    2
> 
> p = 0;
> printf ("%d %d %d %d %d %d %d %d\n", p++, p++, ++p, ++p, p++, p++, ++p, ++p);
> //                                              +1   +1             +1   +1
> //                                     4   4              2    2                <--- going this way
> //   going this way --->                         4    4              4    4
> 
> p = 0;
> printf ("%d %d %d %d %d\n",          p++, ++p, p++, p++, ++p);
> //                                         +1             +1
> //                                    2         1    1            <--- going this way
> //   going this way --->                    2              2
> //
> 
> 


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

Date: Wed, 25 Feb 2009 06:18:18 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Strategy of ++/-- operator in Lists in perl
Message-Id: <ae4f76-uut.ln1@osiris.mauzo.dyndns.org>


Quoth sln@netherlands.com:
> Below is a Perl code sample of using increment operator on variables in lists.
> Below that is a C++ equivalent.
> 
> The strategies are different for pre/post-increment as far as the list block,
> as are the outcomes.
> 
> Can anybody explain the logic in this? To me, they both look incorrect. C++
> possibly a little more so.

I don't now whether this will help you or not, but

    ~% perl -e'print for \$i, \(++$i), \($i++)'
    SCALAR(0x8100c04)
    SCALAR(0x8100c04)
    SCALAR(0x8100094)

preinc returns an alias to the value incremented, postinc returns a copy
of the value before the increment. So

    perl -MData::Alias -le'$i = 0; alias $j = ++$i; $i = 10; print $j'
    10

List assignment takes a copy of all the values assigned, so at that
point the value gets frozen.

C++ (like C) doesn't define the order of increments between sequence
points, so you shouldn't expect any particular logic.

Ben



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

Date: Tue, 24 Feb 2009 22:49:55 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: utf8 and chomp
Message-Id: <slrngq8ndl.775.whynot@orphan.zombinet>

On 2009-02-24, Marc Lucksch <perl@marc-s.de> wrote:
> Eric Pozharski schrieb:
>> I've just gone through your original script with debugger, and found out
>> that after C<$line = <>;> I<$line> is pure byte string.  And then after
>> C<chomp $line;> it automagically decodes into utf8 character(!) string.
>> Should I keep on explaining?  (No, no spoiler this time.)
>
> Ok now I am confused, do please explain.

A long and boring way -- C<perldoc perlvar> then look for section
C<ARGV> (it's the first one among many), read 4 of them thoroughly.
Then return to C<perldoc encoding> and C<perldoc Encode> (it seems to be
used internally by B<encoding> pragma anyway).  Then think a lot and
finally see the light.

p.s.  A quick and dirty way --

perl -wle '
while(<>) {
    system qq|ls -l /proc/$$/fd|;
    exit;
};
' /etc/passwd
total 0
lrwx------ 1 whynot whynot 64 2009-02-24 22:47 0 -> /dev/pts/0
lrwx------ 1 whynot whynot 64 2009-02-24 22:47 1 -> /dev/pts/0
lrwx------ 1 whynot whynot 64 2009-02-24 22:47 2 -> /dev/pts/0
lr-x------ 1 whynot whynot 64 2009-02-24 22:47 3 -> /etc/passwd
lr-x------ 1 whynot whynot 64 2009-02-24 22:47 4 -> pipe:[7056143]
l-wx------ 1 whynot whynot 64 2009-02-24 22:47 5 -> pipe:[7056143]

Pay a bit of attention to I<fileno> #3

-- 
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


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

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


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