[19685] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1880 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 5 14:10:47 2001

Date: Fri, 5 Oct 2001 11:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1002305412-v10-i1880@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 5 Oct 2001     Volume: 10 Number: 1880

Today's topics:
    Re: Multiplexing strings <joe+usenet@sunstarsys.com>
    Re: Multiplexing strings (Abigail)
    Re: Multiplexing strings <dtweed@acm.org>
    Re: Multiplexing strings (Abigail)
    Re: Multiplexing strings (Randal L. Schwartz)
    Re: Multiplexing strings <JPFauvelle@Colt-Telecom.fr>
    Re: Multiplexing strings <JPFauvelle@Colt-Telecom.fr>
    Re: Multiplexing strings <darkon@one.net>
        oop question <jens@irs-net.com>
    Re: Perl Guru needed for this extremely frustrating sea (Dan Boyce)
        Perl on Soalris > need help with install <nclarke@mindspring.com>
    Re: Perl on Soalris > need help with install <djberge@qwest.com>
    Re: Perl on Soalris > need help with install <thomas@baetzler.de>
        Reformat Chain (Houda Araj)
    Re: Reformat Chain <thomas@baetzler.de>
    Re: resetting variables nobull@mail.com
    Re: seconds since epoch to normal date (Mark Jason Dominus)
    Re: splitting a very wide report gls@byu.edu
        strangeness (bug?) in regexp handling <vvv@vsu.ru>
    Re: strangeness (bug?) in regexp handling <thomas@baetzler.de>
    Re: strangeness (bug?) in regexp handling <davidhilseenews@yahoo.com>
        Taint aware tree (Miko O'Sullivan)
    Re: Trapping sendmail errors (with eval?) nobull@mail.com
    Re: Uninstall under Windows ME (Mike Filippo)
    Re: Uninstall under Windows ME <thomas@baetzler.de>
    Re: what am I doing wrong ? (JR)
    Re: Yet another fork question <uri@sysarch.com>
    Re: Yet another fork question (Villy Kruse)
    Re: Yet another fork question (Randal L. Schwartz)
    Re: Yet another fork question <uri@sysarch.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 05 Oct 2001 11:06:36 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Multiplexing strings
Message-Id: <m3adz6i0sj.fsf@mumonkan.sunstarsys.com>

Dave Tweed <dtweed@acm.org> writes:

>     'swrite' => sub {
>         $out = swrite("^<^<^<~~", $str1, $str2, $str3);
>     },
>     'inline' => sub {
>         $^A = "";
>         formline("^<^<^<~~", $str1, $str2, $str3);
>         $out = $^A;


The way you've written it, both 'swrite' and 'inline' will 
wipe-out the $str* variables (the picture's "~~" does that).  
You need to first copy them to temporary variables, like

  $out = swrite("^<^<^<~~", @tmp=($str1, $str2, $str3))

-- 
Joe Schaefer    "I don't give a damn for a man that can only spell a word one
                                            way."
                                               --Mark Twain



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

Date: 5 Oct 2001 15:35:04 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Multiplexing strings
Message-Id: <slrn9rrkm6.c4h.abigail@alexandra.xs4all.nl>

Damian James (damian@qimr.edu.au) wrote on MMCMLVII September MCMXCIII in
<URL:news:slrn9rq1ph.nup.damian@puma.qimr.edu.au>:
'' On 4 Oct 2001 15:46:21 -0700, Dimitri said:
'' >I have N=3 strings of equal length, and I want to multiplex them by taking
'' >M=2 characters from each string (the length of each string is divisible by
'' >M). Example :
'' >
'' >Input:
'' >
'' >$str1 = "aabbccddeeff";
'' >$str2 = "AABBCCDDEEFF";
'' >$str3 = "001122334455";
'' >
'' >Output :
'' >
'' >$out = "aaAA00bbBB11ccCC22ddDD33eeEE44ffFF55";
'' >
'' >Besides the obvious for loop :
'' >
'' >$out = ""; $len = length($str1);
'' >
'' >for ($i = 0; $i < $len; $i += 2) {
'' > $out .= substr($str1, $i, 2) . substr($str2, $i, 2) . substr($str3, $i, 2);
'' >}
'' >
'' >Is there a more elegant (faster) way?
'' 
'' Don't know about faster, certainly less memory efficient, but in any case
'' a workable Other Way To Do It:
'' 
'' #!/usr/bin/perl 
'' use warnings;
'' use strict;
'' 
'' my @str = qw ( aabbccddeeff AABBCCDDEEFF 001122334455 );
'' my @seq = map { [ /(..)/g ] } @str;
'' my $out = join '',
'' 		  map {  $seq[0]->[$_], $seq[1]->[$_], $seq[2]->[$_] }
''           0..5;
'' print "$out\n";
'' 
'' I'm sure someone can think of a neater way to handle that map().



#!/opt/perl/bin/perl -wl

use strict;

my $M = 2;

print sub {
          my $s = "";
          {
              $s .= shift @{$_ [0]};
              push @_ => shift;
              redo if @{$_ [0]};
          }
          $s} -> (map {[/.{$M}/g]} qw {aabbccddeeff AABBCCDDEEFF 001122334455});


__END__


Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
__END__
A butterfly flying // above a pool. A darting // goldfish. A fox.


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

Date: Fri, 05 Oct 2001 15:36:34 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: Multiplexing strings
Message-Id: <3BBDD231.A3850C85@acm.org>

Joe Schaefer wrote:
> The way you've written it, both 'swrite' and 'inline' will
> wipe-out the $str* variables (the picture's "~~" does that).
> You need to first copy them to temporary variables, like
> 
>   $out = swrite("^<^<^<~~", @tmp=($str1, $str2, $str3))

Ah. That's better. Thanks. Now I get:

~/temp/perl>perl mux.pl
          Rate  split swrite substr inline
split  11039/s     --   -59%   -66%   -70%
swrite 26940/s   144%     --   -17%   -28%
substr 32392/s   193%    20%     --   -13%
inline 37256/s   237%    38%    15%     --

~/temp/perl>perl mux.pl 10
         Rate  split substr swrite inline
split  1114/s     --   -67%   -79%   -81%
substr 3340/s   200%     --   -39%   -42%
swrite 5431/s   387%    63%     --    -6%
inline 5803/s   421%    74%     7%     --

~/temp/perl>perl mux.pl 100
        Rate  split substr swrite inline
split  119/s     --   -67%   -82%   -82%
substr 366/s   207%     --   -45%   -45%
swrite 664/s   456%    81%     --    -0%
inline 665/s   457%    82%     0%     --

-- Dave Tweed


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

Date: 5 Oct 2001 15:37:30 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Multiplexing strings
Message-Id: <slrn9rrkqu.c4h.abigail@alexandra.xs4all.nl>

Dave Tweed (dtweed@acm.org) wrote on MMCMLVII September MCMXCIII in
<URL:news:3BBD9BD4.86060ABA@acm.org>:
`' Joe Schaefer wrote:
`' > Wins what?  I didn't realize there was a prize to be had for
`' > avoiding subroutine calls in the solution.
`' 
`' The OP asked, "Is there a more elegant (faster) way?"


Which is a silly question to ask, as it's unclear what the OP wants.
Elegance, or speed? Elegance not always gives the best speed, nor 
does speed often lead to elegance.

Speed usually leads to C. Elegance always avoids it.



Abigail
-- 
perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'
#    A raven nesting.
#    A kitty washes beside a
#    lake. A lark nesting.


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

Date: 05 Oct 2001 08:56:55 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Multiplexing strings
Message-Id: <m1adz6qdvc.fsf@halfdome.holdit.com>

>>>>> "Abigail" == Abigail  <abigail@foad.org> writes:

Abigail> Which is a silly question to ask, as it's unclear what the OP wants.

A good grade for their homework, perhaps? :)

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


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

Date: Fri, 05 Oct 2001 18:01:33 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: Multiplexing strings
Message-Id: <q8mrrtkarm2mvlbpukhflejievdlrfljk2@4ax.com>

Le 4 Oct 2001 15:46:21 -0700, mauroid@csi.forth.gr (Dimitri) écrit:

@STR= ($str1,$str2,$str3);
$N = @STR;           # number of strings
$M = 2;              # chars per token
$S = length $STR[0]; # string length

$out = join '', 
  ( join('',@STR) =~ /(.{$M})/gos )[
    map { my($i)=$_; return map { $i + $_*$S/$M } 0..$N-1 }  0..($S/$M)-1
  ];

one line only ! 

Jean-Philippe Fauvelle

>I have N=3 strings of equal length, and I want to multiplex them by taking
>M=2 characters from each string (the length of each string is divisible by
>M). Example :
>
>Input:
>
>$str1 = "aabbccddeeff";
>$str2 = "AABBCCDDEEFF";
>$str3 = "001122334455";
>
>Output :
>
>$out = "aaAA00bbBB11ccCC22ddDD33eeEE44ffFF55";
>
>Besides the obvious for loop :
>
>$out = ""; $len = length($str1);
>
>for ($i = 0; $i < $len; $i += 2) {
> $out .= substr($str1, $i, 2) . substr($str2, $i, 2) . substr($str3, $i, 2);
>}
>
>Is there a more elegant (faster) way?
>
>Thanks!
>-Dimitri



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

Date: Fri, 05 Oct 2001 18:18:36 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: Multiplexing strings
Message-Id: <d6nrrtg0kts4agluli09o71i8cd9g89gp4@4ax.com>

Le Fri, 05 Oct 2001 15:36:34 GMT, Dave Tweed <dtweed@acm.org> écrit:

Hi Dave.

Can you add my version into your benchmark, please ?
I tested it and it works.
I'd like to know how fast is the probably most ugly version :-)
Thanks !

Jean-Philippe Fauvelle


$str1 = "aabbccddeeff";
$str2 = "AABBCCDDEEFF";
$str3 = "001122334455";

@STR= ($str1,$str2,$str3);
$N = @STR;           # number of strings
$M = 2;              # chars per token
$S = length $STR[0]; # string length

$out = join '', 
  ( join('',@STR) =~ /(.{$M})/gos )[
    map { my($i)=$_; map { $i + $_*$S/$M } 0..$N-1 }  0..($S/$M)-1
  ];





>Joe Schaefer wrote:
>> The way you've written it, both 'swrite' and 'inline' will
>> wipe-out the $str* variables (the picture's "~~" does that).
>> You need to first copy them to temporary variables, like
>> 
>>   $out = swrite("^<^<^<~~", @tmp=($str1, $str2, $str3))
>
>Ah. That's better. Thanks. Now I get:
>
>~/temp/perl>perl mux.pl
>          Rate  split swrite substr inline
>split  11039/s     --   -59%   -66%   -70%
>swrite 26940/s   144%     --   -17%   -28%
>substr 32392/s   193%    20%     --   -13%
>inline 37256/s   237%    38%    15%     --
>
>~/temp/perl>perl mux.pl 10
>         Rate  split substr swrite inline
>split  1114/s     --   -67%   -79%   -81%
>substr 3340/s   200%     --   -39%   -42%
>swrite 5431/s   387%    63%     --    -6%
>inline 5803/s   421%    74%     7%     --
>
>~/temp/perl>perl mux.pl 100
>        Rate  split substr swrite inline
>split  119/s     --   -67%   -82%   -82%
>substr 366/s   207%     --   -45%   -45%
>swrite 664/s   456%    81%     --    -0%
>inline 665/s   457%    82%     0%     --
>
>-- Dave Tweed



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

Date: Fri, 05 Oct 2001 17:18:16 -0000
From: David Wall <darkon@one.net>
Subject: Re: Multiplexing strings
Message-Id: <Xns9131872836F5darkononenet@207.126.101.97>

abigail@foad.org (Abigail) wrote on 05 Oct 2001:
>
> Speed usually leads to C. 

But once your speed becomes a substantial fraction of C you run into 
relativistic effects....

-- 
David Wall
darkon@one.net


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

Date: Fri, 05 Oct 2001 17:36:26 +0200
From: Jens Luedicke <jens@irs-net.com>
Subject: oop question
Message-Id: <9pkk5d$8h9$05$1@news.t-online.com>

hi there...

$foo = new Foo;
$foo->bar->baz("hello, world!");

My object-oriented Perl knowledge is a little limited,
so I would like to know how the above lines are coded in Perl
(package Foo, methods, ...)

-- 
Jens Luedicke
jens@irs-net.com


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

Date: 5 Oct 2001 09:35:26 -0700
From: dboyce@phoenixcolor.com (Dan Boyce)
Subject: Re: Perl Guru needed for this extremely frustrating search and replace problem.
Message-Id: <3fac67fd.0110050835.47173382@posting.google.com>

Michael Budash <mbudash@sonic.net> wrote in message news:<mbudash-B196AA.16511104102001@news.sonic.net>...
> In article <3BBCF238.20219C7B@acm.org>, Dave Tweed <dtweed@acm.org> 
> wrote:
> 
> > Don't top-post, it's a pain to fix up for follow-ups.
> > 
> > Dan Boyce wrote:
> > > Michael Budash <mbudash@sonic.net> wrote in message > 
> > > news:<mbudash-A0C5AE.14215903102001@news.sonic.net>...
> > > > In article <3fac67fd.0110031258.3cce7cd8@posting.google.com>,
> > > > dboyce@phoenixcolor.com (Dan Boyce) wrote:
> > > > > Some how I need to convert the script below to allow me to enter a
> > > > > directory structure (ie. /home/dan/).  Using a script that I have
> > > > > found in a book I can replace INSTALL_DIR with strings as long as 
> > > > > they
> > > > > do not contain "/" in them.
> > > > >
> > > > > The following is the test script:
> > > > > #/bin/sh
> > > > > echo "Replace with: "
> > > > > read number_two
> > > > > cp test.conf test.conf.bak
> > > > > perl -p -i -e s/INSTALL_DIR/$number_two/ test.conf
> > > > > echo "test.conf"
> > > > > more test.conf
> > > > >
> > > > try this (untested) replacement line in the test script:
> > > >
> > > > perl -p -i -e 's{INSTALL_DIR}{$number_two}' test.conf
> > > 
> > > Thanks for the help, but still no luck.  I tried your line as is, and
> > > it just deleted INSTALL_DIR and put nothing in its place.  I tried
> > > modifying it a bit and again no luck.
> > 
> > You need both a perl guru and a shell guru, I guess.
> > 
> > The problem with your initial attempt was that any '/' in the replacement
> > string terminated the substitute command prematurely, creating the syntax
> > error.
> > 
> > Unfortunately, Michael introduced single-quotes around his solution, 
> > which
> > prevented the shell from doing the intended substitution for the 
> > replacement
> > pattern.
> > 
> > The trick is that you need to use some delimiter for the substitution 
> > other
> > than '/', but you need to make sure that the character you use isn't 
> > going
> > to be acted on by the shell.
> > 
> > Try this, using double-quotes and parens instead of single-quotes
> > and braces:
> > 
> >     perl -p -i -e "s(INSTALL_DIR)($number_two)" test.conf
> > 
> > -- Dave Tweed
> 
> thanks for correcting me, dave... just wasn't looking closely enuff...

Thanks a lot for the help,
I'm sorry for top posting, I didn't notice that I did it at the time.
Thanks again,
Dan


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

Date: Fri, 5 Oct 2001 13:50:40 -0400
From: "clarke" <nclarke@mindspring.com>
Subject: Perl on Soalris > need help with install
Message-Id: <9pks1f$ja0$1@slb3.atl.mindspring.net>

Having a hard time installing PERL on Solaris. I download the TAR file and I
had problems with the INSTALL file.

Can anyone point me in the right direction?




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

Date: Fri, 5 Oct 2001 13:04:18 -0500
From: "Mr. Sunblade" <djberge@qwest.com>
Subject: Re: Perl on Soalris > need help with install
Message-Id: <zzmv7.116$O13.167355@news.uswest.net>


"clarke" <nclarke@mindspring.com> wrote in message
news:9pks1f$ja0$1@slb3.atl.mindspring.net...
> Having a hard time installing PERL on Solaris. I download the TAR file and
I
> had problems with the INSTALL file.
>
> Can anyone point me in the right direction?

Need more info.

Which version of Solaris?
Which platform (Intel, Sparc, other)?
Which version of Perl?
What errors are you getting?

Regards,

Mr. Sunblade




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

Date: Fri, 05 Oct 2001 20:04:14 +0200
From: Thomas Bätzler <thomas@baetzler.de>
Subject: Re: Perl on Soalris > need help with install
Message-Id: <aatrrt8fb6sa342g4ntk1ilqnsigljhphq@4ax.com>

On Fri, 5 Oct 2001, "clarke" <nclarke@mindspring.com> wrote:
>Having a hard time installing PERL on Solaris. I download the TAR file and I
>had problems with the INSTALL file.

What kind of problems? You are aware that this is a text file
describing the installation, not an executable installer?

>Can anyone point me in the right direction?

You can always grab a precompiled binary package from
http://www.sunfreeware.com - then you won't have to fiddle around with
the compiler and such.

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: 5 Oct 2001 09:26:23 -0700
From: houda.araj@cogmedia.com (Houda Araj)
Subject: Reformat Chain
Message-Id: <7d0055df.0110050826.4102cf31@posting.google.com>

I would like to reformat an (input chain) to an output chain. The
input chain has two lines. The first line is plain english words and
the second is grammatical categories. What I want to do is to put
grammatical label in capital letter after each word.

I have several input chains to transform.  

Is anybody knows how I can achieve that ? Is PERL the right language
or C++ is better ?

Input Chain
cases will be by   means of either the operation of the appropriate 
nns   md/3 be rb/2 vbz/3 in cc     at  nn        in at  jj/2        

Output Chain
cases_NNS will_MD/3 be_BE by_RB/2   means_VBZ/3 of_IN either_CC the_AT
operation_NN of_IN the_AT appropriate_JJ/2


Houda Araj

Houda.Araj@cogmedia.com


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

Date: Fri, 05 Oct 2001 19:03:33 +0200
From: Thomas Bätzler <thomas@baetzler.de>
Subject: Re: Reformat Chain
Message-Id: <ssprrtoepe20ie9m63u5a62436mojf26vq@4ax.com>

On 5 Oct 2001, houda.araj@cogmedia.com (Houda Araj) wrote:

>I would like to reformat an (input chain) to an output chain. The
>input chain has two lines. The first line is plain english words and
>the second is grammatical categories. What I want to do is to put
>grammatical label in capital letter after each word.

#!/usr/bin/perl -w

use strict;

my @words = split /\s+/, <DATA>;

my @notes = split /\s+/, <DATA>;

print join( ' ', map { $_ . "_" . uc( splice @notes,0,1 ) } @words );

__DATA__
cases will be by   means of either the operation of the appropriate
nns   md/3 be rb/2 vbz/3 in cc     at  nn        in at  jj/2

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: 05 Oct 2001 17:13:37 +0100
From: nobull@mail.com
Subject: Re: resetting variables
Message-Id: <u9zo76njym.fsf@wcl-l.bham.ac.uk>

rdeenen@mollymail.com (rolf deenen) writes:

> Ok, so, the fact that an item is added to the database when refreshing
> a page is not the result of the hash remembering it's value but of the
> browser sending the same value again... Can this be stopped?

Did you see my previous contribution to this thread?

<u9g0903alf.fsf@wcl-l.bham.ac.uk>

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


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

Date: Fri, 05 Oct 2001 15:33:25 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: seconds since epoch to normal date
Message-Id: <3bbdd2c4.37b$387@news.op.net>

In article <wj4v7.377271$Lw3.23709518@news2.aus1.giganews.com>,
Jessica Bull <jessica.bull@broadwing.com> wrote:
> my $timemodvalue = @_;

Other folks have already pointed out that this line is the culprit.

Whenever you see a date in December 1969 or January 1970, you should
guess that the number that you passed to 'localtime' was a lot smaller
than it should have been.

> my ($sec2, $min2, $hou2, $mdy2, $mon2, $yea2) = localtime($timemodvalue);
>  $yea2=1900+$yea2; $mon2=$mon2+1;
>
>   if (length($sec2)<2) { $sec2="0$sec2"; }
>   if (length($min2)<2) { $min2="0$min2"; }
>   if (length($hou2)<2) { $hou2="0$hou2"; }
>   if (length($mdy2)<2) { $mdy2="0$mdy2"; }
>   if (length($mon2)<2) { $mon2="0$mon2"; }
>
> # $timestamp is in the format of yyyy.mm.dd.hh.mm.ss
>
>  my $timestamp2="$yea2.$mon2.$mdy2";
>  return $timestamp2;

I notice that the comment and the code disagree.  At least one of them
is wrong.  You should find out which and fix it.

Supposing that it's the code that is wrong, you might prefer to get
rid of this whole block of code and replace it with this much smaller block:  

     my ($sec2, $min2, $hou2, $mdy2, $mon2, $yea2) = localtime($timemodvalue);
     $yea2=1900+$yea2; $mon2=$mon2+1;

     # $timestamp is in the format of yyyy.mm.dd.hh.mm.ss
     return sprintf("%02d.%02d.%02d.%02d.%02d.%02d",
                     $yea2, $mon2, $mdy2, $hou2, $min2, $sec2);

The "%02d"s format each of the parts of the timestamp as a two-digit number.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: 05 Oct 2001 08:51:28 -0600
From: gls@byu.edu
Subject: Re: splitting a very wide report
Message-Id: <uitdu16of.fsf@SNOW.i-did-not-set--mail-host-address--so-shoot-me>

Marc Ulrich <mdulrich@unity.ncsu.edu> writes:

> I've a report output that is very very wide and is better done as three
> individual reports (which will fit on a single page). Line wraps are
> annoying and so is ultrasmall text.
> 
> The only solution I've come up with is to have three output formats and
> do three separate reports. This is kind of awkward. I'd rather do a
> single report but ask it to split it after column x and after column y.
> Is this possible?

Not a perl solution, but look at the program enscript:
http://people.ssh.fi/mtr/genscript/

Look specifically at the --slice option.

Remember Perl is a good glue language.  It does not have to do
everything itself.  Just create your wide report with Perl, then pipe
the results into enscript.

Hope this helps,

-- 
Greg Snow, PhD                Office: 223A TMCB
Department of Statistics      Phone:  (801) 378-7049
Brigham Young University      Dept.:  (801) 378-4505
Provo, UT  84602              email:  gls@byu.edu


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

Date: Fri, 05 Oct 2001 21:11:25 +0400
From: Vladimir Volovich <vvv@vsu.ru>
Subject: strangeness (bug?) in regexp handling
Message-Id: <ey4rpef1vm.fsf@vsu.ru>
Keywords: 1908269398

Hi,

could someone please explain why i get the following strange result:

$ perl -e '$_="abc&aacute;abc"; s/&([A-Za-z0-9#]+?);/\0$1\1/g; s/;.*//; s/\0([A-Za-z0-9#]+?)\1/&$1;/g; print "$_\n"'
abc&a;cuteaacuteabc
$ perl -e    '$_="abc&ETH;abc"; s/&([A-Za-z0-9#]+?);/\0$1\1/g; s/;.*//; s/\0([A-Za-z0-9#]+?)\1/&$1;/g; print "$_\n"'
abc&ETH;abc

i think that the result of the first command should be
abc&aacute;abc
instead of
abc&a;cuteaacuteabc

Best,
v.


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

Date: Fri, 05 Oct 2001 19:37:32 +0200
From: Thomas Bätzler <thomas@baetzler.de>
Subject: Re: strangeness (bug?) in regexp handling
Message-Id: <orrrrt4pfdbck88b2qt9iqa1kvp4k0nek3@4ax.com>

On Fri, 05 Oct 2001, Vladimir Volovich <vvv@vsu.ru> wrote:

>could someone please explain why i get the following strange result:
>
>$ perl -e '$_="abc&aacute;abc"; s/&([A-Za-z0-9#]+?);/\0$1\1/g; s/;.*//; s/\0([A-Za-z0-9#]+?)\1/&$1;/g; print "$_\n"'
>abc&a;cuteaacuteabc

perldoc perlre

I suspect \1 is not doing what you think it does.

Maybe you could explain what you're trying to achieve first, next
time. That makes finding potential bugs a lot easier. Anyways:

#!/usr/bin/perl -w

use strict;

my $a="abc&aacute;abc";

$a =~ s/&([A-Za-z0-9#]+?);/<$1>/g;
$a =~ s/;.*//;
$a =~ s/<([A-Za-z0-9#]+?)>/&$1;/g;

print "$a\n";

__END__

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Fri, 05 Oct 2001 17:44:15 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: strangeness (bug?) in regexp handling
Message-Id: <Pjmv7.103278$Xz1.12150717@news1.rdc1.md.home.com>


"Vladimir Volovich" <vvv@vsu.ru> wrote in message
news:ey4rpef1vm.fsf@vsu.ru...
> Hi,
>
> could someone please explain why i get the following strange result:
>
> $ perl -e '$_="abc&aacute;abc"; s/&([A-Za-z0-9#]+?);/\0$1\1/g; s/;.*//;
s/\0([A-Za-z0-9#]+?)\1/&$1;/g; print "$_\n"'
> abc&a;cuteaacuteabc
> $ perl -e    '$_="abc&ETH;abc"; s/&([A-Za-z0-9#]+?);/\0$1\1/g; s/;.*//;
s/\0([A-Za-z0-9#]+?)\1/&$1;/g; print "$_\n"'
> abc&ETH;abc
>
> i think that the result of the first command should be
> abc&aacute;abc
> instead of
> abc&a;cuteaacuteabc
>
> Best,
> v.

That's incredibly convoluted.  You should try to break the problem down more
next time.  Also, print out your intermediate strings so you can see what's
going on.

$ perl -le '$_="abc&aacute;abc"; print;s/&([A-Za-z0-9#]+?);/\0$1\1/g;print;
s/;
 .*//; print;s/\0([A-Za-z0-9#]+?)\1/&$1;/g; print'
abc&aacute;abc
abc aacuteaacuteabc
abc aacuteaacuteabc
abc&a;cuteaacuteabc

$ perl -le '$_="abc&aacute;abc"; print;s/&([A-Za-z0-9#]+?);/\0$1\1/g;print;
s/;
 .*//; print;s/\0([A-Za-z0-9#]+)\1/&$1;/g; print'
abc&aacute;abc
abc aacuteaacuteabc
abc aacuteaacuteabc
abc&aacute;abc

Note the removal of the question mark on the second one.  The question mark
in the first one isn't even necessary.  Also, some of those substitutions
aren't doing anything.  I think you need to re-examine this code.

As another poster mentioned, please perldoc perlre and make sure you
completely understand \1, etc.

--
David Hilsee




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

Date: 5 Oct 2001 10:31:50 -0700
From: miko@idocs.com (Miko O'Sullivan)
Subject: Taint aware tree
Message-Id: <db27ea77.0110050931.39edbeb0@posting.google.com>

I've found some discussions the topic of taint-aware tree deletion,
but not any actual consensus on a module that does it.  (If there
actually is a standard solution out there, hey, I'm all... um...
eyes.) Therefore I'm posting the module echoed below for
comments/flames/praise.  If there seems to be a consensus that this is
a useful module, I'll submit to CPAN for a namespace and do the whole
CPAN upload thang.

The module below provides a way to delete a tree while tainting is on
(which IMHO it should almost always be).  Dir::DelTree::deltree
accepts a single path as an argument.  If that path is tainted then a
fatal error occurs.  If the path is not tainted, then that directory
and everything within it are deleted.  Symbolic links are deleted but
not followed.

The aspect of this subroutine with which I'm still not comfortable is
that the file names in the directory are blindly untainted... not
exactly the spirit of tainting.  I can't think of how this would be a
problem, but perhaps someone here can.  That being said, it wouldn't
be accurate to say that the module conpletely defeats the purpose of
tainting: it still requires a tainted initial argument.  At any rate,
it doesn't strike me as any worse than the popular solution which is
to use rmdir without tainting.

OK, enough introduction.  The code follows.

-miko

=========================================================

 package Dir::DelTree;
 use strict;
 use Carp;
 use Taint;
 
 # deltree deletes an entire directory tree.  deltree, which accepts 
 # a single argument as the path to the directory to delete, is 
 # taint-aware. deltree will refuse to proceed if the argument is 
 # tainted, but will proceed to untaint the file names (and then 
 # files) delete the thereafter if the first argument is not tainted.
 
 sub deltree {
    my ($dir) = @_;
    my (@files);
    
    # if path is tainted
    if (Taint::is_tainted($dir))
        {die "Cannot delete directory tree: insecure dependency"}

    # if path is not a directory
    unless (-d $dir)
        {croak "$dir is not a directory"}
    
    opendir(MYDIR, $dir) or return(0);
    @files = grep(/[^\.]+/, readdir(MYDIR));
    closedir(MYDIR) or return(0);
    
    foreach my $file (@files){
        $file =~ m/^(.*)$/so;
        $file = "$dir/$1";
        
        if ( (-l $file) || (! (-d $file)) )
            {unlink($file) or return(0)}
        else
            {Dir::DelTree::deltree($file) or return(0)}
    }
    
    rmdir($dir) or return(0);
    return 1;
 }

 # return
 1;


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

Date: 05 Oct 2001 17:12:12 +0100
From: nobull@mail.com
Subject: Re: Trapping sendmail errors (with eval?)
Message-Id: <u93d4yoylf.fsf@wcl-l.bham.ac.uk>

bill@ilap.com (Bill Dykstra) writes:

> nobull@mail.com wrote in message news:<u9g08zxp38.fsf@wcl-l.bham.ac.uk>...
> 
> > That does not look like a Perl error.  That looks like STDOUT from
> > sendmail. What makes you believe that you Perl script is crashing?
> > 
> > >   I've tried using eval to trap the error, but I can't get it to
> > > work.
> > 
> > What makes you believe that there is an error to trap?

> You're correct, it is a sendmail error message, not a perl error.  My
> confusion is with the fact that my perl program should continue
> looping, trying X number of times to resend the message.

There was no such looping in your original post.  Besides retrying in
response to a non-transient error is an utterly inappropriate
response.  In general one sendmail has accepted a message for delivery
it will queue and retry automatically if there's an error that's
likely to be transient.

> Instead of detecting that there was an error from sendmail,
> however, the perl script just dies.

Please show us some evidence to support your assertion that the Perl
script dies.  For example put a diagnostic print after the point where
you believe the script dies and check that it does not print. From
what you've described so far it sounds like the Perl script continues
oblivious to the fact that it failed to send the mail.

This has nothing to do with Perl, but I suspect sendmail is configured
for background delivery (fork-off-and-die) so it has already exited
with a zero exit status before it detects the error.  It may help to
use the -O DeliveryMode=i option.  (On the other hand it may not -
since this isn't a Perl issue I'm not going to go to too much trouble
to check).

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


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

Date: 5 Oct 2001 10:09:15 -0700
From: filippomj@netscape.net (Mike Filippo)
Subject: Re: Uninstall under Windows ME
Message-Id: <ad3e516c.0110050909.31c93842@posting.google.com>

"Rob - Rock13.com" <rob_13@excite.com> wrote in message news:<Xns91311EF43535Erock13com@64.8.1.227>...
> Mike Filippo
> <news:ad3e516c.0110041923.1ef0bbab@posting.google.com>: 
> 
> > I've installed Perl 5.6 on an ME system. There is no entry in
> > the Add/Remove programs, there is no uninstall.bat file, and
> > the Uninstall entry in the FAQ is null. Can anyone tell me how
> > to uninstall it? Thanks.
> 
> Why on earth do you want to uninstall it?
> 
> Did you use ActivePerl? Mine put an entry in the Remove programs 
> applet in the Control Panel. Otherwise, I suppose you have to do it 
> manually.
Rob, it was active Perl. What I was able to do was run a system
restore from msconfig for a system image that was created before I
installed Perl. It worked as advertised. Thanks.


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

Date: Fri, 05 Oct 2001 19:20:48 +0200
From: Thomas Bätzler <thomas@baetzler.de>
Subject: Re: Uninstall under Windows ME
Message-Id: <usqrrtcga10r5405i4rmfrc73rgm9shlo8@4ax.com>

On 5 Oct 2001, filippomj@netscape.net (Mike Filippo) wrote:
>Rob, it was active Perl. What I was able to do was run a system
>restore from msconfig for a system image that was created before I
>installed Perl. It worked as advertised. Thanks.

Try the MSI package next time. Installs and uninstalls like a charm. 

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: 5 Oct 2001 10:54:44 -0700
From: tommyumuc@aol.com (JR)
Subject: Re: what am I doing wrong ?
Message-Id: <319333f5.0110050954.670814ce@posting.google.com>

tana@acedsl.com (Tana) wrote in message news:<4294f74d.0110041720.2afc78bc@posting.google.com>...
> I have a simple perl script like this:
> #!/usr/bin/perl
> use CGI;
> 
> $cgi=new CGI;
> print $cgi->header();
> 
> print "User ID: $user_id";
> 
> 
> And I call the script from internet browser like this:
> http://hepek.com/cgi-bin/test.pl?user_id=100
> 
> I would expect to see a value for user_id (100) as a result, but value is emty.
> All I see is "User ID: ".
> 
> what am I doing wrong?

There is nothing to receive the variable $user_id in your script.  All
you have to do is catch the variable like this:

my $user_id = $q->param('user_id');

This will receive the varible information and you should then get:

User ID: 100 (which is what you want)

Hope this help...


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

Date: Fri, 05 Oct 2001 15:05:46 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Yet another fork question
Message-Id: <x7d74286tw.fsf@home.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> MJD has recently shown code where each kid runs its own accept loop
  AS> and the parent does nothing but wait(pid) and more forks.  I like
  AS> that solution a lot (if applicable), and it has me wondering why
  AS> practically all standard examples in the Perl literature place the
  AS> accept call in the parent.

that design has its flaws and strengths. it requires all the children to
be preforked (and you know how painful that is!). most forking servers
fork after each accept call and that allows the parent to manage them
slightly better. a parent that accepts could make various decisions
globally before forking a child. in mjd's design any random child will
get the accept and not know about the others. his design does have its
merits but it is not a win in every server case.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: 05 Oct 2001 15:31:12 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Yet another fork question
Message-Id: <slrn9rrkhu.l24.vek@pharmnl.ohout.pharmapartners.nl>

On 05 Oct 2001 07:31:52 -0700,
    Randal L. Schwartz <merlyn@stonehenge.com> wrote:


>>>>>> "Anno" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
>
>Anno> That makes sense.  There had to be a disadvantage in letting many
>Anno> processes accept connections on a single socket.
>
>And it's illegal on at least one place I was testing it, when
>I was building the code for:
>
>  <http://www.stonehenge.com/merlyn/WebTechniques/col34.html>
>
>I don't recall where now, but I think it was sunos4. Linux handled it
>just fine.
> 


R. Stevens book: UNIX Network Programming, vol.1 is where I read about
the problem, and also about other server implementation alternatives.


Villy


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

Date: 05 Oct 2001 08:41:03 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Yet another fork question
Message-Id: <m1eloiqels.fsf@halfdome.holdit.com>

>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
AS> MJD has recently shown code where each kid runs its own accept loop
AS> and the parent does nothing but wait(pid) and more forks.  I like
AS> that solution a lot (if applicable), and it has me wondering why
AS> practically all standard examples in the Perl literature place the
AS> accept call in the parent.

Uri> that design has its flaws and strengths. it requires all the children to
Uri> be preforked (and you know how painful that is!). most forking servers
Uri> fork after each accept call and that allows the parent to manage them
Uri> slightly better. a parent that accepts could make various decisions
Uri> globally before forking a child. in mjd's design any random child will
Uri> get the accept and not know about the others. his design does have its
Uri> merits but it is not a win in every server case.

Or you have the kids notify the parent of their state using a scoreboard,
Apache-style.

I have (unpublished) a dynamic-pre-forking Apache-style web streaming
proxy server in about 300 lines of pure Perl (using HTTP::Daemon and
the other LWP items, of course).  It takes the same parameters as
Apache child management:

    ### configuration
    my $HOST = 'www.stonehenge.com';
    my $PORT = 42001;		# 0 = pick next available user-port
    my $START_SERVERS = 4;		# start this many, and don't go below
    my $MAX_CLIENTS = 12;		# don't go above
    my $MAX_REQUESTS_PER_CHILD = 250; # just in case there's a leak
    my $MIN_SPARE_SERVERS = 1;	# minimum idle (if 0, never start new)
    my $MAX_SPARE_SERVERS = 12;	# maximum idle (should be "single browser max")

And acts accordingly, using a simple scoreboarding mechanism similar
to the Apache method.

Using this code, the apache-benchmark program shows that I'm only half
as fast as Apache, and has one quarter the footprint!

The best part is that in those 300 lines, I handle full SSL streaming
(the CONNECT call), full content streaming (I was watching live-feed
quicktime movies through the proxy), and if the content-type is
text/html, an HTML parser in token mode is inserted, allowing
real-time rewriting.  For example, I could insert <font color=blue>
tags around all <a href=> links, while not impeding the stream of the
rest of the HTML... there'd just be a hiccup while the <a href=> was
being noticed.

The code was originally written as a work for-hire for a client who
had intended my work to become open source.  But the client
dot-bombed, so I'm still trying to get clarification of whether I can
release the code under my own copyright.  As soon as that clears up,
expect a WebTechniques column or two on it. :)

print "Just another Perl hacker,"

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


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

Date: Fri, 05 Oct 2001 16:03:00 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Yet another fork question
Message-Id: <x7adz6846i.fsf@home.sysarch.com>

>>>>> "RLS" == Randal L Schwartz <merlyn@stonehenge.com> writes:

>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:

  Uri> that design has its flaws and strengths. it requires all the
  Uri> children to be preforked (and you know how painful that
  Uri> is!). most forking servers fork after each accept call and that
  Uri> allows the parent to manage them slightly better. a parent that
  Uri> accepts could make various decisions globally before forking a
  Uri> child. in mjd's design any random child will get the accept and
  Uri> not know about the others. his design does have its merits but it
  Uri> is not a win in every server case.

  RLS> Or you have the kids notify the parent of their state using a
  RLS> scoreboard, Apache-style.

well, i said some global managing is probably necessary. that was the
main weakness of that design as MJD coded it. in a normal forking server
you don't need IPC with the parent to manage a scoreboard, the parent
owns all the control data anyway. it all comes down to how much you save
with preforking vs. how much extra code you need to manage the children
and the IPC to the parent. also preforking implies that the children
manage their data spaces carefully for each request whereas pure
forking/exec will allow a clean process each time. tradeoffs all over
the place.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


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


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