[19702] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1897 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 9 14:05:52 2001

Date: Tue, 9 Oct 2001 11:05: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: <1002650711-v10-i1897@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 9 Oct 2001     Volume: 10 Number: 1897

Today's topics:
        Accessing Public Scripts (Andrea)
        Anyone know of a SNMP MIB browser <tmciver@yottanetworks.com>
    Re: binmode with "perl -p" doesn't work (Peter J. Acklam)
        CGI.pm :: OO or not? <lmoran@wtsg.com>
    Re: CGI.pm :: OO or not? <ilya@martynov.org>
        Checking Network Access <MrsKensingtonUK@yahoo.co.uk>
    Re: Checking Network Access nobull@mail.com
        Date calculation <philippe.perrin@sxb.bsf.alcatel.fr>
    Re: Date calculation (Anno Siegel)
    Re: Date calculation <JPFauvelle@Colt-Telecom.fr>
        getting Perl to wait <mg@netops.de>
    Re: hash problem <Thomas@Baetzler.de>
    Re: hash problem (Clinton A. Pierce)
    Re: HTML Template Parsing Problem nobull@mail.com
    Re: I need help with an add and print function <Laocoon@eudoramail.com>
        Match first valid sentence. (Simon)
    Re: Match first valid sentence. <blahdeblah@wahwahwah.boohoo>
    Re: Match first valid sentence. <rsherman@ce.gatech.edu>
    Re: Match first valid sentence. (Eric Bohlman)
    Re: Newbie basic question on splitting strings (Richard)
    Re: Newbie basic question on splitting strings <jurgenex@hotmail.com>
    Re: pid list of childs (Martien Verbruggen)
        regex substitution <joerivdv007@hotmail.com>
    Re: regex substitution <jessica.bull@broadwing.com>
    Re: Shouldn't /c preserve pos() when matching in list c (Randal L. Schwartz)
    Re: Shouldn't /c preserve pos() when matching in list c (Anno Siegel)
    Re: Signaling (Clinton A. Pierce)
    Re: Signaling (Clinton A. Pierce)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 9 Oct 2001 06:16:36 -0700
From: rubash@navigatenewmedia.com (Andrea)
Subject: Accessing Public Scripts
Message-Id: <16986fd1.0110090516.797f3d4f@posting.google.com>

I don't know WHAT possessed me to choose such a non-descriptive
subject line for my post.  Sorry.

rubash@navigatenewmedia.com (Andrea) wrote in message news:<16986fd1.0110090223.679ed5c6@posting.google.com>...
> I have my site set up to use the standard form mail from my hosting
> company (dellhost).  Everything works, because the variable names were
> listed in the sample HTML document...  (it's not the same formmail as
> the one at Matt's Script Archive)
> 
> However, I can't access the script.. and the standard redirect = URL
> has no effect.  So... instead of my nice little thank you page, users
> get an ugly white page with black text.
> 
> I have no idea how to tell this script that I haven't even seen where
> to direct users when they have submitted an e-mail.  How do I find out
> what variable they are using so I can tell the script to direct my
> users there?
> 
> Andrea


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

Date: Tue, 9 Oct 2001 10:20:23 -0500
From: "Tony McIver" <tmciver@yottanetworks.com>
Subject: Anyone know of a SNMP MIB browser
Message-Id: <7EB97BF7C3E7EFC5.AD082038A05688C5.133C5F0788500477@lp.airnews.net>

Hello All,
    I am writing a perl script that uses the NET::SNMP module. I need to get
a MIB browser so I don't have to figure out all of the OID's manually. Does
anyone know of a free MIB browser out on the web somewhere. It would really
be a big help if I could find one.

Thanks in advance,

Tony




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

Date: 09 Oct 2001 15:53:41 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: binmode with "perl -p" doesn't work
Message-Id: <ofngc42i.fsf@online.no>

Bart Lateur <bart.lateur@skynet.be> wrote:

> This is safer -- and doesn't need the variable:
> 
> 	# Wild.pm - emulate shell @ARGV expansion on shells that don't
> 	use File::DosGlob;
> 	@ARGV = map {
> 	            /[*?]/ ? File::DosGlob::glob($_)  : $_;
>                    } @ARGV;
> 	1;
> 
> Plus:  if one of your "arguments" is a command line switch, you likely
> don't want to replace it.

Yet another variant.  Here's the one I have used for a few years.
It's more "noisy", but prints a (unix shell-like) warning if the
glob matches nothing.

    sub glob_arg_list (@) {
        map { m! (^|/)~ | [*?{}[\]^%] !x
              ? do {
                    my @files = glob
                      or warn "$program: $_: No such file or directory\n";
                    @files;
                }
              : $_ } @_;
    }

    @ARGV = glob_arg_list @ARGV if $^O =~ /^MS/;

Peter

-- 
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;


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

Date: Tue, 09 Oct 2001 12:04:59 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: CGI.pm :: OO or not?
Message-Id: <h086st8fjldp7lm0qjtvvf43quhn12d46l@4ax.com>

--I just started using CGI.pm and I have noticed that while perldoc
CGI recomends OO funtionality but I rarely see it in use.

--Several of the books/tutorials mention that you can use references
but that "function based" CGI(.pm) is easier to read so they use that
instead.

--So if --*YOU*-- were using CGI.pm to accomplish some task would you
write it utilizing the OO approach or the function based approach?

--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com


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

Date: 09 Oct 2001 20:42:43 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: CGI.pm :: OO or not?
Message-Id: <874rp8bw8s.fsf@abra.ru>

>>>>> On Tue, 09 Oct 2001 12:04:59 -0400, Lou Moran <lmoran@wtsg.com> said:

LM> --I just started using CGI.pm and I have noticed that while perldoc
LM> CGI recomends OO funtionality but I rarely see it in use.

LM> --Several of the books/tutorials mention that you can use references
LM> but that "function based" CGI(.pm) is easier to read so they use that
LM> instead.

LM> --So if --*YOU*-- were using CGI.pm to accomplish some task would you
LM> write it utilizing the OO approach or the function based approach?

I use OO interface. The reasons are simple: I don't like pollution of
namespace and it is often convenient to have an object that can be
passed into various parts of application.

As for 'is easier to read'. I actually use only 'param' and 'upload'
methods of CGI so it is not very hard to type $cgi->param('name') and
it hardy hurts readability of code. My IMHO is that usage of all other
functionality of CGI.pm should be avoided because good web application
should try to separate business logic from presentation (i.e. use some
templating systems for generation of HTML code).

As for (books/tutorials) I suspect that *some* of them are written by
not very experienced programmers. For such programmers usage of OOP
itself is not very comfortable since they are not familiar with it so
they avoid OO interface at all. My IMHO is that experienced web
developers *don't* use CGI.pm (with exception for incoming data
processing methods like 'param' and 'upload') so they just don't
write such tutorials where OO interface of CGI.pm is used.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Tue, 9 Oct 2001 17:01:29 +0100
From: "MrsKensingtonUK" <MrsKensingtonUK@yahoo.co.uk>
Subject: Checking Network Access
Message-Id: <1002643293.2973.0.nnrp-10.3e31b93c@news.demon.co.uk>

As BT keep on cutting off our ADSL unexpectedly i've decided to write a perl
script to show the state of e-mail, internet and internal network access, so
people in other departments can check if there are any errors before phoning
technical support.
I have an idea on checking the Internal Network and internet access. They
both involve copying a file and timing how long it takes and from there
deciding if it is running fine, slow or not at all.
For the local network i'm copying a 1Mb file off one of our servers and for
the internet access i'm copying a 100K file off demons FTP site (it's a test
file so it'll always be there).

I have this at the top of my page
use File::Copy;
$localFile = "\\\\amy\\Shr_Docs2\\doNotDelete";

my current code is

#get start time
$startTime = getCurrentTime();
#do job
getSpeedOfLocalNetwork($localFile);
#get end time
$endTime = getCurrentTime();
#get time difference
print getTimeTaken($startTime, $endTime);


where getSpeedOfLocalNetwork() is...

sub getSpeedOfLocalNetwork()
{
    my ($file) = @_;
    my $toReturn = -1;
    if (copy($file, "c:\emptyFile"))
    {
        $toReturn = 1;
    }
    else
    {
        $toReturn = 0;
    }
    return $toReturn;
}


for some reason it always returns 0! What am I doing wrong?

Is there a better way of testing/timing it?

Thanks alot for your help

Mrs Kensington

p.s. oh and I definately got the path correct




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

Date: 09 Oct 2001 18:24:08 +0100
From: nobull@mail.com
Subject: Re: Checking Network Access
Message-Id: <u9vgholoav.fsf@wcl-l.bham.ac.uk>

"MrsKensingtonUK" <MrsKensingtonUK@yahoo.co.uk> writes:

>     if (copy($file, "c:\emptyFile"))
> 
> for some reason it always returns 0! 

What $! reason? 

> What am I doing wrong?

Not telling us the reason.  

BTW: Are you sure you want an escape ( chr(27) aka "\e" ) in the file name. 

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


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

Date: Tue, 09 Oct 2001 17:45:54 +0200
From: Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr>
Subject: Date calculation
Message-Id: <3BC31BB2.EAE74544@sxb.bsf.alcatel.fr>

Hello

I need to calculate the amount of time elapsed between two dates (given
by dom, month, hour, minutes, seconds). I do NOT need other
calculations.
1) Is there a (fast) way to know the difference between the two ? (or a
function performing the opposite of the localtime() function in list
context)
2) If not, which date package should I use ? There are so many on CPAN,
I don't know which one fits best (I don't need 90% of the features they
offer).

thanks for any advice !

-- 
PhP

($r1,$r2,$r3,$r4)=("19|20","0|1","28|29","5|24");($r5,$r6)=("9|10|15|16|$r1|$r2","9|10|$r3");%h=("1|",$r6,"1=","[1-5]|2[0-4]","1/","0|19","1\\","6|25","2|","0|6|19|25|$r6","2/","1|20","2\\",$r4,"3|","$r2|6|$r1|25|$r6","3/",$r4,"4|","$r2|$r1|$r6","4=","2|3|4|11|12|13|14|21|22|23","4/",$r4,"4\\",15,"5|","$r2|9|15|$r1|20|$r3","5/",10,"6|",$r5,"7|",$r5,"7/",$r3);for($l=1;$l<8;$l++){b:for($i=0;$i<30;$i++){c:foreach(keys
%h){next c if(!(/^$l(.*)$/));$a=$1;if($i=~/^($h{$_})$/){print $a;next
b;}}print " ";}print "\n";}


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

Date: 9 Oct 2001 16:11:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Date calculation
Message-Id: <9pv7j0$fba$3@mamenchi.zrz.TU-Berlin.DE>

According to Philippe PERRIN  <philippe.perrin@sxb.bsf.alcatel.fr>:
> Hello
> 
> I need to calculate the amount of time elapsed between two dates (given
> by dom, month, hour, minutes, seconds). I do NOT need other
> calculations.
> 1) Is there a (fast) way to know the difference between the two ? (or a
> function performing the opposite of the localtime() function in list
> context)

Time::Local does that. It's a base module.

Anno


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

Date: Tue, 09 Oct 2001 18:15:46 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: Date calculation
Message-Id: <ef86stkd9ag145bf9tg0aabof4ccjgquee@4ax.com>

Le Tue, 09 Oct 2001 17:45:54 +0200, Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr> écrit:

perldoc Time::Local

NAME
    Time::Local - efficiently compute time from local and GMT time

SYNOPSIS
        $time = timelocal($sec,$min,$hours,$mday,$mon,$year);
        $time = timegm($sec,$min,$hours,$mday,$mon,$year);

DESCRIPTION
    These routines are the inverse of built-in perl fuctions localtime() and
    gmtime(). They accept a date as a six-element array, and return the
    corresponding time(2) value in seconds since the Epoch (Midnight,
    January 1, 1970). This value can be positive or negative.


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Jean-Philippe Fauvelle  -  jpFauvelle@colt-telecom.fr
Chef de Projets Architecture & Solutions Internet
Audit / Conseil / Formation / Expertise / Pilotage de projets

COLT Telecommunications France - 60, rue de Wattignies 75012 Paris
t +33 (0) 1 70 99 64 98 
f +33 (0) 1 70 99 57 97
w http://www.colt-telecom.fr
a http://www.mappy.fr/PlanPerso/AAAA6FEF5qLAqAEYAAAJQQ==/1
We make business straight.forward
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~



>Hello
>
>I need to calculate the amount of time elapsed between two dates (given
>by dom, month, hour, minutes, seconds). I do NOT need other
>calculations.
>1) Is there a (fast) way to know the difference between the two ? (or a
>function performing the opposite of the localtime() function in list
>context)



>2) If not, which date package should I use ? There are so many on CPAN,
>I don't know which one fits best (I don't need 90% of the features they
>offer).
>
>thanks for any advice !



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

Date: Tue, 9 Oct 2001 17:13:57 +0200
From: "Milan Göllner" <mg@netops.de>
Subject: getting Perl to wait
Message-Id: <9pv3ph$k8dom$1@ID-28578.news.dfncis.de>

Well, I've managed to create a User with Expect.pm remote
controlling passwd, works quite nicely that.

BUT .... the whole thing is based on something like this:

-----
main
    do_some_work
    call sub1()

sub1
    do_some_work
    call sub2()

sub2
    finish_work
    return_to_main()
-----

main is one big while block. This whileblock doesn't seem to wait
for its various subs to finish their work. It rather seems to feed
new data into the various subs which effectively confuses my last
sub (the one with the Expect.pm controlling passwd) and feeds wrong
data to passwd.

I Believe this might be solved with ait, unfortunately I don't get
it ... how is it used ?
Someone ?

Cheers,
Milan




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

Date: Tue, 09 Oct 2001 15:29:24 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: hash problem
Message-Id: <gqu5stk32rgvu2ahpk75ct82r6krl4nvl6@4ax.com>

On Tue, 09 Oct 2001, clintp@geeksalad.org (Clinton A. Pierce) wrote:
>Not at all!  With careful use of locks, and tie-untie'ing the hash
>at appropriate times it's not necessary to get into IPC at all.  I've done
>this quite a few times to write routines that were portable between 
>OS's without a hint of caching problems.

Care to share the code? I'd like to see this.

TIA,
-- 
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: Tue, 09 Oct 2001 16:46:37 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: hash problem
Message-Id: <NRFw7.157070$K6.75198695@news2>

[Posted and mailed]

In article <gqu5stk32rgvu2ahpk75ct82r6krl4nvl6@4ax.com>,
	Thomas Bätzler <Thomas@Baetzler.de> writes:
> Care to share the code? I'd like to see this.

Absolutely.  There's a full-blown working example in Chapter 23 of
TYPi24H, 2ed (see .signature below).  There are partial examples in
Chapter 15 of the same book, both editions.

In psudeocode it works out to:

	get lock  #  Google for mjd's Perl Hardware Store for example
	dbmopen(%foo...)
	change %foo
	dbmclose(%foo...)
	release lock

As long as everyone involed agrees to use the same locking mechanism --
and if the dbm-file is on a sane filesystem -- then everyone plays nice.

-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: 09 Oct 2001 18:17:22 +0100
From: nobull@mail.com
Subject: Re: HTML Template Parsing Problem
Message-Id: <u9y9mklom5.fsf@wcl-l.bham.ac.uk>

"Mike Mackay" <mike@mikemackay.co.uk> writes:

> Subject: HTML Template Parsing Problem

There is no HTML template parsing involved in the situation you
describe.  The template is simply subjected to simple s/// without any
parsing.

> My script reads in the html file and where it finds <--search_result> the
> script replaces it with its results.

Perhaps you should show us your script then?  The script you post does
not look for that target.

Before you post the script you may want to apply all the advice that
is given to all newcommers here. (strict, warnings, check for failure
and so on).

You may also want to see FAQ "How can I read in an entire file all at
once?"

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


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

Date: Tue, 9 Oct 2001 15:27:13 +0200
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: I need help with an add and print function
Message-Id: <Xns91359D35E4E9ALaocooneudoramailcom@62.153.159.134>


>     print $FORM{a1}+$FORM{a2}+$FORM{a3}+$FORM{a4}


Change this to :

my $c = $FORM{a1}+$FORM{a2}+$FORM{a3}+$FORM{a4};
print $c;

>     $FORM{b1}+$FORM{b2}+$FORM{b3}+$FORM{b4}+$FORM{b5}+$FORM{b6}+$FORM{b7};

Change this to :

my $d = $FORM{b1}+$FORM{b2}+$FORM{b3}+$FORM{b4}+$FORM{b5}+$FORM{b6}+$FORM
{b7};
print $d;

Add this :

print $c + $d;


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

Date: 9 Oct 2001 08:24:56 -0700
From: thefairey@hotmail.com (Simon)
Subject: Match first valid sentence.
Message-Id: <ba3a18e0.0110090724.103be0e5@posting.google.com>

I'm currently struggling with a regexp to match the first sentence in
a string and although it works in principal i'm having trouble with
things like floating point numbers and names, i.e. 43.5% or Mr T.Smith

Now I know for perfection Perl would have to understand English but as
with most things it's a case of adding clauses and conditions as you
come across them for the best possible match rather than perfection!!

I'm sure someone must have addressed this in the past and I've tried
scanning the Text modules and the newsgroup but can't seem to find
anything.

If noone knows of an existing solution then i'll battle on and work
something out.

Cheers

Si


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

Date: Tue, 9 Oct 2001 17:46:59 +0100
From: "Mair Allen-Williams" <blahdeblah@wahwahwah.boohoo>
Subject: Re: Match first valid sentence.
Message-Id: <9pv9ka$jt9$1@pegasus.csx.cam.ac.uk>


"Simon" <thefairey@hotmail.com> wrote in message
news:ba3a18e0.0110090724.103be0e5@posting.google.com...
> I'm currently struggling with a regexp to match the first sentence in
> a string and although it works in principal i'm having trouble with
> things like floating point numbers and names, i.e. 43.5% or Mr T.Smith

If you tell it to look for a full stop and then two spaces, does that
eliminate some of the problems?




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

Date: Tue, 09 Oct 2001 12:51:25 +0500
From: Robert Sherman <rsherman@ce.gatech.edu>
Subject: Re: Match first valid sentence.
Message-Id: <3BC2AC7C.8D8B3232@ce.gatech.edu>

Simon wrote:
> 
> I'm currently struggling with a regexp to match the first sentence in
> a string and although it works in principal i'm having trouble with
> things like floating point numbers and names, i.e. 43.5% or Mr T.Smith
> 
> Now I know for perfection Perl would have to understand English but as
> with most things it's a case of adding clauses and conditions as you
> come across them for the best possible match rather than perfection!!
> 
> I'm sure someone must have addressed this in the past and I've tried
> scanning the Text modules and the newsgroup but can't seem to find
> anything.
> 
> If noone knows of an existing solution then i'll battle on and work
> something out.
> 
> Cheers
> 
> Si

well, if you follow the rules, there will be two spaces after the period
at the end of a sentence, just one after abbreviations, and none after
the period in a floating point number...but you can't really count on
people to follow the rules.

but i am as sure as you are that a module somewhere addresses this in a
more thorough manner.

-- 
robert sherman
css, cee
georgia institute of technology
atlanta, ga, usa


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

Date: 9 Oct 2001 17:06:36 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Match first valid sentence.
Message-Id: <9pvaqs$1jc$1@bob.news.rcn.net>

Simon <thefairey@hotmail.com> wrote:
> I'm currently struggling with a regexp to match the first sentence in
> a string and although it works in principal i'm having trouble with
> things like floating point numbers and names, i.e. 43.5% or Mr T.Smith

> Now I know for perfection Perl would have to understand English but as
> with most things it's a case of adding clauses and conditions as you
> come across them for the best possible match rather than perfection!!

> I'm sure someone must have addressed this in the past and I've tried
> scanning the Text modules and the newsgroup but can't seem to find
> anything.

The modules for processing human languages are in the Lingua::* namespace, 
and IIRC there's one with a name like Lingua::En::Sentence, which sounds 
promising.



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

Date: 9 Oct 2001 08:52:22 -0700
From: webmaster@ukparents.co.uk (Richard)
Subject: Re: Newbie basic question on splitting strings
Message-Id: <b9f5ddd3.0110090752.730c3769@posting.google.com>

Thanks to both for replying, its working fine, and I still don't
really understand why !  At least it works, so thanks for your help
guys.

Cheers

Richard

Thomas Bätzler <Thomas@Baetzler.de> wrote in message news:<ddj5sto68m2mbuss7ae5am1645i9qorqiq@4ax.com>...
> On 9 Oct 2001 02:37:26 -0700, webmaster@ukparents.co.uk (Richard) wrote:
> [...]
> > I
> >have a string which always has the same format:  numbers(up to 4 as
> >low as 1) followed directly (ie no spaces) by some text of an unknown
> >length.
> 
> if( $string =~ m/^(\d+)/ ){
>   print "The number is $1\n";
> } else {
>  print "Sorry, no number at start of string\n".
> }
> 
> HTH,


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

Date: Tue, 9 Oct 2001 10:10:29 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Newbie basic question on splitting strings
Message-Id: <3bc32f85$1@news.microsoft.com>

"Richard" <webmaster@ukparents.co.uk> wrote in message
news:b9f5ddd3.0110090137.5179b397@posting.google.com...
> have a string which always has the same format:  numbers(up to 4 as
> low as 1) followed directly (ie no spaces) by some text of an unknown
> length.
>
> eg:  123Wibble,  2332Wobble, 12Foobars  etc
>
> Basically I need to access in a string for use in a PRINT statement
> the numbers, so that I would have for example (as output):
>
> The numbers are:  123,  or The Numbers are 2332 etc.
>
> I can't tell what on earth I should be using to do this, I feel its
> likely it should be a split and RegExp but I can't get my head round
> the syntax.  Can anyone tell me the answer.

Actually the easiest way would be to add "0" to the string. Then the string
would be evaluated in a numerical context which effectively means that the
trailing non-digits will be thrown out.

Try
    print "123Wibble" + 0;

Only caveat: if there is no leading digit you will still get a "0".

jue




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

Date: Wed, 10 Oct 2001 00:21:03 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: pid list of childs
Message-Id: <slrn9s61uf.448.mgjv@martien.heliotrope.home>

On Tue, 09 Oct 2001 13:16:12 +0200,
	Jens Luedicke <jens@irs-net.com> wrote:
> hi ...
> 
> how can I fetch a list of pids of all fork'd child processes?

When you fork, keep track of the pid that gets allocated.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Little girls, like butterflies, need
Commercial Dynamics Pty. Ltd.   | no excuse - Lazarus Long
NSW, Australia                  | 


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

Date: Tue, 09 Oct 2001 15:02:59 GMT
From: "fishy" <joerivdv007@hotmail.com>
Subject: regex substitution
Message-Id: <DkEw7.94987$6x5.20798053@afrodite.telenet-ops.be>

Hi,

I want to substitute a regexp in a text.
E.g.
while (<>) {
    if ($_ =~ /(^| |\.)(B|b)ij(\n| |\.)/) {
        s/(^| |\.)(B|b)ij(\n| |\.)/ /g;
        }
}

The problem is that this only substitutes the first
appearance of the regexp and ignores any further instances of that
regexp on the same line. So if the line says:

bij de bakker en niet bij de kapper

Then the result is:

de bakker en niet bij de kapper

I want both instances of 'bij' deleted from the line. Is there some way of
doing this the right way?

One other problem appears when I want to substitute a
multi-word expression and the words are spread accross lines.
E.g.

while (<>) {
    if ($_ =~ /(^| |\.)(I|i)n(\n| )verband(\n| )met(\n| |\.)/) }
        s/(^| |\.)(I|i)n(\n| )verband(\n| )met(\n| |\.)/ /g;
        }
}

This does not delete the regexp from the text, which is what I want to do.
If two consecutive lines say:

hij zei iets in verband
met het studentenblad

then nothing happens. Can anyone help me?

Thanks a lot.




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

Date: Tue, 09 Oct 2001 15:30:03 GMT
From: "Jessica Bull" <jessica.bull@broadwing.com>
Subject: Re: regex substitution
Message-Id: <%JEw7.427625$Lw3.26841627@news2.aus1.giganews.com>

your regex specifies that it has to be at the beginning of a line.  if you
want the "^" to mean "not", then the expression needs to be in []

> while (<>) {
>     if ($_ =~ /([^| |\.])(B|b)ij(\n| |\.)/) {
>         s/([^| |\.])(B|b)ij(\n| |\.)/ /g;
>         }
> }



"fishy" <joerivdv007@hotmail.com> wrote in message
news:DkEw7.94987$6x5.20798053@afrodite.telenet-ops.be...
> Hi,
>
> I want to substitute a regexp in a text.
> E.g.
> while (<>) {
>     if ($_ =~ /(^| |\.)(B|b)ij(\n| |\.)/) {
>         s/(^| |\.)(B|b)ij(\n| |\.)/ /g;
>         }
> }
>
> The problem is that this only substitutes the first
> appearance of the regexp and ignores any further instances of that
> regexp on the same line. So if the line says:
>
> bij de bakker en niet bij de kapper
>
> Then the result is:
>
> de bakker en niet bij de kapper
>
> I want both instances of 'bij' deleted from the line. Is there some way of
> doing this the right way?
>
> One other problem appears when I want to substitute a
> multi-word expression and the words are spread accross lines.
> E.g.
>
> while (<>) {
>     if ($_ =~ /(^| |\.)(I|i)n(\n| )verband(\n| )met(\n| |\.)/) }
>         s/(^| |\.)(I|i)n(\n| )verband(\n| )met(\n| |\.)/ /g;
>         }
> }
>
> This does not delete the regexp from the text, which is what I want to do.
> If two consecutive lines say:
>
> hij zei iets in verband
> met het studentenblad
>
> then nothing happens. Can anyone help me?
>
> Thanks a lot.
>
>
>




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

Date: 09 Oct 2001 07:08:05 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Shouldn't /c preserve pos() when matching in list context? (Was: Re:  What good is "\G" ...)
Message-Id: <m1elocewje.fsf@halfdome.holdit.com>

>>>>> "David" == David Bouman <david.bouman@nl.xo.com> writes:

David> Joe Schaefer wrote:
>> ... another is that your regexps destroy pos() upon failure.

David> Ah! this reminds me of something I noticed about /c:

David>   perl5 -le '$_="12345a"; 1 while m/\d/cg; print pos'

David> outputs 5 as expected, whereas something like:

David>   perl5 -le '$_="12345a"; @d = m/\d/cg; print pos'

David> doesn't. In fact pos() is undefined just as if /c was never there..

David> It's same in both perl 5.005_03 & 5.6.0 but it doesn't make sense
David> to me.

That's an outstanding bug that I filed two years ago.  I haven't
tried 5.7.2 to see if it was fixed.

-- 
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: 9 Oct 2001 15:46:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Shouldn't /c preserve pos() when matching in list context? (Was: Re:  What good is "\G" ...)
Message-Id: <9pv659$fba$1@mamenchi.zrz.TU-Berlin.DE>

According to Randal L. Schwartz <merlyn@stonehenge.com>:
> >>>>> "David" == David Bouman <david.bouman@nl.xo.com> writes:
> 
> David> Joe Schaefer wrote:
> >> ... another is that your regexps destroy pos() upon failure.
> 
> David> Ah! this reminds me of something I noticed about /c:
> 
> David>   perl5 -le '$_="12345a"; 1 while m/\d/cg; print pos'
> 
> David> outputs 5 as expected, whereas something like:
> 
> David>   perl5 -le '$_="12345a"; @d = m/\d/cg; print pos'
> 
> David> doesn't. In fact pos() is undefined just as if /c was never there..
> 
> David> It's same in both perl 5.005_03 & 5.6.0 but it doesn't make sense
> David> to me.
> 
> That's an outstanding bug that I filed two years ago.  I haven't
> tried 5.7.2 to see if it was fixed.

Nope.

Anno


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

Date: Tue, 09 Oct 2001 16:53:48 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Signaling
Message-Id: <wYFw7.157078$K6.75203016@news2>

[Posted and mailed]

In article <3bc2dfca$1@epflnews.epfl.ch>,
	"plambe" <plambe@yahoo.com> writes:
> I know that I can trigger INT with Ctr+C so I tried another aproach. Again I
> opened like a pipe for writing my executable and with print command I sent
> Ctr+C (\03) to STDIN as I suppose of hvite.exe. It again does not work. It
> seems as it sends this symbol after quitting hvite.exe.

Signals (as Unix people know them) don't really exist in Windows NT.
Process notification doesn't happen that way at all.

IIRC, The SIGINT in the ActiveState Perl is just a hack to treat the 
keyboard ^C interrupt as a signal.  There's no real IPC going on there.

-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Tue, 09 Oct 2001 16:56:59 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Signaling
Message-Id: <v%Fw7.157082$K6.75204799@news2>

[Posted and mailed]

In article <3bc2dfca$1@epflnews.epfl.ch>,
	"plambe" <plambe@yahoo.com> writes:
> I have the following problem:
> I work under WinNT40 and I want to use Signals to glue together  a script
> using external executables. $

The message from p5p which documents this is:

http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-06/msg00740.html


-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

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


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