[19636] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1831 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 27 11:05:35 2001

Date: Thu, 27 Sep 2001 08:05:08 -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: <1001603107-v10-i1831@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 27 Sep 2001     Volume: 10 Number: 1831

Today's topics:
    Re: a "private" installation of Perl (Andy Dougherty)
    Re: AoA(LoL) Sorting <tsee@gmx.net>
        Beginner Question <ytgh@hotmail.com>
    Re: Beginner Question (Randal L. Schwartz)
    Re: Beginner Question <ytgh@hotmail.com>
        delete/undef a hash inside a hash <x25@pobox.com>
    Re: delete/undef a hash inside a hash <Thomas@Baetzler.de>
    Re: Forcing reevaluation of code in mod_perl scripts? <please@no.spam>
    Re: Launching an external win32 app using a perl script <bart.lateur@skynet.be>
    Re: maths <na@na>
    Re: maths <davidhilseenews@yahoo.com>
    Re: maths <Thomas@Baetzler.de>
    Re: maths <na@na>
    Re: maths <na@na>
    Re: maths <hafner@augusta.de>
    Re: maths <Thomas@Baetzler.de>
    Re: maths <na@na>
    Re: maths <Thomas@Baetzler.de>
    Re: Peek and Poke on Perl? <please@no.spam>
        Regular Expression + Sub <stefan.jurack@sib-siemens.de>
    Re: Regular Expression + Sub <uri@sysarch.com>
    Re: Regular Expression + Sub <Thomas@Baetzler.de>
    Re: Regular Expression + Sub <stefan.jurack@sib-siemens.de>
        testing the "flatness" of a structured file <hafner@augusta.de>
    Re: testing the "flatness" of a structured file <Thomas@Baetzler.de>
        Uninitialized Value... (rab)
    Re: Win32 Perl - Setting ENV Variables from Command-lin <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 27 Sep 2001 13:19:48 -0000
From: doughera@maxwell.phys.lafayette.edu (Andy Dougherty)
Subject: Re: a "private" installation of Perl
Message-Id: <slrn9r69tv.eh7.doughera@maxwell.phys.lafayette.edu>

In article <9ot0t1$69f$1@plutonium.btinternet.com>, Peter Cameron wrote:
>I've discovered what I want to do isn't yet possible. Searching for
>"relocatable perl" provided me with the current status at:
>
>http://www.perl.com/pub/a/2001/05/p5pdigest/THISWEEK-20010506.html

That's slightly misleading.  It is quite possible to build a somewhat
relocatable perl by editing the binaries, and has been for a long
time.  Basically, you build an 'installable tar archive' as in the
INSTALL file.  Then, once you learn where it's ultimately going to go,
you just edit the binaries appropriately.  The two main problems are
that there's no convenient easy-to-use front end to the process, and
that the editing must be done prior to first use of perl5.  Once it's
been edited and installed, you can't pick up the distribution and move
it somewhere else without re-editing.

-- 
    Andy Dougherty		doughera@lafayette.edu
    Dept. of Physics
    Lafayette College, Easton PA 18042


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

Date: Thu, 27 Sep 2001 15:26:45 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: AoA(LoL) Sorting
Message-Id: <9ov9du$la4$07$1@news.t-online.com>

Michael, Martien,

"Martien Verbruggen" <mgjv@tradingpost.com.au> schrieb im Newsbeitrag
news:slrn9r4pge.8ai.mgjv@martien.heliotrope.home...
> On Wed, 26 Sep 2001 22:21:30 +0200,

[snip]

> Makes no difference. The first argument to split() is always interpreted
> as a regular expression [1].
>
> Martien
>
> [1] Except when it is a space (' ', but not / /).

Thank you for the correction. I read up on it now.

Steffen





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

Date: Thu, 27 Sep 2001 10:25:30 -0400
From: "LEPP" <ytgh@hotmail.com>
Subject: Beginner Question
Message-Id: <9ovcg1$bdf$1@bob.news.rcn.net>

I am writing my first perl script and want to know if my strategy is sound.
I want to write a script that will list all of the directories in the
current working directory and save the list into an array.  It will then
list all of the files in each of those subdirectories.  I have gotten this
far.  The part that is difficult is that when I output all of the files to
std out, I need to have two columns. One column should be all of the files
in alphabetical order and one column listing the directory that it is in.
Attached is the current code.  I have all of the directories and
subdirectories in the array but the problem is that I feel that I really
need to use a C style struct but I can't find if that is available in Perl.
The problem is that I cannot find a way of storeing what directory every
file is in.  Any help would be greatly appreciated.

Thanks
LEPP



#! /usr/bin/perl

@dirs =( `ls -F | grep /` );

$index=0;
#@dirs=`ls -F | grep /`;

print @dirs;
print $dirs[1];
print $dirs[2];
print "$#dirs is the length of the array \n";

while ($index <= $#dirs) {
 print "$index \n";
 print `ls $dirs[$index]`;
 push @dirs , `ls $dirs[$index]`;
# print "/$dirs[$index]"
 $index++;
}
print "Here is  the sorted list \n";
print reverse sort @dirs;
#push @dirs, `ls -F | grep /`;
print "after push \n @dirs";







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

Date: 27 Sep 2001 07:38:46 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Beginner Question
Message-Id: <m1adzgu2a1.fsf@halfdome.holdit.com>

>>>>> "LEPP" == LEPP  <ytgh@hotmail.com> writes:

LEPP> I am writing my first perl script and want to know if my
LEPP> strategy is sound.

Your question is fine, but separately posting it to alt.perl and
comp.lang.perl.misc is forbidden.  (Cross-posting OK, multi-posting BAD BAD.)

I just answered this question there.
Please don't followup here.


-- 
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: Thu, 27 Sep 2001 10:52:45 -0400
From: "LEPP" <ytgh@hotmail.com>
Subject: Re: Beginner Question
Message-Id: <9ove37$ijf$1@bob.news.rcn.net>

Thanks for your help. Sorry I did not know that I performed a no no.

Thanks for your help

LEPP

"Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
news:<m1adzgu2a1.fsf@halfdome.holdit.com>...

> >>>>> "LEPP" == LEPP <ytgh@hotmail.com> writes:

>

> LEPP> I am writing my first perl script and want to know if my

> LEPP> strategy is sound.

>

> Your question is fine, but separately posting it to alt.perl and

> comp.lang.perl.misc is forbidden. (Cross-posting OK, multi-posting BAD
BAD.)

>

> I just answered this question there.

> Please don't followup here.

>

>

> --

> 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!

"Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
news:m1adzgu2a1.fsf@halfdome.holdit.com...
> >>>>> "LEPP" == LEPP  <ytgh@hotmail.com> writes:
>
> LEPP> I am writing my first perl script and want to know if my
> LEPP> strategy is sound.
>
> Your question is fine, but separately posting it to alt.perl and
> comp.lang.perl.misc is forbidden.  (Cross-posting OK, multi-posting BAD
BAD.)
>
> I just answered this question there.
> Please don't followup here.
>
>
> --
> 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: Thu, 27 Sep 2001 20:59:02 +0700
From: "S" <x25@pobox.com>
Subject: delete/undef a hash inside a hash
Message-Id: <9ovbb9$ehu$1@news.cscoms.com>

Hi!

I am making a small script which parses some entries from the logs (it
'tails' them actually :).

When one entry in the log is spotted, a hash is created (in another
hash). Basically, I'm creating hash of hashes.

When another entry comes in (might be 2 seconds later, might be 15
minutes later), the hash needs to be removed completely (so that I don't
waste RAM which doesn't need to be wasted).

Hash looks like (example):

%a = (
    b => {
       'something' => 'something',
       'something2' => 'something2'
    },
    c => {
       'a' => 'b',
       'c' => 'd'
    }
);

(this is just an example, hashes are created dynamically)

What I first tried is to do "undef $a{$b}" when I don't need it
anymore - but hash key still remained.

I have then added "delete $a{$b}" after this, and it *seems* like it's
working now (key is gone if I try to access it).

Is this the correct way? :)

Thanks.


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

Date: Thu, 27 Sep 2001 16:16:48 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: delete/undef a hash inside a hash
Message-Id: <m4d6rtsm2jgs6q3lssj82lls4n5glot3i5@4ax.com>

On Thu, 27 Sep 2001 20:59:02 +0700, "S" <x25@pobox.com> wrote:
>What I first tried is to do "undef $a{$b}" when I don't need it
>anymore - but hash key still remained.

Try delete $a{$b};

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: Thu, 27 Sep 2001 15:04:11 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: Forcing reevaluation of code in mod_perl scripts?
Message-Id: <87pu8c4qzc.fsf@homer.cghm>

damian@qimr.edu.au (Damian James) writes:
> 
> @:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
> $:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
> $,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/}  __END__
> Just another Perl Hacker,### http://home.pacific.net.au/~djames.hub

That's really cool.


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

Date: Thu, 27 Sep 2001 14:29:30 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Launching an external win32 app using a perl script...
Message-Id: <7rd6rtgoaiuo0ksavu74ulmt6ffvrf3esn@4ax.com>

GuaRDiaN wrote:

>Does anybody knows how I could start an external win32 application using a
>perl script?
>I'm usign Active State Perl under Win2k Advanced Server ...

Just like on any other OS: using `...`, system() or possibly exec().

In addition, you might like to play with the external program/command
'start', and examine the Win32::Process module.

-- 
	Bart.


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

Date: Thu, 27 Sep 2001 14:12:42 +0100
From: "Chris" <na@na>
Subject: Re: maths
Message-Id: <3bb325d1$0$230$ed9e5944@reading.news.pipex.net>

i know more about the internet than you to buddy.

but im not going to harp on about all the internet things i know , (unlike
you perl types) i dont even care whether you use capital letters.

thank you all for you help with my perl questions. -q -f flags dont work
with perldoc (for me).

also thanks to you all for your amusing sigs, i just waiting for "unix is
user friendly, its just picky about who its friends with"

hahahah sys adm humour.




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

Date: Thu, 27 Sep 2001 13:32:09 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: maths
Message-Id: <tTFs7.3894$Xz1.925380@news1.rdc1.md.home.com>


"Chris" <na@na> wrote in message
news:3bb325d1$0$230$ed9e5944@reading.news.pipex.net...
> i know more about the internet than you to buddy.
>
> but im not going to harp on about all the internet things i know , (unlike
> you perl types) i dont even care whether you use capital letters.
>
> thank you all for you help with my perl questions. -q -f flags dont work
> with perldoc (for me).
>
> also thanks to you all for your amusing sigs, i just waiting for "unix is
> user friendly, its just picky about who its friends with"
>
> hahahah sys adm humour.
>
>

You can go to www.perldoc.com. where they have the FAQs and various other
things that you might find useful.

Your particular question is in perlfaq4 (data manipulation).  You can also
hit up perlfunc under the POD stuff for a list of functions.

David Hilsee




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

Date: Thu, 27 Sep 2001 15:34:01 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: maths
Message-Id: <f2a6rt0rs247ahaso07rmglg857d9n1ior@4ax.com>

On Thu, 27 Sep 2001 14:12:42 +0100, "Chris" <na@na> wrote:
>i know more about the internet than you to buddy.

Yeah, it shows :-P

>thank you all for you help with my perl questions. -q -f flags dont work
>with perldoc (for me).

Oh? Which Perl version and port are you running?

Since you're running Windows, I suggest you visit ActiveState at 
http://aspn.activestate.com/ASPN/Downloads/ActivePerl/ and grab their
current ActivePerl. Not only has that package a working perldoc, but
it also comes with HTML formatted documentation, including the FAQ.

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: Thu, 27 Sep 2001 14:40:20 +0100
From: "Chris" <na@na>
Subject: Re: maths
Message-Id: <3bb32c4b$0$234$ed9e5944@reading.news.pipex.net>

you do judge people without any knowledge of who they are.

a) i'd be surprised if you knew more about the internet than i

b)why am i running windows, im using linux session piped through an
x-session  on a windows platform.






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

Date: Thu, 27 Sep 2001 14:41:15 +0100
From: "Chris" <na@na>
Subject: Re: maths
Message-Id: <3bb32c81$0$237$ed9e5944@reading.news.pipex.net>


"David Hilsee" <davidhilseenews@yahoo.com> wrote in message
news:tTFs7.3894$Xz1.925380@news1.rdc1.md.home.com...
>
> "Chris" <na@na> wrote in message
> news:3bb325d1$0$230$ed9e5944@reading.news.pipex.net...
> > i know more about the internet than you to buddy.
> >
> > but im not going to harp on about all the internet things i know ,
(unlike
> > you perl types) i dont even care whether you use capital letters.
> >
> > thank you all for you help with my perl questions. -q -f flags dont work
> > with perldoc (for me).
> >
> > also thanks to you all for your amusing sigs, i just waiting for "unix
is
> > user friendly, its just picky about who its friends with"
> >
> > hahahah sys adm humour.
> >
> >
>
> You can go to www.perldoc.com. where they have the FAQs and various other
> things that you might find useful.
>
> Your particular question is in perlfaq4 (data manipulation).  You can also
> hit up perlfunc under the POD stuff for a list of functions.
>
> David Hilsee
>



Cheers David




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

Date: 27 Sep 2001 15:56:16 +0200
From: Walter Hafner <hafner@augusta.de>
Subject: Re: maths
Message-Id: <qdf4rpopwjj.fsf@www.ibexnet.de>

"Chris" <na@na> writes:

> wow, what a friendly bunch you lot are.
> 
> i have a script when i need a little help with  and look at the abuse i get.
> 
> this is a news group, you dont own and cant control what gets posted. this
> isn't your news group.

No, but i can control what i have to read.

*PLONK*

Have fun with Godzilla. She's down there somewhere, too.

-Walter


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

Date: Thu, 27 Sep 2001 16:12:18 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: maths
Message-Id: <ffb6rtk509snogg0s0a3r4j4dtmhp12llc@4ax.com>

On Thu, 27 Sep 2001 14:40:20 +0100, "Chris" <na@na> wrote:
>you do judge people without any knowledge of who they are.

Yes, of course. Everybody does that. We go after our first impression.
And so far, you have shown no sign that my first impression of you was
wrong.

I mean, a grown up person would've stood up by now and said the four
magic words - "sorry, I was wrong". Instead you're trying to impress
people by trying to project the image of the Great White Internet
Specialist, and you're failing miserably.

>a) i'd be surprised if you knew more about the internet than i

Oh, there are many people out there who know more than I do. People
that I look up to and that I respect. They usually don't have an urge
to tell everybody how great and wonderful they are. See
http://www.tuxedo.org/~esr/writings/homesteading/homesteading/x249.html

>b)why am i running windows, im using linux session piped through an
>x-session  on a windows platform.

And you're running Outlook Express in a vmware Windows session on the
Linux box? I don't get your point - you do sit in front of a Windows
box, so why not download a Perl package for it? Even if you're not
going to use it for development, you still have the documentation
handy. And if you prefer reading that in lynx or mozilla on X, just
FTP it over?

confused,
-- 
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: Thu, 27 Sep 2001 15:35:08 +0100
From: "Chris" <na@na>
Subject: Re: maths
Message-Id: <3bb33922$0$231$ed9e5944@reading.news.pipex.net>

well done, you have managed to brighten my day up.

i sat here for a few minutes and though of all the things i wanted to say to
you, how i was going to point out the various flaws in your arguments and
statements, but i realised.....

why bother, you are obviously a small lonely man, with little to brighten
your day apart from your officious perl doctrin. enjoy your life at your
keyboard, i for one will be down the pub with my friends laughing at your
type.

chris





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

Date: Thu, 27 Sep 2001 16:58:52 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: maths
Message-Id: <1cf6rtkth04qf6fatqfjepgh6kcrsvme2i@4ax.com>

On Thu, 27 Sep 2001 15:35:08 +0100, "Chris" <na@na> wrote:
>well done, you have managed to brighten my day up.

Same to you, old chap. 

>i sat here for a few minutes and though of all the things i wanted to say to
>you, how i was going to point out the various flaws in your arguments and
>statements, but i realised.....

That you didn't have a point? Ah, that'd've been hoping for too much.

People never cease to amaze me...
-- 
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: Thu, 27 Sep 2001 15:04:03 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: Peek and Poke on Perl?
Message-Id: <87vgi44qzk.fsf@homer.cghm>

Gary <gamtci1@mpinet.net> writes:

> I built the board, so it's not supported by any OS. However, I built
> it to reside at one of the segment addresses A,B,C,D or E.
> 
> Currently, under DOS, I use an out instruction to the board's IO
> port to set the memory address, and then use peek and poke to get at
> the memory.
> 
> I appreciate all the reponses and comments. It is, however, as I
> feared: I have to write this module myself for use under Linux and
> NT.  I'm wondering now which newsgroup would be appropriate to ask
> if a "peek/poke/inport/outport" driver is available for Linux and/or
> NT (even if it's a sample).

I believe you can map the physical memory to the process's page table
using /dev/{kmem,port} and mmap.  You may be able to get help with
that in comp.unix.programmer.  There are also other (possibly better)
ways to do it (e.g. writing a kernel driver), but I imagine mmap would
make porting from DOS easiest.  For NT I have no clue.

HTH.


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

Date: Thu, 27 Sep 2001 16:04:01 -0700
From: Stefan Jurack <stefan.jurack@sib-siemens.de>
Subject: Regular Expression + Sub
Message-Id: <3BB3B061.E96CB93A@sib-siemens.de>

Hello!

I try to parse a text to find a certain pattern. This pattern i'd like
to replace with the result of a funktion/sub.

for now it looks like this:

$myvar = $myfunction($1);
$bla = s/mypattern(.*)mypattern/$myvar/g;
or
$bla = s/mypattern(.*)mypattern/$myvar($1)/g;

The Problem is to get the $1 content of this reg.expr. as parameter of
the function!!!!
Has anyone an idea how to solve the problem, or another way!

Thanks in advance!
Stefan



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

Date: Thu, 27 Sep 2001 14:12:59 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Regular Expression + Sub
Message-Id: <x7n13gafi1.fsf@home.sysarch.com>

>>>>> "SJ" == Stefan Jurack <stefan.jurack@sib-siemens.de> writes:

  SJ> I try to parse a text to find a certain pattern. This pattern i'd like
  SJ> to replace with the result of a funktion/sub.

  SJ> $myvar = $myfunction($1);
  SJ> $bla = s/mypattern(.*)mypattern/$myvar/g;
  SJ> or
  SJ> $bla = s/mypattern(.*)mypattern/$myvar($1)/g;

  SJ> The Problem is to get the $1 content of this reg.expr. as parameter of
  SJ> the function!!!!
  SJ> Has anyone an idea how to solve the problem, or another way!

read perldoc perlop and the entry on s///. look for the /e modifier.

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: Thu, 27 Sep 2001 16:21:56 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Regular Expression + Sub
Message-Id: <d7d6rtk473nl88qrle7vnbbsf1fs6bj70f@4ax.com>

On Thu, 27 Sep 2001, Stefan Jurack <stefan.jurack@sib-siemens.de>
wrote:

>$bla = s/mypattern(.*)mypattern/$myvar($1)/g;
>
>The Problem is to get the $1 content of this reg.expr. as parameter of
>the function!!!!

Try /eg instead of just /g - see the "Regexp Quotelike Operators"
section in perlop ("perldoc perlop") for details.

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: Thu, 27 Sep 2001 16:33:00 -0700
From: Stefan Jurack <stefan.jurack@sib-siemens.de>
Subject: Re: Regular Expression + Sub
Message-Id: <3BB3B72C.56DE6932@sib-siemens.de>

THNX *jiipiiii*


Uri Guttman schrieb:

> >>>>> "SJ" == Stefan Jurack <stefan.jurack@sib-siemens.de> writes:
>
>   SJ> I try to parse a text to find a certain pattern. This pattern i'd like
>   SJ> to replace with the result of a funktion/sub.
>
>   SJ> $myvar = $myfunction($1);
>   SJ> $bla = s/mypattern(.*)mypattern/$myvar/g;
>   SJ> or
>   SJ> $bla = s/mypattern(.*)mypattern/$myvar($1)/g;
>
>   SJ> The Problem is to get the $1 content of this reg.expr. as parameter of
>   SJ> the function!!!!
>   SJ> Has anyone an idea how to solve the problem, or another way!
>
> read perldoc perlop and the entry on s///. look for the /e modifier.
>
> 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: 27 Sep 2001 15:53:00 +0200
From: Walter Hafner <hafner@augusta.de>
Subject: testing the "flatness" of a structured file
Message-Id: <qdf8zf0pwoz.fsf@www.ibexnet.de>

Hi!

I'm sure there is a simple solution - i just can't see it.

I have a couple of small, structured files in the form:

 ...
[BEGIN xxx]
 ...
[END xxx]
 ...
[BEGIN yyy]
 ...
[END yyy]
 ...

I want to strip everything between the BEGIN ... END Blocks and write
the blocks (including the delimiters) in an array.

Ok, easily done:

    # slurp input. Files are small enough (< 50 KB)
    open IN, "<testfile" or die $!;
    my $file = join "", <IN>;
    close IN;
    my @chunks = ($file =~ /\[BEGIN.*?\].*?\[END.*?\]/sg);

Now the difficult part:

How can i ensure that there aren't any nested blocks? I don't need to
parse them, i simply need to stop parsing and print an error message.
I know that Perl's regular expressions can't match nested balanced
text.

But it should be possible to test if there's a BEGIN ... BEGIN ... END
pattern.

Since the task isn't time critical, i don't care if the test runs
on the whole file ($file), on the chunks or even during array
generation.

I just don't see it! ARGH! I feel SO stupid!

Help me please or I have to code a single line parser with state
memory. Not difficult but not very stylish either. :-)

Thanks

-Walter


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

Date: Thu, 27 Sep 2001 16:52:44 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: testing the "flatness" of a structured file
Message-Id: <8kd6rtc65td2mulv5kndfb4sgj2m96oj6q@4ax.com>

On 27 Sep 2001 15:53:00, Walter Hafner <hafner@augusta.de> wrote:
>I have a couple of small, structured files in the form:
>
>...
>[BEGIN xxx]
>...
>[END xxx]
>...
>[BEGIN yyy]
>...
>[END yyy]
[...]
>How can i ensure that there aren't any nested blocks? I don't need to
>parse them, i simply need to stop parsing and print an error message.
>I know that Perl's regular expressions can't match nested balanced
>text.

Sounds like a job for extract_tagged in Text::Balanced. You could add
your tags in the reject option.

>But it should be possible to test if there's a BEGIN ... BEGIN ... END
>pattern.

#!/usr/bin/perl -w

use strict;

my $text = << 'END';
delim1
[BEGIN 1]
foo
[END 1]
bla
[BEGIN 2]
bar
[END 2]
delim2
[BEGIN 3]
bar
[END 3]
baz
[BEGIN 4]
foo
bar
[END 4]
feddich
END

my $out;
         
while( $text =~ m/(\[BEGIN\s+(.*?)\](.*?)\[END\s+\2\])/s ){

  $out .= $` ."[BEGIN $2]\n[END $2]";
  $text = $';
  my $capture = $3;
  
  die "Nested blocks $capture: " if $capture =~ m/\[(BEGIN|END).*?\]/

}

$out .= $text;

print $out;

>Since the task isn't time critical, i don't care if the test runs
>on the whole file ($file), on the chunks or even during array
>generation.

The code above is bad because I'm using the pre/postmatch operators -
but since you said that speed wasn't an issue... :-)

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: 27 Sep 2001 06:57:56 -0700
From: richardbriggs@att.com (rab)
Subject: Uninitialized Value...
Message-Id: <900b7105.0109270557.64034589@posting.google.com>

Here's the code snipit....

    27  #open the syslog for reading
    28  open(SYSLOG,"/var/adm/syslog/syslog.log")|| die "cannot open
syslog";
    29
    30  #grep out the offending lines and place them into an array
    31  @rejects = grep /reject/ || /data error/, (<SYSLOG>);
    32  #make the  array components are unique set prev to
anything(foo)
    33  $prev = 'foo';
    34  @reject = grep($_ ne $prev && ($prev = $_), @rejects);
    35
    36
    37  #further refine the array elements only for today's date
    38  @rejec = grep /$dates/, @reject;
    39
    40  #clean up hour parms
    41  my @thatline=split(/ /,$rejec[-1]);
    42  my @thathour=split(/:/,$thatline[2]);
    43  chomp(my $TH=$thathour[0]);
    44  chomp(my $th=$thishour);
    45  my @TD=split(/ /,$rejec[-1]);
    46  chomp (my $td=$TD[1]);
    47
    48  #further...further refine the array elements only for today's
date
    49  @reje = grep /$dates/ && /$th/, @rejec;
    #stripped comment lines###
    59  #Test if this happened this hour & this day or is a relic from
the syslo
    60  #and if so create an error message and send it off to admin
    61  if ($TH == $th && $td == $dates){


Here's the errors...

Use of uninitialized value at rejects line 41, <SYSLOG> chunk 11558.
Use of uninitialized value at rejects line 42, <SYSLOG> chunk 11558.
Use of uninitialized value at rejects line 43, <SYSLOG> chunk 11558.
Use of uninitialized value at rejects line 45, <SYSLOG> chunk 11558.
Use of uninitialized value at rejects line 46, <SYSLOG> chunk 11558.
Use of uninitialized value at rejects line 61, <SYSLOG> chunk 11558.


I know the code is sloppy...I'm still trying to wean myself off shell
scripting and force myself to use perl (be gentle).. but beyond the
ungracefulness of the code..what's causing these errors?

Thanks


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

Date: Thu, 27 Sep 2001 14:27:14 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Win32 Perl - Setting ENV Variables from Command-line
Message-Id: <5fd6rt4fcfcheqbdtn4g3dglpet7s4m9ge@4ax.com>

Jeremy Smith wrote:

>BTW, the server isn't Apache, it's a custom one I'm writing partly as an
>exercise.

Aha. Have you played with HTTP::Daemon?

An interesting approach I tried out, was incorporating all the CGI
scripts I wanted to run into my main script. With a little script I
wrote, that was done automatically, from existing scripts. A very fun
excercise.

>This means I have to work out the ENV variables from the HTTP
>header, which isn't a problem.

HTTP::Daemon does  that for you. Just a source of inspiration.

>Basically, I want my small server program to have CGI scripting via Perl, so
>it just runs Perl after setting all the ENV variables (as if it were a
>'proper' web server).

Two remarks:

 * system, or rather `perl yourscript.cgi`, looks like a better approach
than the dedicated module.

 * localize %ENV, so that after this script is through, all is reset:

	local %ENV = %ENV;
	... # set some environment variables
	my $output = `perl $cgiscript`;
	... # masage headers
	print $output;

-- 
	Bart.


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

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


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