[31171] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2416 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 14 16:09:53 2009

Date: Thu, 14 May 2009 13:09: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, 14 May 2009     Volume: 11 Number: 2416

Today's topics:
        [confused about the warn] childpsych.columbia@gmail.com
    Re: [confused about the warn] <smallpond@juno.com>
    Re: [confused about the warn] childpsych.columbia@gmail.com
    Re: [confused about the warn] <noreply@gunnar.cc>
    Re: [confused about the warn] childpsych.columbia@gmail.com
    Re: [confused about the warn] childpsych.columbia@gmail.com
    Re: [confused about the warn] childpsych.columbia@gmail.com
    Re: How do I turn a list of strings into a list of rege <mahurshi@gmail.com>
    Re: How do I turn a list of strings into a list of rege <bart.lateur@pandora.be>
    Re: How to replace c:\Program Files with Program Files  clearguy02@yahoo.com
    Re: How to replace c:\Program Files with Program Files  <noreply@gunnar.cc>
        jobs for you at home <adnanhameed750@gmail.com>
    Re: Launching 2 background processes with fork - how to derykus@gmail.com
    Re: Launching 2 background processes with fork - how to <glex_no-spam@qwest-spam-no.invalid>
        new CPAN modules on Thu May 14 2009 (Randal Schwartz)
    Re: s/(The N)e(urdsburg Affair)/$1$2/ looks dumb <placebo@dontbesilly.com>
    Re: s/(The N)e(urdsburg Affair)/$1$2/ looks dumb sln@netherlands.com
    Re: writing get_script as an external routine callable  <uri@PerlOnCall.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 14 May 2009 07:15:27 -0700 (PDT)
From: childpsych.columbia@gmail.com
Subject: [confused about the warn]
Message-Id: <e5551b36-bedf-4fd0-86c8-b47361f8b02d@r13g2000vbr.googlegroups.com>

Hi,

I am confused about the warn.
In the a project source code, I added some warn in aaa.pm, then the
warn information appear in the error_log.
but,
I added some warn in bbb.pm, the warn information does NOT appear in
the error_log.
I am sure the bbb.pm is executed.
Why?
Is there any warn switch or warn level? What's the debug/warn
information mechanism in mason+perl+apache?
Thank you very much.



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

Date: Thu, 14 May 2009 09:48:31 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: [confused about the warn]
Message-Id: <0c6d89d8-a610-424d-920e-5df80b40c8c2@21g2000vbk.googlegroups.com>

On May 14, 10:15 am, childpsych.colum...@gmail.com wrote:
> Hi,
>
> I am confused about the warn.
> In the a project source code, I added some warn in aaa.pm, then the
> warn information appear in the error_log.
> but,
> I added some warn in bbb.pm, the warn information does NOT appear in
> the error_log.
> I am sure the bbb.pm is executed.
> Why?
> Is there any warn switch or warn level? What's the debug/warn
> information mechanism in mason+perl+apache?
> Thank you very much.

See the docs for CGI::Carp


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

Date: Thu, 14 May 2009 12:03:02 -0700 (PDT)
From: childpsych.columbia@gmail.com
Subject: Re: [confused about the warn]
Message-Id: <24f55d19-c5ea-4d0b-8cf3-a1b8ae0c8add@g19g2000vbi.googlegroups.com>

On May 14, 12:48=A0pm, smallpond <smallp...@juno.com> wrote:
> On May 14, 10:15 am, childpsych.colum...@gmail.com wrote:
>
> > Hi,
>
> > I am confused about the warn.
> > In the a project source code, I added some warn in aaa.pm, then the
> > warn information appear in the error_log.
> > but,
> > I added some warn in bbb.pm, the warn information does NOT appear in
> > the error_log.
> > I am sure the bbb.pm is executed.
> > Why?
> > Is there any warn switch or warn level? What's the debug/warn
> > information mechanism in mason+perl+apache?
> > Thank you very much.
>
> See the docs for CGI::Carp

Thank you very much.
I google CGI::Carp,
It seems that it originally contains the Carp.

Now, I paste the two *.pm
(
 I add warn in Staff.pm, but the warn information does NOT appear in
the error_log.
 I add warn in mason.pm, the warn info does appear in the error_log.
)

First file is lib/Clinic/Party/Staff.pm
package Clinic::Party::Staff;
use strict;
use Carp;


use DBRX::Entity::Current '-isasubclass', (
  type_id =3D> 'S',
  type_name =3D> 'Staff',
  type_description =3D> 'The Staff entity tracks care providers and
support staff.',
);

Class::MakeMethods->make(
  'Template::Hash:scalar --eiffel' =3D> [
    qw(
        id fname lname login password
        email title degree gender
        ethnicity_id supervisor_id
        admin clinician status clinic
    ),
  ],
);

# fields to display on list view
sub list_columns {
  my $self =3D shift;
  my $columns =3D [
    {
      header =3D> 'Name',
      field =3D> sub {
        my $staff =3D shift;
        return "<a href=3D'/S/" . $staff->id . "'>" . $staff->value
('lname')->text . ', ' . $staff->value('fname')->text . "</a>";
      },
    },
    {
      header =3D> 'Email',
      field =3D> sub {
        my $email =3D shift->value('email');
        return $email->text if $email;
      },
    },
    {
      header =3D> 'Active',
      field =3D> sub {
        my $status =3D shift->value('status');
        my $a =3D $status->text if $status;
        if ( $a eq 'No' ) {
          $a =3D qq|<font color=3D"#000000">$a</font>|;
        } elsif ( $a eq 'Yes' ) {
          $a =3D qq|<font color=3D"#CC0000">$a</font>|;
        }
        return $a;
      },
    },
    {
      header =3D> 'Account Type',
      field =3D> sub {
        my $staff =3D shift;
        my $val =3D $staff->value('type');
        return $val->text if $val;
      },
    },
    {
      header =3D> 'Clinician',
      field =3D> sub {
        my $clinician =3D shift->value('clinician');
        return $clinician->text if $clinician;
      },
    },
    {
      header =3D> 'Supervisor',
      field =3D> sub {
        my $s =3D shift->value('supervisor');
        return $s->text if $s;
      },
    },

  ];
  return $columns;
}

sub detail_header {
  my $self =3D shift;
  my $path =3D shift;
  my $detail_header =3D $self->value( 'fname' )->text . ' ' . $self-
>value( 'lname' )->text . ', ' . $self->value( 'degree' )->text . '</
small>';

}

##

# Authentication

use Crypt::Simple passphrase =3D> 'pass phrase';





sub authenticate {

  my ( $self, $user, $pass ) =3D @_;
  my $enc_pass =3D encrypt($pass);
  my $staff =3D $self->fetch_one( { login =3D> $user, password =3D>
$enc_pass } ) || '';
  return unless $staff;
  return if $staff->value('type')->raw_int =3D=3D 663; # type:supervisor
  return unless $staff->status; # active
  return $staff->id;
}

sub decrypt_pass {
  my $self =3D shift;
  return decrypt( $self->password );
}
sub is_default_pass {
  my $staff =3D shift;
  my $enc_clinic =3D encrypt('abcdef');
  return 1 if $staff->password eq $enc_clinic;
  return 0;
}

sub is_password_expired {
  my $staff =3D shift;
  return 1 if $staff->days_since_last_password_change > 90; # CUTOFF
DAYS FOR PASS EXPIRATION
  return 0;
}


sub days_since_last_password_change {
  my $staff =3D shift;
  my $changes =3D DBRX::Entity::History->fetch( {
        entity_type_id =3D> 'S',
        entity_id =3D> $staff->id,
  } , [ 'id' ] );
  my $most_recent_pass_change =3D Quantity::Timestamp->current->value;
  foreach my $c ( @$changes ) {
    my $change_values =3D $c->values;
    foreach ( @$change_values ) {
      #warn Quantity::Timestamp->new($c->timestamp)->readable if $_-
>attribute_id =3D=3D 32;
      $_->{timestamp} =3D $c->timestamp;
      $most_recent_pass_change =3D $c->timestamp if $_->attribute_id =3D=3D
32;
    }
  }
  #warn Quantity::Timestamp->new($most_recent_pass_change)->readable;
  return ((Quantity::Timestamp->current->value -
$most_recent_pass_change) /
        ( 60 * 60 * 24 ) );
}

sub needs_to_change_password {
  my $staff =3D shift;
  return 1 if $staff->is_default_pass || $staff->is_password_expired;
  return 0;
}

##

sub last_session_time {
  my $user =3D shift;
  my $sql =3D 'select * from session where user_id =3D ' . $user->id . '
order by id desc limit 1';
  my $session =3D @{$user->fetch_sql( $sql )}[0];
  my $time =3D Quantity::Date->current;
  $time->set_udt( $session->{started} );
  return $time->readable;
}

sub name_link {
  my $staff =3D shift;
  return q{<a href=3D"/S/} . $staff->id . q{">} . $staff->value('name')-
>text . q{</a>};
}


1;




Second file is lib/Dixon/Mason.pm


package Dixon::Mason;

use strict;
use Carp;

use Apache::Constants qw( :response );
use HTML::Mason;

use Carp;

use Dixon::Session::Identifier;

########################################################################

use vars qw( $Interpreter $ApacheHandler $Session );

use Clinic::Site::Config;
my $server_root =3D Clinic::Site::Config->dir_path;

$Interpreter =3D HTML::Mason::Interp->new(
  parser =3D> HTML::Mason::Parser->new(),
  comp_root =3D> $server_root,
  data_dir =3D> "$server_root/var/mason",
  out_mode =3D> 'batch',
  # use_data_cache =3D> undef(),
  code_cache_max_size =3D> 0,
  # verbose_compile_error =3D> 1,
  dhandler_name =3D> 'dhandler',
);

use HTML::Mason::ApacheHandler (args_method=3D>'mod_perl');

$ApacheHandler =3D HTML::Mason::ApacheHandler->new(
  interp =3D> $Interpreter,
  error_mode =3D> 'fatal',
  decline_dirs =3D> 0,
  # error_mode =3D> 'html',
  # output_mode =3D> 'batch',
);

########################################################################

my @proxy_addrs =3D qw(  127.0.0.1  209.208.128.102  209.208.128.101  );

sub correct_proxy_address ($) {
  my $r =3D shift;

  # we'll only look at the X-Forwarded-For header if the requests
  # comes from our proxy at localhost
  my $remote =3D $r->connection->remote_ip;
  my $forward =3D $r->header_in('X-Forwarded-For');

  return Apache::Constants::OK
      unless ( $forward and grep { $remote eq $_ } @proxy_addrs );

  # Select last value in the chain -- original client's ip
  if ( my($ip) =3D ($forward =3D~ /([^,\s]+)$/) ) {
  $r->connection->remote_ip($ip);
  }

  return Apache::Constants::OK;
}

########################################################################

use HTTP::Date qw(time2str str2time);
use Time::HiRes;

sub content_handler {
  my $time =3D time();

  my ($r) =3D @_;

  my $uri =3D $r->uri();
  my $pid =3D $$;


  warn "Dixon::Mason content_handler for $uri\n";
  warn "Query String: " . substr( $r->args(), 0, 125 ) . "\n" if $r-
>args;

  $r->no_cache();
  $r->header_out("Expires" =3D> time2str($time - (60*60*3)));

  # CATCH ANNOYING REQUESTS
  # Added default.ida 2.15.2002
  # Added favico 8.1.2005
  # Added servlet/webacc 5.14.2006

  if ( $uri =3D~ /scripts/ or $uri =3D~ /\.exe/
        or $uri =3D~ /default.ida/ or $uri =3D~ /\.asp/
        or $uri =3D~ /\.dll/ or $uri =3D~ /favico/
        or $uri =3D~ /webacc/ or $uri =3D~ /vti/
  ) {
    $r->get_remote_host;
    #warn 'Inappropriate Request From: ' . $r->get_remote_host . ':' .
$r->get_remote_logname;
    return 'FORBIDDEN';
  }

  ### Session
  my ( $Session, $status );
  eval {
    local $SIG{ALRM} =3D sub { die "Timeout waiting for session $@" };
    alarm 45;

    $Session =3D Dixon::Session::Identifier->establish( $r );
    warn "Session: $Session->{public_id}\n";
    alarm 0;

    local $HTML::Mason::Commands::Session =3D $Session;

    $status =3D $ApacheHandler->handle_request($r);
  $time =3D time() - $time;
    warn "Mason ApacheHandler returned $status\n";
    warn "user_id:" . ( $Session->{user_id} || '(Not Logged In)' ) .
":page:$uri:time:$time\n\n";
  };
  die $@ if $@;
  return $status;
}

sub child_init_handler {
  # Make sure each Apache process has its own random numbers.
  srand();
  warn "Mason.pm.......................01";
  warn "Reconnecting to database...\n";
  warn "Mason.pm.......................02";
  DBRX::Framework->datasource->reconnect();
  warn "Mason.pm.......after reconnect()";
}

sub fixup_handler {
  my ($r) =3D @_;
  my $uri =3D $r->uri();
  warn "entering fixup handler for $uri";
  return DECLINED;
}

########################################################################

# $component =3D Dixon::Mason->fetch_component( $component_path );
sub fetch_component {
  my $class =3D shift;
  my $component_name =3D shift;

  $HTML::Mason::Commands::m->fetch_comp( $component_name )
    or Carp::confess("No such component '$component_name'");
}

# $component =3D Dixon::Mason->build_component( $mason_text );
sub build_component {
  my $class =3D shift;
  my $expr =3D shift;
  return $Interpreter->make_component( script =3D> $expr );
}

# $result =3D Dixon::Mason->eval_component( $mason_text, @arguments );
sub eval_component {
  my $class =3D shift;
  my $expr =3D shift;
  my $component =3D ref($expr) ? $expr :
                  $Interpreter->make_component( script =3D> $expr )
        or Carp::croak( "Can't interpret component '$expr'" );
  my $result =3D $HTML::Mason::Commands::m->scomp( $component, @_ );
  # warn "Eval '$expr' : '$result'\n";
  $result;
}
package HTML::Mason::Commands;

use vars qw( $Session $SessionID $SessionData $SessionEvent );
use Carp;
use Dixon::HTMLWriter qw[
        emit_uri emit_text emit_text_paras emit_tag
];

1;



Thank you very much.



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

Date: Thu, 14 May 2009 21:10:09 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: [confused about the warn]
Message-Id: <7738klF1fjegrU1@mid.individual.net>

childpsych.columbia@gmail.com wrote:
>  I add warn in Staff.pm, but the warn information does NOT appear in
> the error_log.

Try to uncomment the lines with the warn() statements.

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


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

Date: Thu, 14 May 2009 12:18:13 -0700 (PDT)
From: childpsych.columbia@gmail.com
Subject: Re: [confused about the warn]
Message-Id: <dbba17cd-a4b4-44bd-b6f2-e01164814b67@b1g2000vbc.googlegroups.com>

On May 14, 3:10=A0pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> childpsych.colum...@gmail.com wrote:
> > =A0I add warn in Staff.pm, but the warn information does NOT appear in
> > the error_log.
>
> Try to uncomment the lines with the warn() statements.
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl

Dear Gunnar,
What's your meaning?
I am sorry that I know nothing about the whole project source code.


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

Date: Thu, 14 May 2009 12:20:12 -0700 (PDT)
From: childpsych.columbia@gmail.com
Subject: Re: [confused about the warn]
Message-Id: <45114629-8f3f-4902-a041-3d8df9b0d80b@o20g2000vbh.googlegroups.com>

On May 14, 3:10=A0pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> childpsych.colum...@gmail.com wrote:
> > =A0I add warn in Staff.pm, but the warn information does NOT appear in
> > the error_log.
>
> Try to uncomment the lines with the warn() statements.
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl

Dear Gunnar,

What's your meaning?
I am sorry that I know nothing about the whole project source code.


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

Date: Thu, 14 May 2009 12:25:06 -0700 (PDT)
From: childpsych.columbia@gmail.com
Subject: Re: [confused about the warn]
Message-Id: <6e8194b0-5ce2-442c-a27d-9d6a7245ef37@z19g2000vbz.googlegroups.com>

On May 14, 3:10=A0pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> childpsych.colum...@gmail.com wrote:
> > =A0I add warn in Staff.pm, but the warn information does NOT appear in
> > the error_log.
>
> Try to uncomment the lines with the warn() statements.
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl

Actually,
I read the source code.
I found that the login.masn call the Staff->authenticate.
 the code is as follows:
 my $staff_id =3D Clinic::Party::Staff->authenticate( $username,
$pass );

So, I goto lib/Clinic/Party/Staff.pm, there is a sub authenticate.
I add a warn statement in the sub authenticate.
But it seems that the warn information does not appear in the
error_log.

Thank you very much.
Best,
Bruce


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

Date: Wed, 13 May 2009 22:36:34 -0700 (PDT)
From: Mahurshi Akilla <mahurshi@gmail.com>
Subject: Re: How do I turn a list of strings into a list of regexps?
Message-Id: <20010388-e980-4556-9349-2b6cd701cabd@w31g2000prd.googlegroups.com>

On May 13, 8:28=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Tad J McClellan <ta...@seesig.invalid>:
>
>
>
> > Mahurshi Akilla <mahur...@gmail.com> wrote:
> > > I want to turn a list of strings into a list of regexps. =A0Is there =
a
> > > build in module/easy algorithm to do this?
>
> > > ******original_list******
>
> > > string1
> > > string2
> > > string23
> > > string24
> > > anotherstring2
> > > anothertstring5
> > =A0 =A0 =A0 =A0 =A0^
> > =A0 =A0 =A0 =A0 =A0^
>
> > > ******processed_compressed_list******
>
> > > string*
> > > anotherstring*
>
> > All of these also match all of the strings above...
>
> In fact, looking at it again, neither of the patterns given will match
> any of the given strings... they only match things like
>
> =A0 =A0 strin
> =A0 =A0 string
> =A0 =A0 stringg
> =A0 =A0 stringgg
>
> :)
>
> Ben


Assume there is a ^ in front of every regexp

string
string1
string2
anotherstring2
anotherstring4234

should return something like:

string*
anotherstring*


Again, for "*" .. I don't care if it returns .* or * or [0-9]+ .. I am
only looking for a "collapsed" list of fewer elements.  I believe
simply returning a "*" would be easier and is good enough for what I
am trying to do. :-)


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

Date: Thu, 14 May 2009 09:00:03 +0200
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: How do I turn a list of strings into a list of regexps?
Message-Id: <71gn055oafpes391gjqp3jkjh30cto74j1@4ax.com>

Mahurshi Akilla wrote:

>I want to turn a list of strings into a list of regexps.  Is there a
>build in module/easy algorithm to do this?
>
>******original_list******
>
>string1
>string2
>string23
>string24
>anotherstring2
>anothertstring5
>
>******processed_compressed_list******
>
>string*
>anotherstring*

That looks more like a list of glob patterns, than like a regexp.

Anyway, there's more than one module that does something somewhat like
what you want, for example, Regex::PreSuf.

Test output:

	use Regex::PreSuf;
	print presuf(qw(
	string1
	string2
	string23
	string24
	anotherstring2
	anotherstring5
	));

Output:

	(?:anotherstring[25]|string(?:2[34]|[12]))


You could choose to postprocess it, replacing the character classes with
a simpler pattern, or you could use the source of the module as a basis
to write your own routine.

-- 
	Bart.


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

Date: Thu, 14 May 2009 10:38:05 -0700 (PDT)
From: clearguy02@yahoo.com
Subject: Re: How to replace c:\Program Files with Program Files (x86) in all  scripts?
Message-Id: <b7cb0fd3-a67f-4fba-b0b9-e87ff71aceb0@d38g2000prn.googlegroups.com>

On May 13, 7:36=A0pm, l v <veatc...@yahoo.com> wrote:
> cleargu...@yahoo.com wrote:
> > Hi experts,
>
> > I have a parent folder, C:\Test and it has a few sub-folders (and its
> > files) and files and I am now forced to do the following change in all
> > files starting from its parent folder, c:\Test
>
> > To replace a string, "c:\\program files\" or "c:\PROGRA~1" with "C:\
> > \Program Files (x86)" in all files.
>
> > Here is some thing I am trying with:
>
> > C:\>perl -i.bak -pe "s/Progra~1/Program Files (x86)/g" `find "C:\
> > \Test" -type f -name "*.pl" `
>
> > Error is:
> > Can't open `find: No such file or directory.
> > Can't do inplace edit: C:\\Test is not a regular file.
> > Can't open -type: No such file or directory.
> > Can't open f: No such file or directory.
> > Can't open -name: No such file or directory.
> > Can't open *.pl`: Invalid argument.
>
> > When I run the find command (find C:\Test -type f -name "*.pl" ), it
> > is returning the correct set of files, but it not working with the
> > perl commandline.
>
> > Where am I doing wrong?
>
> > --J
>
> Assuming windows. =A0Try the following on a single line.
>
> for %F in (*.pl) do perl -i.bak -pe "s/Progra~1/Program Files (x86)/g" "%=
F"
>
> --
>
> Len

It looks goods Len.. thanks a bunch. But what if I have to address a
few sub-folders within c:\TEST folder?


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

Date: Thu, 14 May 2009 20:51:17 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to replace c:\Program Files with Program Files (x86) in all scripts?
Message-Id: <7737h9F1e46lpU1@mid.individual.net>

clearguy02@yahoo.com wrote:
> I have a parent folder, C:\Test and it has a few sub-folders (and its
> files) and files and I am now forced to do the following change in all
> files starting from its parent folder, c:\Test
> 
> To replace a string, "c:\\program files\" or "c:\PROGRA~1" with "C:\
> \Program Files (x86)" in all files.

Why would you need to do that? I thought that Windows was not case 
sensitive.

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


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

Date: Thu, 14 May 2009 07:08:39 -0700 (PDT)
From: adnan ji <adnanhameed750@gmail.com>
Subject: jobs for you at home
Message-Id: <1354205c-00b7-47d4-a269-426d884c0691@i28g2000prd.googlegroups.com>


free jobs at your home free for you just more visit www.mmtfpk.blogspot.com


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

Date: Thu, 14 May 2009 06:28:10 -0700 (PDT)
From: derykus@gmail.com
Subject: Re: Launching 2 background processes with fork - how to make wait()  work?
Message-Id: <5653ee00-ef5c-471a-afe5-7f4b07a38128@j9g2000prh.googlegroups.com>

On May 13, 9:16=A0am, mrstevegross <mrstevegr...@gmail.com> wrote:
> Hi folks. I need to launch two "background" processes and wait for
> them both to finish before proceeding. I have followed the advice
> elsewhere on this forum to use the fork & wait solution. Here's what I
> have so far:
>
> =A0 my $proc1_pid =3D fork;
> =A0 if(not $proc1_pid) {
> =A0 =A0 exec("proc1");
> =A0 }
> =A0 my $proc2_pid =3D fork;
> =A0 if(not $proc2_pid) {
> =A0 =A0 exec("proc1");
> =A0 }
> =A0 wait();
   ^^^^^^^^

As mentioned briefly in one of the responses, you can also wait-block
on those 2 specific pids:

waitpid($proc1_pid, 0); # perldoc -f waitpid
waitpid($proc2_pid, 0);

However, you'll usually want to use the non-
blocking WNOHANG to reap them asynchronously.
You may need to check $? child status too if
that impacts proceeding to doSomething().

--
Charles DeRykus


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

Date: Thu, 14 May 2009 14:21:01 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Launching 2 background processes with fork - how to make wait() work?
Message-Id: <4a0c6f1e$0$89865$815e3792@news.qwest.net>

mrstevegross wrote:
> Hi folks. I need to launch two "background" processes and wait for
> them both to finish before proceeding. I have followed the advice
> elsewhere on this forum to use the fork & wait solution. Here's what I
> have so far:
> 
>   my $proc1_pid = fork;
>   if(not $proc1_pid) {
>     exec("proc1");
>   }
>   my $proc2_pid = fork;
>   if(not $proc2_pid) {
>     exec("proc1");
>   }
>   wait();
>   doSomething();
> 
> Unfortunately, wait() doesn't appear to work--the doSomething() line
> is processed immediately, even though proc1 and proc2 have not
> terminated.
> 
> Am I doing something wrong? Is there something quirky about having two
> background processes instead of one?

Take a look at using Parallel::ForkManager.  Might be a little
much for only two processes, but it makes running things in
parallel very easy.


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

Date: Thu, 14 May 2009 04:42:27 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu May 14 2009
Message-Id: <KJMAEr.1yqo@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.

Acme-PM-Paris-Meetings-0.01
http://search.cpan.org/~dolmen/Acme-PM-Paris-Meetings-0.01/
Get the date/time of the next Paris.pm meeting! 
----
Apache2-WURFLFilter-2.01
http://search.cpan.org/~ifuschini/Apache2-WURFLFilter-2.01/
is a Apache Mobile Filter that give any information about the capabilities of the devices as environment variable 
----
Apache2-WURFLFilter-2.02
http://search.cpan.org/~ifuschini/Apache2-WURFLFilter-2.02/
is a Apache Mobile Filter that give any information about the capabilities of the devices as environment variable 
----
Carp-Clan-Share-0.013
http://search.cpan.org/~rkrimen/Carp-Clan-Share-0.013/
Share your Carp::Clan settings with your whole Clan 
----
Catalyst-Devel-1.15
http://search.cpan.org/~flora/Catalyst-Devel-1.15/
Catalyst Development Tools 
----
Catalyst-Plugin-Session-0.22
http://search.cpan.org/~bobtfish/Catalyst-Plugin-Session-0.22/
Generic Session plugin - ties together server side storage and client side state required to maintain session data. 
----
Catalyst-Plugin-Session-State-Cookie-0.11
http://search.cpan.org/~bobtfish/Catalyst-Plugin-Session-State-Cookie-0.11/
Maintain session IDs using cookies. 
----
Catalyst-Plugin-Session-Store-FastMmap-0.10
http://search.cpan.org/~bobtfish/Catalyst-Plugin-Session-Store-FastMmap-0.10/
FastMmap session storage backend. 
----
Catalyst-Plugin-SmartURI-0.034
http://search.cpan.org/~rkitover/Catalyst-Plugin-SmartURI-0.034/
Configurable URIs for Catalyst 
----
Chart-Clicker-2.31
http://search.cpan.org/~gphat/Chart-Clicker-2.31/
Powerful, extensible charting. 
----
Config-Divide-0.01
http://search.cpan.org/~hirafoo/Config-Divide-0.01/
config loader like Catalyst::Plugin::ConfigLoader. 
----
Config-JFDI-0.05_1
http://search.cpan.org/~rkrimen/Config-JFDI-0.05_1/
Just * Do it: A Catalyst::Plugin::ConfigLoader-style layer over Config::Any 
----
Convert-X509-0.3
http://search.cpan.org/~leo/Convert-X509-0.3/
interface module to help analizing X509 data 
----
DBIx-Locker-0.091340
http://search.cpan.org/~rjbs/DBIx-Locker-0.091340/
locks for db resources that might not be totally insane 
----
DateTime-TimeZone-HPUX-0.08
http://search.cpan.org/~dolmen/DateTime-TimeZone-HPUX-0.08/
Handles timezones defined at the operating system level on HP-UX 
----
Dist-Zilla-Plugin-Repository-0.07
http://search.cpan.org/~fayland/Dist-Zilla-Plugin-Repository-0.07/
Automatically sets repository URL from svn/svk/Git checkout for Dist::Zilla 
----
Elive-0.17
http://search.cpan.org/~warringd/Elive-0.17/
Elluminate Live (c) client library 
----
File-AtomicWrite-0.93
http://search.cpan.org/~jmates/File-AtomicWrite-0.93/
writes files atomically via rename() 
----
File-LibMagic-0.94
http://search.cpan.org/~fitzner/File-LibMagic-0.94/
Perlwrapper for libmagic (file-4.x or file-5.x) 
----
Flickr-Simple2-0.03
http://search.cpan.org/~jfroebe/Flickr-Simple2-0.03/
A XML::Simple based Perl Flickr API. 
----
HTML-Truncate-0.19
http://search.cpan.org/~ashley/HTML-Truncate-0.19/
(beta software) truncate HTML by percentage or character count while preserving well-formedness. 
----
HTML-TurboForm-0.39
http://search.cpan.org/~camelcase/HTML-TurboForm-0.39/
----
IO-1.25
http://search.cpan.org/~gbarr/IO-1.25/
load various IO modules 
----
IO-AIO-Util-0.07
http://search.cpan.org/~gray/IO-AIO-Util-0.07/
useful functions missing from IO::AIO 
----
IPC-Exe-1.008
http://search.cpan.org/~glai/IPC-Exe-1.008/
Execute processes or Perl subroutines & string them via IPC. Think shell pipes. 
----
JavaScript-Beautifier-0.08
http://search.cpan.org/~fayland/JavaScript-Beautifier-0.08/
Beautify Javascript (beautifier for javascript) 
----
JavaScript-Lite-0.02
http://search.cpan.org/~crakrjack/JavaScript-Lite-0.02/
Bare-bones interface to SpiderMonkey ECMAscript API 
----
JavaScript-Lite-0.03
http://search.cpan.org/~crakrjack/JavaScript-Lite-0.03/
Bare-bones interface to SpiderMonkey ECMAscript API 
----
Log-Log4perl-1.23
http://search.cpan.org/~mschilli/Log-Log4perl-1.23/
Log4j implementation for Perl 
----
Math-Decimal-0.000
http://search.cpan.org/~zefram/Math-Decimal-0.000/
arithmetic in decimal 
----
Module-Install-0.88
http://search.cpan.org/~adamk/Module-Install-0.88/
Standalone, extensible Perl module installer 
----
Module-Install-AutomatedTester-0.02
http://search.cpan.org/~bingos/Module-Install-AutomatedTester-0.02/
A Module::Install extension to detect whether we are being tested by CPAN Testers. 
----
Module-Install-Repository-0.05
http://search.cpan.org/~miyagawa/Module-Install-Repository-0.05/
Automatically sets repository URL from svn/svk/Git checkout 
----
Moose-0.79
http://search.cpan.org/~drolsky/Moose-0.79/
A postmodern object system for Perl 5 
----
MooseX-MethodAttributes-0.10
http://search.cpan.org/~bobtfish/MooseX-MethodAttributes-0.10/
code attribute introspection 
----
Net-Axigen-0.10
http://search.cpan.org/~itmfrolov/Net-Axigen-0.10/
Perl extension for Gecad Technologies Axigen Mail Server (www.axigen.com). This module use Axigen CLI interface. 
----
Net-Libdnet-0.92
http://search.cpan.org/~gomor/Net-Libdnet-0.92/
binding for Dug Song's libdnet 
----
Net-Lookup-DotTel-0.03
http://search.cpan.org/~zebaz/Net-Lookup-DotTel-0.03/
Look up information related to a .tel domain name (or possible another domain name having .tel-style TXT and NAPTR records). 
----
Net-SFTP-Foreign-1.52_07
http://search.cpan.org/~salva/Net-SFTP-Foreign-1.52_07/
SSH File Transfer Protocol client 
----
Net-SFTP-Server-0.02
http://search.cpan.org/~salva/Net-SFTP-Server-0.02/
Base class for writting SFTP servers 
----
PDL-2.4.4_01
http://search.cpan.org/~chm/PDL-2.4.4_01/
the Perl Data Language 
----
Params-Classify-0.007
http://search.cpan.org/~zefram/Params-Classify-0.007/
argument type classification 
----
Parse-Stallion-0.82
http://search.cpan.org/~arthur/Parse-Stallion-0.82/
EBNF based regexp backtracking parser and tree evaluator. 
----
Sane-0.03
http://search.cpan.org/~ratcliffe/Sane-0.03/
Perl extension for the SANE (Scanner Access Now Easy) Project 
----
Scalar-List-Utils-1.20
http://search.cpan.org/~gbarr/Scalar-List-Utils-1.20/
----
Statistics-Descriptive-2.9
http://search.cpan.org/~shlomif/Statistics-Descriptive-2.9/
Module of basic descriptive statistical functions. 
----
String-Tagged-0.03
http://search.cpan.org/~pevans/String-Tagged-0.03/
string buffers with value tags on extents 
----
Sys-RunAlone-0.09
http://search.cpan.org/~elizabeth/Sys-RunAlone-0.09/
make sure only one invocation of a script is active at a time 
----
Task-Module-Install-BINGOS-1.00
http://search.cpan.org/~bingos/Task-Module-Install-BINGOS-1.00/
A Task to install all BINGOS' Module::Install extensions 
----
Test-Aggregate-0.35_02
http://search.cpan.org/~ovid/Test-Aggregate-0.35_02/
Aggregate *.t tests to make them run faster. 
----
Test-Run-0.0119
http://search.cpan.org/~shlomif/Test-Run-0.0119/
a new and improved test harness for TAP scripts. 
----
Text-RewriteRules-0.19
http://search.cpan.org/~ambs/Text-RewriteRules-0.19/
A system to rewrite text using regexp-based rules 
----
TheOneRing-0.3
http://search.cpan.org/~hardaker/TheOneRing-0.3/
A high level perl class to bind all VCs together 
----
Tie-Hash-ReadonlyStack-0.1
http://search.cpan.org/~dmuey/Tie-Hash-ReadonlyStack-0.1/
Treat multiple hashes as a single hash and do not modify original hashes when assigning values 
----
Tie-Quicksort-Lazy-0.02
http://search.cpan.org/~davidnico/Tie-Quicksort-Lazy-0.02/
a lazy quicksort with tiearray interface 
----
XML-Easy-0.003
http://search.cpan.org/~zefram/XML-Easy-0.003/
XML processing with a clean interface 
----
XML-TreePP-XMLPath-0.52
http://search.cpan.org/~rglaue/XML-TreePP-XMLPath-0.52/
Something similar to XPath, allowing definition of paths to XML subtrees 
----
ZConf-GUI-0.0.0
http://search.cpan.org/~vvelox/ZConf-GUI-0.0.0/
A GUI backend chooser. 
----
ack-1.89_02
http://search.cpan.org/~petdance/ack-1.89_02/
grep-like text finder 


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: Thu, 14 May 2009 10:01:18 GMT
From: "Peter Wyzl" <placebo@dontbesilly.com>
Subject: Re: s/(The N)e(urdsburg Affair)/$1$2/ looks dumb
Message-Id: <OZROl.10931$y61.8658@news-server.bigpond.net.au>

<jidanni@jidanni.org> wrote in message news:87precs81f.fsf@jidanni.org...
> Sure I can do
> s/(The N)e(urdsburg Affair)/$1$2/;
> but something tells me that there ought to be a smarter looking way to
> get the same functionality. Something like
> s/The N(e)urdsburg Affair/... but what?

Why not just s/Neurdsburg/Nurdsburg/; ?

P 




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

Date: Thu, 14 May 2009 12:58:50 -0700
From: sln@netherlands.com
Subject: Re: s/(The N)e(urdsburg Affair)/$1$2/ looks dumb
Message-Id: <i6to05dq65kplef5an75odqpa23neosphf@4ax.com>

On Thu, 14 May 2009 11:00:28 +0800, jidanni@jidanni.org wrote:

>Sure I can do
>s/(The N)e(urdsburg Affair)/$1$2/;
>but something tells me that there ought to be a smarter looking way to
>get the same functionality. Something like
>s/The N(e)urdsburg Affair/... but what?

This is not a suitable example of the use of regular expression
substitution. Regular expressions are not used for in-line
spelling corrections, especially for book/movie titles.
Unless you want to do a million different regular expressions
from pos() = 0, substitutions are something that should be used
possibly multiple times.

The regular expression 'substitution' idiom is valid as always.
Its up to you how its used. 

The rule is only use as much as necessary to uniquely describe what you are
looking for in the target string. This possibly reduces the search
overhead. But the entire match will be affected with whatever you
direct on the substitution.

-sln


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

Date: Thu, 14 May 2009 00:17:04 -0400
From: "Uri Guttman" <uri@PerlOnCall.com>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <87hbzomi7z.fsf@quad.sysarch.com>

>>>>> "BM" == Ben Morrow <ben@morrow.me.uk> writes:

  >> my $filename = 'book1.txt';
  >> open(my $fh, '<', $filename) or 
  >> die "cannot open $filename for reading: $!";
  >> my @books;

  BM>     chomp( my @books = <$fh> );

  BM> If you prefer, you can expand that to three statements:

  BM>     my @books;
  BM>     @books = <$fh>;
  BM>     chomp @books;

  BM> You can also use File::Slurp::read_file, which will handle opening the
  BM> file, chomping the lines and closing the file for you.

read_file doesn't (yet) chomp lines. that option is in the todo
list. but it does make it easier to read in a file as lines. this should
work fine:

use File::Slurp ;
chomp( my @books = read_file( $file_name ) ) ;

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

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


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