[25712] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7952 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 7 18:05:38 2005

Date: Thu, 7 Apr 2005 15:05:13 -0700 (PDT)
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, 7 Apr 2005     Volume: 10 Number: 7952

Today's topics:
    Re: $line = <FH> returns incomplete lines <spamtrap@dot-app.org>
    Re: $line = <FH> returns incomplete lines <spamtrap@dot-app.org>
    Re: $line = <FH> returns incomplete lines <spamtrap@dot-app.org>
    Re: $line = <FH> returns incomplete lines <flavell@ph.gla.ac.uk>
        asynchronous system shell? <Ninja67@gmail.com>
    Re: asynchronous system shell? <1usa@llenroc.ude.invalid>
    Re: asynchronous system shell? <Ninja67@gmail.com>
    Re: asynchronous system shell? xhoster@gmail.com
    Re: asynchronous system shell? <Ninja67@gmail.com>
    Re: Basic Regular Expressions question... (Anno Siegel)
    Re: Basic Regular Expressions question... <noreply@gunnar.cc>
    Re: Bug in timelocal? <joe@inwap.com>
    Re: C++, Perl Embed,  and "Out of Memory during request (Anno Siegel)
    Re: Embperl question <Juha.Laiho@iki.fi>
    Re: Embperl question soup_or_power@yahoo.com
    Re: FAQ 3.10 Is there an IDE or Windows Perl Editor? (replace z with h, spam protection)
        Help with regular expression soup_or_power@yahoo.com
    Re: Help with regular expression <perl@my-header.org>
    Re: Help with regular expression <skuo@mtwhitney.nsc.com>
    Re: Help with regular expression <someone@example.com>
    Re: Help with regular expression <pilkowsk@informatik.uni-marburg.de>
    Re: OO and Inheritance WelkinConsulting@gmail.com
    Re: OO and Inheritance WelkinConsulting@gmail.com
    Re: OO and Inheritance <astrader@ecnext.com>
    Re: output-monitoring module (Anno Siegel)
    Re: output-monitoring module <henry.townsend@not.here>
    Re: output-monitoring module (Anno Siegel)
    Re: Perl CGI & File I/O Problem <joe@inwap.com>
    Re: Regular expression question. <nobull@mail.com>
        Windows fork emulation (and buffering?) problem <henry.townsend@not.here>
    Re: Windows fork emulation (and buffering?) problem <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 07 Apr 2005 16:27:44 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: $line = <FH> returns incomplete lines
Message-Id: <mbqdnbbN55VcCsjfRVn-uQ@adelphia.com>

robic@yahoo.com wrote:

> YAFPE - Yeah another fuckin perl expert... 

Don't worry little boy, if you work real hard and eat all your 
vegetables, you can grow up to be a Perl Expert too someday.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Thu, 07 Apr 2005 16:32:04 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: $line = <FH> returns incomplete lines
Message-Id: <mbqdnbHN55VYBcjfRVn-uQ@adelphia.com>

robic@yahoo.com wrote:

> Its like readin the funny papers Sinan, if its irrelavent
> to you....don't watch

Nonsense needs to be corrected for the sake of other newbies who might 
otherwise believe it.

 > I'll be posting along time and
> I won't be learning from you.

I have no doubt about that. You're obviously quite proud of your 
ignorance and have no desire to learn anything from anyone.

> Does that upset you....

Why should it? Your ignorance doesn't hurt me in the slightest.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Thu, 07 Apr 2005 16:33:36 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: $line = <FH> returns incomplete lines
Message-Id: <mbqdnbDN55W9BMjfRVn-uQ@adelphia.com>

robic@yahoo.com wrote:

> YARPA - Yet Another Rude prick Arriving,
> Yes your a rude prick. I gues its easy to arive on the thread in the
> middle of a technical discussion to just criticise without 
> contributing anything more than lesson on manners and le ignorance.
> Have a happy fuckin life asshole !!!

Do you have anything useful to say?

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Thu, 7 Apr 2005 21:37:41 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: $line = <FH> returns incomplete lines
Message-Id: <Pine.LNX.4.61.0504072136280.18419@ppepc56.ph.gla.ac.uk>

On Thu, 7 Apr 2005, Sherm Pendley wrote:

> robic@yahoo.com wrote:
> 
[nothing worth repeating, evidently]

> Do you have anything useful to say?

Happiness is a well-tended killfile.  Please do not feed the
troll to discerning usenauts (to mix a metaphor).


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

Date: 7 Apr 2005 11:50:46 -0700
From: "Ninja67" <Ninja67@gmail.com>
Subject: asynchronous system shell?
Message-Id: <1112899846.301076.98830@f14g2000cwb.googlegroups.com>

I have a perl script that is run on the web, that in turn, calls
another external program.

I can get the script to work, but the perl insists on waiting for the
external program to complete before completing the script.

The external program is not generating output that needs to be shown to
the user and it can take up to 2 minutes to run which is too long to
ask a web user to wait.

How do I tell perl to execute an external program and not wait for it
to complete before continuing with the perl?

I'm running on an Apache server using Unix.

Here's the code that launches the program...
system ("$sas $home/$pname.sas -log $home/$pname.log -print
$home/$pname.lst -sasuser $home -work $home >/dev/null 2>/dev/null");

I'm thinking there must be an easy modification to this call to tell
perl to keep on trucking.



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

Date: Thu, 07 Apr 2005 18:55:07 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: asynchronous system shell?
Message-Id: <Xns963197B51B599asu1cornelledu@127.0.0.1>

"Ninja67" <Ninja67@gmail.com> wrote in news:1112899846.301076.98830
@f14g2000cwb.googlegroups.com:

> I have a perl script that is run on the web, that in turn, calls
> another external program.
> 
> I can get the script to work, but the perl insists on waiting for the
> external program to complete before completing the script.

http://www.stonehenge.com/merlyn/LinuxMag/col39.html

> How do I tell perl to execute an external program and not wait for it
> to complete before continuing with the perl?
> 
> I'm running on an Apache server using Unix.
> 
> Here's the code that launches the program...
> system ("$sas $home/$pname.sas -log $home/$pname.log -print
> $home/$pname.lst -sasuser $home -work $home >/dev/null 2>/dev/null");

That's a little scary, opening a behemoth like SAS to the whole wild 
world.

perldoc perlsec

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

Date: 7 Apr 2005 12:24:55 -0700
From: "Ninja67" <Ninja67@gmail.com>
Subject: Re: asynchronous system shell?
Message-Id: <1112901895.040515.57550@f14g2000cwb.googlegroups.com>


A. Sinan Unur wrote:
> "Ninja67" <Ninja67@gmail.com> wrote in news:1112899846.301076.98830
> @f14g2000cwb.googlegroups.com:
>
> > I have a perl script that is run on the web, that in turn, calls
> > another external program.
> >
> > I can get the script to work, but the perl insists on waiting for
the
> > external program to complete before completing the script.
>
> http://www.stonehenge.com/merlyn/LinuxMag/col39.html

Wow, that's a lot of good information, but way over my head.  The
author of that page is showing how to keep track of a process that was
launched, but I can't tell how he actually launches it.  I'm fairly new
to perl, so I probably just don't know what to look for.  In my program
though, I don't care when the externally called application finishes.
I have no desire to monitor it whatsoever.  I simply want to call it
and let it go.

> > How do I tell perl to execute an external program and not wait for
it
> > to complete before continuing with the perl?
> >
> > I'm running on an Apache server using Unix.
> >
> > Here's the code that launches the program...
> > system ("$sas $home/$pname.sas -log $home/$pname.log -print
> > $home/$pname.lst -sasuser $home -work $home >/dev/null
2>/dev/null");
>
> That's a little scary, opening a behemoth like SAS to the whole wild
> world.
>
> perldoc perlsec

It would be, but the variables you see above have hard-coded values
assigned at the beginning of the script.  Also, this is on an internal
company server not available on the internet.



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

Date: 07 Apr 2005 20:46:08 GMT
From: xhoster@gmail.com
Subject: Re: asynchronous system shell?
Message-Id: <20050407164608.720$cC@newsreader.com>

"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote:
> "Ninja67" <Ninja67@gmail.com> wrote in news:1112899846.301076.98830
> @f14g2000cwb.googlegroups.com:
>
> > I have a perl script that is run on the web, that in turn, calls
> > another external program.
> >
> > I can get the script to work, but the perl insists on waiting for the
> > external program to complete before completing the script.

Add an "&" to the end. see:
perldoc -q background.

> > Here's the code that launches the program...
> > system ("$sas $home/$pname.sas -log $home/$pname.log -print
> > $home/$pname.lst -sasuser $home -work $home >/dev/null 2>/dev/null");
>
> That's a little scary, opening a behemoth like SAS to the whole wild
> world.

Not all servers are open to the whole wild world.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 7 Apr 2005 14:26:06 -0700
From: "Ninja67" <Ninja67@gmail.com>
Subject: Re: asynchronous system shell?
Message-Id: <1112909166.414433.63500@f14g2000cwb.googlegroups.com>


xhos...@gmail.com wrote:
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote:
> > "Ninja67" <Ninja67@gmail.com> wrote in news:1112899846.301076.98830
> > @f14g2000cwb.googlegroups.com:
> >
> > > I have a perl script that is run on the web, that in turn, calls
> > > another external program.
> > >
> > > I can get the script to work, but the perl insists on waiting for
the
> > > external program to complete before completing the script.
>
> Add an "&" to the end. see:
> perldoc -q background.

That worked!  You're a genius!  Now that sure was easy.  I wonder why
it was so hard to find anything on that.

Thanks again!



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

Date: 7 Apr 2005 11:06:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Basic Regular Expressions question...
Message-Id: <d3347q$ei5$1@mamenchi.zrz.TU-Berlin.DE>

Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> A. Sinan Unur wrote:
> > 
> >  \Q  Disable pattern metacharacters until \E
> > 
> > $thispage =~ s{\Q$find\E}{$replace};
> 
> Since escaping all the characters in PATTERN makes it a non-regex 
> problem, I played with using index() and substr() instead:
> 
>      substr $thisPage, index($thisPage, $find), length $find, $replace;
> 
> However, to take the /g modifier into consideration (which the OP 
> originally used), you seem to need something like:
> 
>      my ($i, $length) = (0,0);
>      while ( ( $i = index $thisPage, $find, $i+$length ) >= 0 ) {
>          $length = length $find;
>          substr $thisPage, $i, $length, $replace;
>      }
> 
> That's much typing to 'emulate'
> 
>      $thispage =~ s/\Q$find/$replace/g;

A bit tighter:

    my $i = -1;
    substr $thisPage, $i, length $find, $replace while
        ( $i = index $thisPage, $find, $i + 1) >= 0;

Anno


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

Date: Thu, 07 Apr 2005 22:35:53 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Basic Regular Expressions question...
Message-Id: <3blkk9F6js2hiU1@individual.net>

Anno Siegel wrote:
> Gunnar Hjalmarsson wrote:
>> However, to take the /g modifier into consideration (which the OP 
>> originally used), you seem to need something like:
>>
>>     my ($i, $length) = (0,0);
>>     while ( ( $i = index $thisPage, $find, $i+$length ) >= 0 ) {
>>         $length = length $find;
>>         substr $thisPage, $i, $length, $replace;
>>     }
>>
>> That's much typing to 'emulate'
>>
>>     $thispage =~ s/\Q$find/$replace/g;
> 
> A bit tighter:
> 
>     my $i = -1;
>     substr $thisPage, $i, length $find, $replace while
>         ( $i = index $thisPage, $find, $i + 1) >= 0;

Yeah, but I just realized that neither of the above index() + substr() 
solutions would work on e.g. this set of input:

     my $thisPage = "It's a ball. The ball is brown.";
     my $find = 'ball';
     my $replace = 'football';

Isn't it something like this that's needed:

     my $repl_length = length $replace;
     my $i = -$repl_length;
     while ( ( $i = index $thisPage, $find, $i + $repl_length ) >= 0 ) {
         substr $thisPage, $i, length $find, $replace;
     }

Maybe no wonder that the s/// operator is frequently used also for 
replacing non-regex patterns when efficiency is not a restriction.

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


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

Date: Thu, 07 Apr 2005 11:58:29 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Bug in timelocal?
Message-Id: <ipmdnZqcCKFJH8jfRVn-3A@comcast.com>

brian d foy wrote:
> In article <1112803332.554723.116710@z14g2000cwz.googlegroups.com>,
> yocoyote <yocoyote@gmail.com> wrote: 
> 
>>Here are the dates:   the diff is negative, which highlighted the issue
>>$MonthSTART = 04, $DaySTART = 02, $HourSTART = 02, $MinSTART = 47,
>>$SecSTART = 07
> 
> You're missing an hour on the day that daylight savings starts?
> That's odd.

Actually, missing an hour on the day that daylight savings started
four years ago, which is a different day of the month than this year.


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

Date: 7 Apr 2005 11:25:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: C++, Perl Embed,  and "Out of Memory during request..." Problem
Message-Id: <d335b6$f9q$1@mamenchi.zrz.TU-Berlin.DE>

 <sleepymish@gmail.com> wrote in comp.lang.perl.misc:
> Hi,
> 
> I have cygwin running on a P4 2.4 GHZ with 512 MB RAM machine. I also
> have perl 5.0.8 installed with my cygwin. I wrote a C++ application
> with perl embedded to do string matching for strings of about 256
> characters long. When I run the program I got the following error:
> 
> Out of memory during request for 1208 bytes, total sbrk() is 393910272
> bytes!
> 
> Anyone know what this error mean?

Pretty obvious, isn't it?  "Total sbrk()" means it has requested
(and been granted) 393910272 bytes up to that point.

> What happens is I have a huge html file, about 80MB big, and I wrote a
> parser in C++ to do string matching in the html file. Because Perl has
> such a powerful regular expression capability, I decided to use Perl
> instead of writing my own in C++.  So I use fget to get strings line by
> line from the html, then use perl to find any integer values in it. My

Can't you use one or more of strchr(), strtok() and strspn() to
locate integers?  Looks pretty simple to me.

> program works fine when the html file is 20MB or less.. but craps out
> when it's 80MB. BTW, I'm using STL Vector to store the strings matched
> from Perl.
> 
> Anyone know what might be the problem w/ the "OUt of memory error"? I'm
> trying to narrow it down to a perl or STL vector problem. After initial
> searching, I saw that other people with this error usu. orginates from
> perl.

It is easy to produce memory leaks when embedding or extending Perl.
Since you show no code, nothing more can be said.

Anno


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

Date: Thu, 7 Apr 2005 14:57:34 +0000 (UTC)
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Embperl question
Message-Id: <d33hou$vfg$1@ichaos.ichaos-int>

soup_or_power@yahoo.com said:
>
>Brian McCauley wrote:
>> soup_or_power@yahoo.com wrote:
>>
>> > Can someone please explain this sub taken out of embperl code. I am
>> > not sure what the Storable::thaw is doing.
>>
>> Rather than showing us the code where Storable::thaw is called it
>> would perhaps be more productive if you showed us the part of the
>> Storable documentation that you are finding hard to follow.
>
>Sorry I didn't mean to be lazy. Let me break it down:
>a)what is EMBPERL_SESSION_ARGS and where will one have to specify. Are
>they configured into apache?

From Embperl documentation (comes with Embperl, readable with command
"perldoc HTML::Embperl"):

       EMBPERL_SESSION_ARGS

       List of arguments for Apache::Session classes (see "Session handling")
       Arguments that contains spaces can be quoted.  Example:

         PerlSetEnv EMBPERL_SESSION_ARGS "DataSource=dbi:mysql:session UserName=www 'Password=secret word'"


>For example below:
>sub get_session_env {
>  my %args;
>  foreach ( split( /\s+/, $ENV{EMBPERL_SESSION_ARGS} ) ) {
>    /^(.*?)\s*=\s*(.*?)$/;
>    $args{$1} = $2;
>  }
>
>  return %args;
>}

So, the above gets whatever is stored into the environment variable named
EMBPERL_SESSION_ARGS, and places them into a hash (and returns the hash).
With the above example, the hash would contain name-value pairs:
DataSource => dbi:mysql:session
UserName => www
Password => secret word

>b)what is $ENV{EMBPERL_COOKIE_NAME} and why can it be defaulted as
>'EMBPERL_UID'

Again from included documentation:

       EMBPERL_COOKIE_NAME

       (only 1.2b4 or above) Set the name that Embperl uses when it sends the
       cookie with the session id.  Default is EMBPERL_UID.


>Bottom line is I couldn't find a book on embperl. If you can suggest a
>book I'll be grateful. 

You could start with the included documentation (also available at
http://perl.apache.org/embperl/pod/doc/doc13/HTML/Embperl.htm ), along with
the introductory material at http://perl.apache.org/embperl/pod/intro/ .
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: 7 Apr 2005 10:01:37 -0700
From: soup_or_power@yahoo.com
Subject: Re: Embperl question
Message-Id: <1112893297.897374.255130@o13g2000cwo.googlegroups.com>


Juha Laiho wrote:
> soup_or_power@yahoo.com said:
> So, the above gets whatever is stored into the environment variable
named
> EMBPERL_SESSION_ARGS, and places them into a hash (and returns the
hash).
> With the above example, the hash would contain name-value pairs:
> DataSource => dbi:mysql:session
> UserName => www
> Password => secret word
>
> >b)what is $ENV{EMBPERL_COOKIE_NAME} and why can it be defaulted as
> >'EMBPERL_UID'
>
> Again from included documentation:
>
>        EMBPERL_COOKIE_NAME
>
>        (only 1.2b4 or above) Set the name that Embperl uses when it
sends the
>        cookie with the session id.  Default is EMBPERL_UID.
>
>
> >Bottom line is I couldn't find a book on embperl. If you can suggest
a
> >book I'll be grateful.
>
> You could start with the included documentation (also available at
> http://perl.apache.org/embperl/pod/doc/doc13/HTML/Embperl.htm ),
along with
> the introductory material at
http://perl.apache.org/embperl/pod/intro/ .
> --
> Wolf  a.k.a.  Juha Laiho     Espoo, Finland
> (GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M
V
>          PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++
y++++
> "...cancel my subscription to the resurrection!" (Jim Morrison)

Many thanks for your clarification

Just curious, where are the session info fdat, udat, and mdat stored?
The code also resets the udat and fdat hashes. For instance:
"$fdat{"f|frequency"}="monthly". I thought the form data in fdat can't
be altered. While at it, what does the pipe (|) symbol mean?



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

Date: Thu, 7 Apr 2005 13:37:44 +0200
From: "D. Marxsen" <detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)>
Subject: Re: FAQ 3.10 Is there an IDE or Windows Perl Editor?
Message-Id: <d33606$qb1$1@news1.transmedia.de>

 ... my suggestion:

Add the editor "SciTE" (http://www.scintilla.org/SciTE.html) to the list. It
supports syntax highlighting and code folding. Perl and many other languages
are supported.

Just my two cents,

Detlef.

--
D. Marxsen, TD&DS GmbH
detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)




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

Date: 7 Apr 2005 10:16:13 -0700
From: soup_or_power@yahoo.com
Subject: Help with regular expression
Message-Id: <1112894173.409297.201010@f14g2000cwb.googlegroups.com>

I need help with this regex. It looks the keys of fdat are searched for
"$prefix" and fdat hash is deleted. I have no idea what the map is
trying to do. Thanks for your help.

 debug my %indices  = map { (/^\Q$prefix.\E(.+)/), $_ } grep { delete
$fdat{$_} } grep /^\Q$prefix.\E/, keys %fdat;



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

Date: Thu, 07 Apr 2005 20:04:03 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: Help with regular expression
Message-Id: <15sa51t8haqgvjd18cvvhq3hev53rcnh7h@4ax.com>

X-Ftn-To: soup_or_power@yahoo.com 

soup_or_power@yahoo.com wrote:
>I need help with this regex. It looks the keys of fdat are searched for
>"$prefix" and fdat hash is deleted. I have no idea what the map is
>trying to do. Thanks for your help.

map is producing hash pairs, where keys are striped %fdat keys (and values
are unmodified %fdat keys).

> debug my %indices  = map { (/^\Q$prefix.\E(.+)/), $_ } grep { delete
>$fdat{$_} } grep /^\Q$prefix.\E/, keys %fdat;

#untested
my %indices  = 
  map  { /^\Q$prefix.\E(.+)/, $_ }
  grep /^\Q$prefix./ && delete $fdat{$_},
  keys %fdat;

This is somehow shorter but..

my %indices  = 
  map {
    my $k = $_;
    s!^\Q$prefix.!! && delete $fdat{$k} ? ($_ => $k) : ();
  }
  keys %fdat;

 .. here we are using only one regex so it should be little faster if speed
counts.



-- 
Matija


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

Date: Thu, 7 Apr 2005 11:42:17 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Help with regular expression
Message-Id: <Pine.GSO.4.21.0504071136300.5789-100000@mtwhitney.nsc.com>

On 7 Apr 2005 soup_or_power@yahoo.com wrote:

> I need help with this regex. It looks the keys of fdat are searched for
> "$prefix" and fdat hash is deleted. I have no idea what the map is
> trying to do. Thanks for your help.
> 
>  debug my %indices  = map { (/^\Q$prefix.\E(.+)/), $_ } grep { delete
> $fdat{$_} } grep /^\Q$prefix.\E/, keys %fdat;
 


That's likely to be wrong as 'map' may return an odd number of elements
to %indices.  Perhaps the intent was something like this?

my %indices = 
    map { /^\Q$prefix.\E(.+)/ ? $1 : '' , $_ }
    grep { delete  $fdat{$_} }
    grep /^\Q$prefix.\E/,
    keys %fdat;                                   


That's still too obfuscated for my tastes.  I'd prefer:

my %indices;
my @keys_to_remove_from_fdat;
 
for my $k (keys %fdat)
{
    if ($k =~ /^\Q$prefix.\E(.*)/)
    {
	$indices{$1} = $k;
	push @keys_to_remove_from_fdat, $k;
    }
}

delete @fdat{@keys_to_remove_from_fdat};

-- 
Hope this helps,
Steven



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

Date: Thu, 07 Apr 2005 19:18:29 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Help with regular expression
Message-Id: <9If5e.3555$yV3.2584@clgrps12>

soup_or_power@yahoo.com wrote:
> I need help with this regex. It looks the keys of fdat are searched for
> "$prefix" and fdat hash is deleted. I have no idea what the map is
> trying to do. Thanks for your help.
> 
>  debug my %indices  = map { (/^\Q$prefix.\E(.+)/), $_ } grep { delete
> $fdat{$_} } grep /^\Q$prefix.\E/, keys %fdat;

Well, let's have a look:

john@perl john $ perl -le'use Data::Dumper;
my %x = qw/ abc.123 2 abc.234 3 abc.345 4 abc.456 5 abc.567 6 xyz.123 7 
xyz.234 8 xyz.345 9 /;
print Dumper \%x;
my $prefix = q/abc/;
my %y = map { (/^\Q$prefix.\E(.+)/), $_ } grep { delete $x{$_} } grep 
/^\Q$prefix.\E/, keys %x;
print Dumper \%x, \%y;
'
$VAR1 = {
           'xyz.345' => '9',
           'abc.123' => '2',
           'abc.456' => '5',
           'xyz.234' => '8',
           'abc.345' => '4',
           'abc.567' => '6',
           'xyz.123' => '7',
           'abc.234' => '3'
         };

$VAR1 = {
           'xyz.345' => '9',
           'xyz.234' => '8',
           'xyz.123' => '7'
         };
$VAR2 = {
           '345' => 'abc.345',
           '456' => 'abc.456',
           '123' => 'abc.123',
           '567' => 'abc.567',
           '234' => 'abc.234'
         };



John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 7 Apr 2005 22:24:43 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: Help with regular expression
Message-Id: <3blj81F6lipb5U1@individual.net>

* Steven Kuo schrieb:
> 
> That's still too obfuscated for my tastes.  I'd prefer:
> 
> my %indices;
> my @keys_to_remove_from_fdat;
> for my $k (keys %fdat) {
>     if ($k =~ /^\Q$prefix.\E(.*)/) {
>         $indices{$1} = $k;
>         push @keys_to_remove_from_fdat, $k;
>     }
> }
> delete @fdat{@keys_to_remove_from_fdat};

It seems that the values of the hash %indices are the same as the
elements of the array @keys_to_remove_from_fdat. You could write


    my %indices;
    for ( keys %fdat ) {
        $indices{$1} = $_ if /^\Q$prefix.\E(.*)/;
    }
    delete @fdat{ values %indices };


regards,
fabian


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

Date: 7 Apr 2005 07:46:01 -0700
From: WelkinConsulting@gmail.com
Subject: Re: OO and Inheritance
Message-Id: <1112885161.095264.71540@z14g2000cwz.googlegroups.com>

OK.  Let's say I read that book cover to cover (I have read bits and
pieces of it).  Which sections or concepts should I pay particular
attention to?

Thanks.

Andrew

Bob Walton wrote:
> WelkinConsulting@gmail.com wrote:
>
> > I have a question either about OO in general, or its implementation
in
> > Perl--I'm not sure which because I don't know enough.
> -----------------------------------^^^^^^^^^^^^^^^^^^^
> That can be remedied with the book "Object Oriented Perl" by Conway.
>
> ...
> > Andrew
> --
> Bob Walton
> Email: http://bwalton.com/cgi-bin/emailbob.pl
>
> ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet
News==----
> http://www.newsfeeds.com The #1 Newsgroup Service in the World!
120,000+ Newsgroups
> ----= East and West-Coast Server Farms - Total Privacy via Encryption
=----



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

Date: 7 Apr 2005 07:48:56 -0700
From: WelkinConsulting@gmail.com
Subject: Re: OO and Inheritance
Message-Id: <1112885336.548855.53060@f14g2000cwb.googlegroups.com>

Thanks.

I make calls like

my $browser = Net::Browser::InternetExplorer( $url );

presently--I just thought that passing in the browser variety would be
cleaner.


John Bokma wrote:
> wrote:
>
> > I have a question either about OO in general, or its implementation
in
> > Perl--I'm not sure which because I don't know enough.
> >
> > I've created the module Net::Browser::InternetExplorer.  It drives
an
> > IE instance.
> >
> > I want to eventually create modules for driving other
browsers--like
> > Net::Browser::FireFox .  I would like to be able to say, therefore:
> >
> > my $browser = Net::Browser->new( flavor => 'InternetExplorer', $URL
);
> >
> > or
> >
> > my $browser = Net::Browser->new( flavor => 'FireFox', $URL );
>
> Or
>
> my $browser = Net::Browser::Firefox( $url );
> my $browser = Net::Browser::InternetExplorer( $url );
>
> Is there a reason why you want to pass it as a parameter? If so, it
> sounds like you want to do something with plug ins, e.g.
>
> Otherwise, in the new of Net::Browser you try to use
> Net::Browser::YourBrowser, if ok, you call new, and return the
instance.
>
> > know which OO concept or catchphrase I should be looking for!
>
> Factory:
>
>
<http://www.vico.org/pages/PatronsDisseny/Pattern%20Abstract%20Factory/>
> <http://www.pasteur.fr/formation/infobio/python/ch18s06.html>
>
> --
> John                   Small Perl scripts: http://johnbokma.com/perl/
>                Perl programmer available:     http://castleamber.com/
>             Happy Customers: http://castleamber.com/testimonials.html



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

Date: 7 Apr 2005 12:27:23 -0700
From: "Andrew S" <astrader@ecnext.com>
Subject: Re: OO and Inheritance
Message-Id: <1112902043.772709.326520@f14g2000cwb.googlegroups.com>

Create a base class called Net::Browser::Base with default methods.
Then write Net::Browser::InternetExplorer to inherit from
Net::Browser::Base and override pertinent defaults. At that point you
can write Net::Browser::FireFox and override the defaults in different
ways.

Read all the Perl documentation on object oriented programming. Pay
attention to the parts that you understand. Then go back and read it
again, paying attention to the parts that you understand better in
light of your first reading. Then read it again. In between readings,
do as much programming as you can.



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

Date: 7 Apr 2005 10:22:52 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: output-monitoring module
Message-Id: <d331ls$csf$1@mamenchi.zrz.TU-Berlin.DE>

Henry Townsend  <henry.townsend@not.here> wrote in comp.lang.perl.misc:
> Please forgive me for asking here, I have done some searches and come up
> empty but I still think the module I need may have been written and want 
> to know for sure before I go trying to roll my own.
> 
> I'm thinking of writing a module which would monitor the output of any
> script which "use"d it looking for errors. E.g. something like this
> 
> use Output::Monitor STDOUT => qr/re1/, STDERR => qr/re2/;
> 
> This would - perhaps by using tied filehandles - watch all data flowing
> to stdout and stderr, apply the specified REs to each line, and convert
> the exit status to nonzero if any matches occur. The data would still be 
> delivered to the same place, just checked along the way.

You can do that using the standard module Tie::Handle:

    warn "blubb";  # processed normally
    tie *STDERR, 'Monitor', '>&STDERR';
    warn "glugg";  # prefixed with "monitored: "
    exit;

    package Monitor;
    use Tie::Handle;
    use base "Tie::StdHandle";

    sub WRITE {
        my $ob = shift;
        my ( $scalar, $length) = @_;
        $ob->SUPER::WRITE(
            "monitored: $scalar", length( "monitored: ") + $length
        );
    }

Note however that the ability of tying STDERR is new with Perl 5.8.1.
If you need it to work with an earlier version, use $SIG{ __DIE_} and
$SIG{ __WARN__}.

[snip]

Anno


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

Date: Thu, 07 Apr 2005 09:35:55 -0400
From: Henry Townsend <henry.townsend@not.here>
Subject: Re: output-monitoring module
Message-Id: <cI-dnZd-QMCoqsjfRVn-vQ@comcast.com>

Anno Siegel wrote:

> Henry Townsend  <henry.townsend@not.here> wrote in comp.lang.perl.misc:
>>This would - perhaps by using tied filehandles - watch all data flowing
>>to stdout and stderr, apply the specified REs to each line, and convert
>>the exit status to nonzero if any matches occur. The data would still be 
>>delivered to the same place, just checked along the way.
> 
> 
> You can do that using the standard module Tie::Handle:
> 
>     warn "blubb";  # processed normally
>     tie *STDERR, 'Monitor', '>&STDERR';
>     warn "glugg";  # prefixed with "monitored: "
>     exit;
> 
>     package Monitor;
>     use Tie::Handle;
>     use base "Tie::StdHandle";
> 
>     sub WRITE {
>         my $ob = shift;
>         my ( $scalar, $length) = @_;
>         $ob->SUPER::WRITE(
>             "monitored: $scalar", length( "monitored: ") + $length
>         );
>     }

Thanks. Unfortunately, as I should have made clearer, because I'm 
monitoring build scripts I need to inspect output flowing from 
subprocesses as well. J. Gleixner's pointer to Filter::Handle led to 
documentation indicating that ties can't handle this, and adding a

	system qw(/bin/cat /xx/yy/zz);

to your script shows as well that the error msg from cat is unmonitored.

I've made a stab at solving this using old-fashioned pipe/fork/wait 
semantics instead and have it almost working but with a problem which 
I'll take to a thread with a more appropriate subject line.

-- 
Thanks,
Henry Townsend


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

Date: 7 Apr 2005 14:48:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: output-monitoring module
Message-Id: <d33h81$mns$1@mamenchi.zrz.TU-Berlin.DE>

Henry Townsend  <henry.townsend@not.here> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > Henry Townsend  <henry.townsend@not.here> wrote in comp.lang.perl.misc:

> >>This would - perhaps by using tied filehandles - watch all data flowing
> >>to stdout and stderr, apply the specified REs to each line, and convert
> >>the exit status to nonzero if any matches occur. The data would still be 
> >>delivered to the same place, just checked along the way.
>
> > You can do that using the standard module Tie::Handle:

[snip code]

> Thanks. Unfortunately, as I should have made clearer, because I'm 
> monitoring build scripts I need to inspect output flowing from 
> subprocesses as well...

Sure, that's a show-stopper.  You need the Perl runtime system for
tied filehandles.

Anno


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

Date: Thu, 07 Apr 2005 11:50:20 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Perl CGI & File I/O Problem
Message-Id: <ipmdnZucCKFwHcjfRVn-3A@comcast.com>

Mike wrote:

> Is there something special I'm missing about using file IO in a CGI
> script?

Don't use die() unless you have ensured that the required HTTP
headers have been output first.

Be careful when using select() - it can redirect output that would have
gone to STDOUT.

Never attempt to access /dev/tty in a CGI program.

Post a short but complete program so that we can attempt to
reproduce your problem.

	-Joe


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

Date: 7 Apr 2005 09:51:11 -0700
From: "nobull@mail.com" <nobull@mail.com>
Subject: Re: Regular expression question.
Message-Id: <1112892671.355364.209550@o13g2000cwo.googlegroups.com>

John W. Krahn wrote:
> Brian McCauley wrote:
> > John W. Krahn wrote:
> >
> >> my $required_pattern = qr'(?:\|Line 4)';
> >
> > When there's no beniefit gained from using non-standard delimiters
> > it's best not to do so (IMNSHO).
>
> I used the single quotes to avoid interpolation.  :-)

There were no characters in that pattern that would be interpreted as
interpolation.

If you use m'' rather than // thoughout your code whenever you want a
regex but don't need interpolation then that would be perfectly
reasonable.

If you don't habitually use m'' then using qr'' seems inconsitent.



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

Date: Thu, 07 Apr 2005 09:50:19 -0400
From: Henry Townsend <henry.townsend@not.here>
Subject: Windows fork emulation (and buffering?) problem
Message-Id: <CJOdnXmZp9IJp8jfRVn-oA@comcast.com>

This problem involves forks and pipes. Take a look at this code:

pipe(OREADER, OWRITER) || die "$0: pipe(): $!";
my $pid = fork();
if ($pid) {
     print "parent\n";
     close OWRITER;
     print while(<OREADER>);
     print "done\n";
     wait;
} else {
     die "$0: Error: fork(): $!" if !defined($pid);
     print "child\n";
     close OREADER;
     open(STDOUT, ">&OWRITER") || die "$0: Error: STDOUT: $!";
     print "data to stdout\n";
}

On Unix it works correctly, printing:

child
parent
data to stdout
done

On Windows, using the emulated fork semantics it prints:

T:\>perl -w moo.pl
parent
child

and hangs. Upon Ctrl-C the message "Terminating on signal SIGINT(2)" is 
printed.

This is with Perl 5.8.6, ActiveState build 811. I've read "perldoc 
perlfork" and do not see a reason this should not work on Windows. I'm 
guessing there's a buffering problem. Pointers to help?

-- 
Thanks,
Henry Townsend


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

Date: Thu, 07 Apr 2005 14:35:39 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Windows fork emulation (and buffering?) problem
Message-Id: <Xns96316BBFCB4B0asu1cornelledu@127.0.0.1>

Henry Townsend <henry.townsend@not.here> wrote in 
news:CJOdnXmZp9IJp8jfRVn-oA@comcast.com:

> This problem involves forks and pipes. Take a look at this code:
> 
> pipe(OREADER, OWRITER) || die "$0: pipe(): $!";
> my $pid = fork();
> if ($pid) {
>      print "parent\n";
>      close OWRITER;
>      print while(<OREADER>);
>      print "done\n";
>      wait;
> } else {
>      die "$0: Error: fork(): $!" if !defined($pid);
>      print "child\n";
>      close OREADER;
>      open(STDOUT, ">&OWRITER") || die "$0: Error: STDOUT: $!";
>      print "data to stdout\n";
> }

Not an expert on how these things work, especially the whole dup thing, 
but I just checked,

#! /usr/bin/perl

use strict;
use warnings;

pipe my $reader, my $writer or die "Pipe failed: $!";

my $pid = fork();
if ($pid) {
    print "parent\n";
    close $writer;
    print "received: $_" while(<$reader>);
    print "done\n";
    wait;
} elsif(defined $pid) {
    print "child\n";
    close $reader;
    local(*STDOUT) = $writer;
    print "data to writer\n";
} else {
    die "Cannot fork: $!";
}
__END__

seems to do what you want on Windows.

That doesn't mean there is no bug, it might also be related to the 
warning against potential for deadlock in 

perldoc -f pipe

Dunno if this helps any.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

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 V10 Issue 7952
***************************************


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