[21842] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4046 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 30 06:10:44 2002

Date: Wed, 30 Oct 2002 03:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 30 Oct 2002     Volume: 10 Number: 4046

Today's topics:
        ---looking for suidperl <zhaoq@onelink.com.cn>
        [ANNOUNCE] make.pl v0.1.1 -- Make with Perl Syntax and  <occitan@esperanto.org>
        Bijeenkomst Amsterdam Perl Mongers, Dinsdag 5 november  (Johan Vromans)
    Re: Creating a Microsoft Word file with Win32::OLE <ron@savage.net.au>
        How can I remove null entires from an array? <tim@melonhead.remove.net>
    Re: How can I remove null entires from an array? <tassilo.parseval@post.rwth-aachen.de>
    Re: How can I remove null entires from an array? <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: How can I remove null entires from an array? <tim@melonhead.remove.net>
        How to pass control character to a telnet session (Prashant Varghese)
        looking for perl script to report on changed webpages (Me myself & I)
        Matt Wright's FormMail.pl: a little help needed <metaverso@nospam.com>
    Re: Matt Wright's FormMail.pl: a little help needed <jds@trumpetweb.co.uk>
    Re: More Efficient Way To Get Last Line From A TXT File <jlim30@hotmail.com>
    Re: New Perl Module for QA Engineers (derek chen)
    Re: POST filter (hsasshofer)
    Re: read recursive directories (Helgi Briem)
    Re: Recurring problem <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: setreuid on AIX 5.1 with perl 5.6.1 (Villy Kruse)
    Re: significance of 42 for perl, any?!? <dave@dave.org.uk>
        Terminating regex with space or end of line <simon.andrews@bbsrc.ac.uk>
    Re: Terminating regex with space or end of line <simon.andrews@bbsrc.ac.uk>
    Re: Terminating regex with space or end of line <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Terminating regex with space or end of line <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Terminating regex with space or end of line <simon.andrews@bbsrc.ac.uk>
    Re: Terminating regex with space or end of line <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: whatever happened to "static typing hints"? <tassilo.parseval@post.rwth-aachen.de>
    Re: whatever happened to "static typing hints"? <goldbb2@earthlink.net>
    Re: whatever happened to "static typing hints"? <tassilo.parseval@post.rwth-aachen.de>
    Re: whatever happened to "static typing hints"? (tî'pô)
    Re: Why is DESTROY called in scalar context? (tî'pô)
    Re: Why is DESTROY called in scalar context? (tî'pô)
    Re: Why is DESTROY called in scalar context? <bart.lateur@pandora.be>
    Re: Why is DESTROY called in scalar context? (tî'pô)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 30 Oct 2002 14:49:17 +0800
From: "Bill zhao" <zhaoq@onelink.com.cn>
Subject: ---looking for suidperl
Message-Id: <apnvcq$2if8$1@mail.cn99.com>

I have just installed perl-5.8.0 my RH6.2 after uninstall the old
perl-5.00503
(rpm binary). Now I don't have the suidperl which exist in my old
perl-5.00503
I need it in qmail-scanner(virus kill perl script).
Somebody can help me with it?
Thank You in Advance.






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

Date: Thu, 31 Oct 2002 06:38:05 +0100
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: [ANNOUNCE] make.pl v0.1.1 -- Make with Perl Syntax and Semantics
Message-Id: <20021031063805.77a542db.occitan@esperanto.org>

Hi!

Here comes a make in everybody's favourite programming language, Perl, giving you the best of both worlds. You can use it to write a plain makefile, though in Perl syntax. Or, at the other extreme, you can write a program, that among others does a few (file-) depency driven things.

This version includes minor bugfixes as well as a corrected and completed documentation:

http://dapfy.bei.t-online.de/make.pl/

coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer


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

Date: 29 Oct 2002 12:11:30 +0100
From: jvromans@squirrel.nl (Johan Vromans)
Subject: Bijeenkomst Amsterdam Perl Mongers, Dinsdag 5 november 2002
Message-Id: <m2r8e9jy8t.fsf@phoenix.squirrel.nl>

[English version follows the dutch text]

Amsterdam.pm staat voor de "Amsterdamse Perl Mongers", een groep van
gebruikers van Perl. In tegenstelling tot wat de naam suggereert is
Amsterdam.pm niet beperkt tot alleen Amsterdam, maar functioneert, tot
er meer gebruikersgroepen in Nederland zijn, als Nederlandse
gebruikersgroep.

Amsterdam.pm organiseert informele bijeenkomsten waar Perl gebruikers
kunnen samenkomen en informatie en gebruikservaringen met betrekking
tot Perl kunnen uitwisselen. Deze bijeenkomsten vinden normaliter
plaats op elke eerste dinsdag van de maand. De voertaal binnen
Amsterdam.pm is in pricipe Nederlands, maar indien nodig zal Engels
worden gebruikt, b.v. om te communiceren met niet-Nederlandssprekende
aanwezigen.

De eerstvolgende bijeenkomst vindt plaats op dinsdag 5 november van
20:00 tot 22:00 uur op het kantoor van XS4All, Eekholt 42, Diemen. 

Voor een routebeschrijving, zie
http://www.xs4all.nl/contact/routebeschrijving.html

Liefhebbers van een etentje vooraf kunnen tussen 17:45 en 18:15
verzamelen. Om 18:15 (écht om 18:15!) zoeken we een restaurantje in de
buurt om een hapje te eten.

Bezoek onze Web site http://amsterdam.pm.org voor meer details.

[English version]

Amsterdam.pm stands for the Amsterdam Perl Mongers. We're basically a
Perl user group. Despite its name, it is not local to the Amsterdam
environment, but it welcomes Perl mongers from all over the
Netherlands.

Amsterdam.pm organises informal meetings where Perl users can meet,
and exchange information and experiences with regard to using Perl.
The meetings are normally held every first Tuesday of the month.
Although the preferred language for communication is Dutch, English
will be spoken if necessary.

Our next meeting is Tuesday November 5th, from 20:00 till 22:00 at the
office of XS4All, Eekholt 42, Diemen.

See http://www.xs4all.nl/contact/routebeschrijving.html for directions to
get there.

Should you want to join some of us for dinner, please gather between
17:45 and 18:15. At 18:15 sharp we'll leave for a restaurant somewhere
nearby for dinner.

See http://amsterdam.pm.org for more details.

------------------------------------------------------------------------------
Johan Vromans                                             jvromans@squirrel.nl
Squirrel Consultancy                                  Haarlem, the Netherlands
http://www.squirrel.nl                  http://www.squirrel.nl/people/jvromans
PGP Key 2048/4783B14D   KFP = 65 44 CA 66 B3 50 0B 34  CE 0E FB CA 2D 95 34 D0
------------------------ "Arms are made for hugging" -------------------------


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

Date: Wed, 30 Oct 2002 20:23:01 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Creating a Microsoft Word file with Win32::OLE
Message-Id: <apo8eo$6u$1@arachne.labyrinth.net.au>

"Jay Tilton" <tiltonj@erols.com> wrote in message news:3dbf1d77.113404452@news.erols.com...
> Calvin Wong <cawong@cisco.com> wrote:
>
> : Can someone please post a simple code to use Microsoft
> : word to open a new document, place "hello world" in it, save
> : the file, and then close Microsoft word.
>
> Share the code you already have, even if it falls short of the goal.

There's an old tut, # 7, here:

http://savage.net.au/Perl-tuts-1-30.html

but would expect recent versions of Win32::OLE to provide more fancy examples.
--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html




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

Date: Wed, 30 Oct 2002 09:07:08 -0000
From: "Melonhead" <tim@melonhead.remove.net>
Subject: How can I remove null entires from an array?
Message-Id: <1035968837.82677.0@iapetus.uk.clara.net>

My program reads from a | delimited file and stores the values in @emails.
Quite often some the fields will be empty, i.e. the file will be
x@abc.com|||b@123.com||me@home.com etc.  For other reasons the blank fields
in the file must remain so I need a way of removing them from the array.

This bit of code shows my (questionable) logic!

@emails=("","", "", "me\@123.com", "");
for (my $index=0; $index<@emails; $index++) {
     if ($emails[$index] eq "") {
          splice (@emails, $index,1);
          print "spliced - $#emails\n";
          $index=0;
     }
}
print "TOTAL LEFT: $#emails\n";

This gives a result of 1, I thought that it should return 0 as there should
be only one entry in the array.
Am I was off the mark on this one?  I'm sure that there must be a much
easier method?

Regards




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

Date: 30 Oct 2002 09:19:07 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: How can I remove null entires from an array?
Message-Id: <apo86b$d3e$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Melonhead:

> My program reads from a | delimited file and stores the values in @emails.
> Quite often some the fields will be empty, i.e. the file will be
> x@abc.com|||b@123.com||me@home.com etc.  For other reasons the blank fields
> in the file must remain so I need a way of removing them from the array.
> 
> This bit of code shows my (questionable) logic!
> 
> @emails=("","", "", "me\@123.com", "");
> for (my $index=0; $index<@emails; $index++) {
>      if ($emails[$index] eq "") {
>           splice (@emails, $index,1);
>           print "spliced - $#emails\n";
>           $index=0;
>      }
> }
> print "TOTAL LEFT: $#emails\n";

This is indeed a little questionable. You splice() the array while
iterating over it and therefore need to make this contortion of
resetting $index.

Why not a simple grep?

    @emails = grep { $_ ne '' } @emails;
    
Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Wed, 30 Oct 2002 09:29:55 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: How can I remove null entires from an array?
Message-Id: <slrnarv9gb.hhh.bernard.el-hagin@gdndev25.lido-tech>

In article <1035968837.82677.0@iapetus.uk.clara.net>, Melonhead wrote:
> My program reads from a | delimited file and stores the values in @emails.
> Quite often some the fields will be empty, i.e. the file will be
> x@abc.com|||b@123.com||me@home.com etc.  For other reasons the blank fields
> in the file must remain so I need a way of removing them from the array.
> 
> This bit of code shows my (questionable) logic!


"Questionable" to say the very least. :)


> @emails=("","", "", "me\@123.com", "");
> for (my $index=0; $index<@emails; $index++) {
>      if ($emails[$index] eq "") {
>           splice (@emails, $index,1);
>           print "spliced - $#emails\n";
>           $index=0;
>      }
> }
> print "TOTAL LEFT: $#emails\n";
> 
> This gives a result of 1, I thought that it should return 0 as there should
> be only one entry in the array.
> Am I was off the mark on this one?  I'm sure that there must be a much
> easier method?


If you consider a one-liner easier, sure:


@emails = grep { $_ ne '' } @emails;


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Wed, 30 Oct 2002 09:32:09 -0000
From: "Melonhead" <tim@melonhead.remove.net>
Subject: Re: How can I remove null entires from an array?
Message-Id: <1035970334.83246.1@iapetus.uk.clara.net>

Thanks for the prompt reply - that worked great!

Melonhead


"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
message news:apo86b$d3e$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach Melonhead:
>
> > My program reads from a | delimited file and stores the values in
@emails.
> > Quite often some the fields will be empty, i.e. the file will be
> > x@abc.com|||b@123.com||me@home.com etc.  For other reasons the blank
fields
> > in the file must remain so I need a way of removing them from the array.
> >
> > This bit of code shows my (questionable) logic!
> >
> > @emails=("","", "", "me\@123.com", "");
> > for (my $index=0; $index<@emails; $index++) {
> >      if ($emails[$index] eq "") {
> >           splice (@emails, $index,1);
> >           print "spliced - $#emails\n";
> >           $index=0;
> >      }
> > }
> > print "TOTAL LEFT: $#emails\n";
>
> This is indeed a little questionable. You splice() the array while
> iterating over it and therefore need to make this contortion of
> resetting $index.
>
> Why not a simple grep?
>
>     @emails = grep { $_ ne '' } @emails;
>
> Tassilo
> --
> $_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
> pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
> $_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;




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

Date: 30 Oct 2002 02:08:26 -0800
From: pv79@ddsl.net (Prashant Varghese)
Subject: How to pass control character to a telnet session
Message-Id: <5ff7e2e0.0210300208.4d044128@posting.google.com>

Dear all,

has anyone tried passing control character over telnet session to a
remote host.
the formats mentioned doesn't seem to work.
i;ve been trying to find a way to pass '^]' to terminate the telnet
session in the following manner.

$r->print ("\c]");

Please tell me if its correct and why it is not working out?

Thanks in advance.

Regards,
Prashant Varghese


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

Date: Wed, 30 Oct 2002 10:06:40 +0000 (UTC)
From: nobody@amc.uva.nl (Me myself & I)
Subject: looking for perl script to report on changed webpages
Message-Id: <slrnarvbpf.kql.nobody@oink.amc.uva.nl>

Hi,
this must be somewhere around, but i can't find it.

I would like the functionality of a program that checks
a list of URL's (e.g. from a file) and reports to me
the pages that have changed since the last check.

It could be a cgi script, or else with email functionality

Anybody know of such script?

TIA
Ewald...

-- 
Ewald H. Beekman, Network Engineer, Academic Medical Center, 
dept.  ADB/ICT Computer & Network Services,  The Netherlands


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

Date: Wed, 30 Oct 2002 10:02:10 +0100
From: Metaverso <metaverso@nospam.com>
Subject: Matt Wright's FormMail.pl: a little help needed
Message-Id: <MPG.1829be81457fcf449898f0@news.mclink.it>

Hello! :-)

I'm an absolute beginner in perl programming, and need a little help for 
a modification I would like to do to the Matt Wright's FormMail.pl 
script I've found at the Matt's Script Archive:

http://www.scriptarchive.com/index.html

I would like to have a script whithout the redirect function, that is a 
script which just sends the email, and then do *nothing*. I'll send 
feedback to the user with a different way. How to obtain a totally "non-
verbose" script? Or to disable the redirect or the return_html function?

Thank you for your help!!! :-)

-- 
Metaverso


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

Date: Wed, 30 Oct 2002 10:54:08 -0000
From: "Julia deSilva" <jds@trumpetweb.co.uk>
Subject: Re: Matt Wright's FormMail.pl: a little help needed
Message-Id: <_ROv9.8047$k6.6784@news-binary.blueyonder.co.uk>

"Metaverso" <metaverso@nospam.com> wrote in message
news:MPG.1829be81457fcf449898f0@news.mclink.it...
> Hello! :-)
>
> I'm an absolute beginner in perl programming, and need a little help for
> a modification I would like to do to the Matt Wright's FormMail.pl
> script I've found at the Matt's Script Archive:
>
> http://www.scriptarchive.com/index.html
>
> I would like to have a script whithout the redirect function, that is a
> script which just sends the email, and then do *nothing*. I'll send
> feedback to the user with a different way. How to obtain a totally "non-
> verbose" script? Or to disable the redirect or the return_html function?
>
> Thank you for your help!!! :-)
>
> --
> Metaverso

Entering stormy waters on the NG mentioning this script, but I'm not going
to get into that now. You could start off by commenting (using # at start of
line) out the lines you do not want to work

# Return HTML Page or Redirect User
#&return_html;

and do not use the hidden field redirect on your web page




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

Date: Wed, 30 Oct 2002 13:32:45 +0800
From: Johnny Lim <jlim30@hotmail.com>
Subject: Re: More Efficient Way To Get Last Line From A TXT File
Message-Id: <qlruru4oplq6cj3s8g4jhlvcg84s3psbi5@4ax.com>

On Wed, 30 Oct 2002 02:50:13 +0100, Dominik Seelow
<kurzhalsflasche@netscape.net> wrote:

< SNIP >
>> 
>
>use File::ReadBackwards;
>
>HTH,
>Dominik

Dominik,

Thanks. Found earlier in Google and downloaded from CPAN. :)


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

Date: 30 Oct 2002 02:00:57 -0800
From: u8526505@ms27.hinet.net (derek chen)
Subject: Re: New Perl Module for QA Engineers
Message-Id: <85789064.0210300200.b19fa1d@posting.google.com>

wanna know if there's any possiblity to support applet or activex operation ?


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

Date: 30 Oct 2002 02:14:57 -0800
From: herbert@sasshofer.com (hsasshofer)
Subject: Re: POST filter
Message-Id: <87548ceb.0210300214.326f3e8f@posting.google.com>

"David K. Wall" <usenet@dwall.fastmail.fm> wrote in message news:<Xns92B675EBE6C0Adkwwashere@216.168.3.30>...
> hsasshofer <herbert@sasshofer.com> wrote on 29 Oct 2002:
> 
> > I want to write a CGI-script that filters some values of a POST
> > request and then re-POSTS the data to another script. How do I
> > transfer the param() values to a HTTP:request with the new post? Do I
> > have to build an escaped string for the $request->content() call
> > manually or is there an easier way to pass a hash to a POST request?
> 
> Look in lwpcook -- it has an example of posting data to a web server with 
> Perl.  If you don't have LWP installed on your system, you'll need to get it 
> from CPAN.  (I don't remember if LWP is in the standard modules or not.)
> 
> Here's a reference from perldoc.com: 
> http://www.perldoc.com/perl5.6/lib/lwpcook.html

Thanks for the help, but I don't have a problem how to do a general
POST.

My problem is that my script gets called by some form POSTING quite a
lot of values, I'll pick a specific one giving me another URL where to
actually POST the whole stuff (I then have to do some transcoding on
the resulting answer, so I have to stay in the loop). Now I have a
foreach loop reading all the param() values, store them in a hash,
build a string of key=value&... pairs, escape the stuff, and supply
this to the content() part of a HTTP:Request for the POST.

Can this be done more easily, getting the param()s back out to the
next post? Without reading them all in, doing the reformatting, and
pushing them back out. Is there a way to supply a hash to the POST, or
only a string. As the keys change I cannot do a manual [key =>
value,...] type of thing.

Thanks for any further help.


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

Date: Wed, 30 Oct 2002 10:42:26 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: read recursive directories
Message-Id: <3dbfb77a.1236667093@news.cis.dfn.de>

On Tue, 29 Oct 2002 19:58:13 GMT, Steven Smolinski
<steven.smolinski@sympatico.ca> wrote:

>> exit(1);
>
>Aside: Is the return value from Windows programs 1 for success?  Odd.

No.

-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: Wed, 30 Oct 2002 05:47:15 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Recurring problem
Message-Id: <slrnaruset.hhh.bernard.el-hagin@gdndev25.lido-tech>

In article <slrnaruor7.23l.tadmc@magna.augustmail.com>, Tad McClellan wrote:
> Mahamane <tourem@nhlbi.nih.gov> wrote:
> 
>> I have a problem that I would like to address to see if someone would
>> be capable of pointing me the direction of the answer.
> 
> 
> Do not use regexes to process HTML (as I said in a followup
> to you a couple of months ago).


You remember that!?


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: 30 Oct 2002 09:53:53 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: setreuid on AIX 5.1 with perl 5.6.1
Message-Id: <slrnarvb1h.2rt.vek@station02.ohout.pharmapartners.nl>

On Tue, 29 Oct 2002 16:28:11 GMT,
    techcog@acme.N3T <techcog@acme.N3T> wrote:


>I don't get it?  The perl programmers are already involved and it's
>broken.
>


Get involved in this thread of discussion, of course.  It would be
interesting for me why that was implemented the way it was.



Villy



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

Date: Wed, 30 Oct 2002 06:58:10 +0000
From: "Dave Cross" <dave@dave.org.uk>
Subject: Re: significance of 42 for perl, any?!?
Message-Id: <pan.2002.10.30.06.58.10.715983@dave.org.uk>

On Mon, 28 Oct 2002 13:46:32 +0000, Dave Peacock wrote:

> In article <5nspru8r8t9fodp8gnv32p1eshr4h9lbgl@4ax.com>, Michele Dondi wrote:
>> I noticed that Benjamin Goldberg's japh sig uses the number 42 at some
>> point, while it could have been anything else. Now, even if I can't
>> find any example at the moment, I seem to recall that 42 arises
>> frequently in such contexts... is there any particular significance of
>> 42 for perl or is it just my impression?
> 
> You need to read "Hitch Hikers Guide to the Galaxy" by Douglas Adams.

Or, better, listen to the original radio series.

Dave...

-- 
  Brian: Oh screw Maximilian!
  Sally: I do.
  Brian: So do I.



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

Date: Wed, 30 Oct 2002 09:23:50 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Terminating regex with space or end of line
Message-Id: <3DBFA526.C011DF83@bbsrc.ac.uk>

I've got a reasonably complex substitution I'm trying to perform which i
need to anchor so that it finishes either with a space, or by the end of
a line.  I've cut the problem down to the example below.


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

Date: Wed, 30 Oct 2002 09:27:11 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Terminating regex with space or end of line
Message-Id: <3DBFA5EF.5961AD51@bbsrc.ac.uk>

Simon Andrews wrote:
> 
> I've got a reasonably complex substitution I'm trying to perform which I
> need to anchor so that it finishes either with a space, or by the end of
> a line.  I've cut the problem down to the example below.

[sorry - hit the wrong button!]
==========================================
#!/usr/bin/perl -w
use strict;

my $string = "bob bog bos";

$string =~ s/bo[bgs]([\s\$])/done$1/g;

print $string;

# Want to get "done done done"
==========================================

In this case the terminating $ is being treated as a literal $, but how
can I get it interpreted as being an end anchor?  I know I can do this
with two separate regexes, but there must be a nice neat one line
solution.

Thanks for any help

Simon.


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

Date: Wed, 30 Oct 2002 09:31:30 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Terminating regex with space or end of line
Message-Id: <slrnarv9jb.hhh.bernard.el-hagin@gdndev25.lido-tech>

In article <3DBFA526.C011DF83@bbsrc.ac.uk>, Simon Andrews wrote:
> I've got a reasonably complex substitution I'm trying to perform which i
> need to anchor so that it finishes either with a space, or by the end of
> a line.  I've cut the problem down to the example below.


Ummm...?


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Wed, 30 Oct 2002 09:39:25 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Terminating regex with space or end of line
Message-Id: <slrnarva26.hhh.bernard.el-hagin@gdndev25.lido-tech>

In article <3DBFA5EF.5961AD51@bbsrc.ac.uk>, Simon Andrews wrote:
> Simon Andrews wrote:
>> 
>> I've got a reasonably complex substitution I'm trying to perform which I
>> need to anchor so that it finishes either with a space, or by the end of


This is not anchoring.


>> a line.  I've cut the problem down to the example below.
> 
> [sorry - hit the wrong button!]
>==========================================
> #!/usr/bin/perl -w
> use strict;
> 
> my $string = "bob bog bos";
> 
> $string =~ s/bo[bgs]([\s\$])/done$1/g;
> 
> print $string;
> 
> # Want to get "done done done"
>==========================================
> 
> In this case the terminating $ is being treated as a literal $, but how
> can I get it interpreted as being an end anchor?  I know I can do this
> with two separate regexes, but there must be a nice neat one line
> solution.


In a regex []s define a character class. [\s\$] means a whitespace or
the character $. I don't think you can get $ as the end of a line in a
character class, although it's very possible that it won't take too
long for some smart arse to prove me wrong. :) In any case this should
do the trick:


s/bo[bgs](\s|$)/done$1/g;


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Wed, 30 Oct 2002 10:22:01 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Terminating regex with space or end of line
Message-Id: <3DBFB2C9.C28F1F8D@bbsrc.ac.uk>

Bernard El-Hagin wrote:
> 
> In article <3DBFA5EF.5961AD51@bbsrc.ac.uk>, Simon Andrews wrote:
> > Simon Andrews wrote:
> >>
> >> I've got a reasonably complex substitution I'm trying to perform which I
> >> need to anchor so that it finishes either with a space, or by the end of
> 
> This is not anchoring.
>
> > my $string = "bob bog bos";
> >
> > $string =~ s/bo[bgs]([\s\$])/done$1/g;
> >
> > print $string;
> >
> > # Want to get "done done done"
>
> In a regex []s define a character class. [\s\$] means a whitespace or
> the character $. I don't think you can get $ as the end of a line in a
> character class, although it's very possible that it won't take too
> long for some smart arse to prove me wrong. :) In any case this should
> do the trick:
> 
> s/bo[bgs](\s|$)/done$1/g;

Indeed.  Cheers!

With a bit more playing I also found the \z and \Z modifiers.  In this
context is there any difference between using

s/bo[bgs](\s|$)/done$1/g;

and 

s/bo[bgs](\s|\z)/done$1/g; ?


I was also intereted to see that...

s/bo[bgs]([\s\z])/done$1/g;

 ...fails, saying unrecognised escape sequence \z passed through.  I was
surprised to get the error, especially as if I stick \b in instead
(which is kind of similar in function) then I get no warning and
everything runs OK.

Simon.


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

Date: Wed, 30 Oct 2002 11:00:33 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Terminating regex with space or end of line
Message-Id: <slrnarveqa.hhh.bernard.el-hagin@gdndev25.lido-tech>

In article <3DBFB2C9.C28F1F8D@bbsrc.ac.uk>, Simon Andrews wrote:
> Bernard El-Hagin wrote:
>> 
>> In article <3DBFA5EF.5961AD51@bbsrc.ac.uk>, Simon Andrews wrote:
>> > Simon Andrews wrote:
>> >>
>> >> I've got a reasonably complex substitution I'm trying to perform which I
>> >> need to anchor so that it finishes either with a space, or by the end of
>> 
>> This is not anchoring.
>>
>> > my $string = "bob bog bos";
>> >
>> > $string =~ s/bo[bgs]([\s\$])/done$1/g;
>> >
>> > print $string;
>> >
>> > # Want to get "done done done"
>>
>> In a regex []s define a character class. [\s\$] means a whitespace or
>> the character $. I don't think you can get $ as the end of a line in a
>> character class, although it's very possible that it won't take too
>> long for some smart arse to prove me wrong. :) In any case this should
>> do the trick:
>> 
>> s/bo[bgs](\s|$)/done$1/g;
> 
> Indeed.  Cheers!
> 
> With a bit more playing I also found the \z and \Z modifiers.  In this
> context is there any difference between using
> 
> s/bo[bgs](\s|$)/done$1/g;
> 
> and 
> 
> s/bo[bgs](\s|\z)/done$1/g; ?


In your example, no. But look for \Z in perlvar.pod to find out how
exactly \Z differs in behaviour.


> I was also intereted to see that...
> 
> s/bo[bgs]([\s\z])/done$1/g;
> 
> ...fails, saying unrecognised escape sequence \z passed through.  I was
> surprised to get the error, especially as if I stick \b in instead
> (which is kind of similar in function) then I get no warning and
> everything runs OK.


Are you sure? \b in a character class has a different meaning than
elsewhere. Again, look in perlvar.pod for more.


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: 30 Oct 2002 06:18:27 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: whatever happened to "static typing hints"?
Message-Id: <apntjj$374$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Benjamin Goldberg:

> Tassilo v. Parseval wrote:
>> 
>> Also sprach Benjamin Goldberg:

>> > Perl 5.8 has thrown away psuedohashes, and perl 5.9/5.10 will
>> > probably have $spot->meow a compile time error.  Maybe.
>> 
>> How is that supposed to work with AUTOLOAD() for instance, or perhaps
>> weird inheritance hierarchies?
> 
> Good question.  I don't know.  That's why I said, "Maybe".
> 
> Perhaps *if* this is done, there will be a requirement that all methods
> which are autoloaded be stubbed.
> 
> As to wierd inheritance... how might that complicated it?

The stubbed autoloaded methods thing was also what I was able to think
of. As for inheritance, this was a premature shot into the dark...unless
of course you inherit from three classes all having their own
AUTOLOADER() which makes it hard to stub anything.

Anyway, since strict type checking would certainly be optional there's
not much to complain about. It's just an additional feature that would
be useful in a lot of situations (perhaps even as a run time
optimization).

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Wed, 30 Oct 2002 01:52:53 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: whatever happened to "static typing hints"?
Message-Id: <3DBF81C5.4875A457@earthlink.net>

Tassilo v. Parseval wrote:
> 
> Also sprach Benjamin Goldberg:
> 
> > Tassilo v. Parseval wrote:
> >>
> >> Also sprach Benjamin Goldberg:
> 
> >> > Perl 5.8 has thrown away psuedohashes, and perl 5.9/5.10 will
> >> > probably have $spot->meow a compile time error.  Maybe.
> >>
> >> How is that supposed to work with AUTOLOAD() for instance, or
> >> perhaps weird inheritance hierarchies?
> >
> > Good question.  I don't know.  That's why I said, "Maybe".
> >
> > Perhaps *if* this is done, there will be a requirement that all
> > methods which are autoloaded be stubbed.
> >
> > As to wierd inheritance... how might that complicated it?
> 
> The stubbed autoloaded methods thing was also what I was able to think
> of. As for inheritance, this was a premature shot into the
> dark...unless of course you inherit from three classes all having
> their own AUTOLOADER() which makes it hard to stub anything.

Why would that make it hard to stub things?

> Anyway, since strict type checking would certainly be optional there's
> not much to complain about. It's just an additional feature that would
> be useful in a lot of situations (perhaps even as a run time
> optimization).

I dunno... a compile-time optomization could be done.  Eg, suppose that
if you have:
   my Dog $spot = ...;
   $spot->bark(@args);
It does Dog->can('bark') at compile time, stores that sub in the optree,
and effectively does:
   Dog->can('bark')->($spot, @args);

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: 30 Oct 2002 07:19:11 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: whatever happened to "static typing hints"?
Message-Id: <apo15f$6l2$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Benjamin Goldberg:

> Tassilo v. Parseval wrote:

>> The stubbed autoloaded methods thing was also what I was able to think
>> of. As for inheritance, this was a premature shot into the
>> dark...unless of course you inherit from three classes all having
>> their own AUTOLOADER() which makes it hard to stub anything.
> 
> Why would that make it hard to stub things?

You don't always inherit from classes written by you. Looking at the
perldocs of those wont usually help you finding out which methods are
static (in the sense of hard-coded, so reported by UNIVERSAL::can()) and
which are autoloaded and therefore need to be stubbed.

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Wed, 30 Oct 2002 10:19:28 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: whatever happened to "static typing hints"?
Message-Id: <nb5vrug42agdpd1o6fsagv07chijd9l9c9@4ax.com>

Benjamin Goldberg bravely attempted to attach 44 electrodes of
knowledge to the nipples of comp.lang.perl.misc by saying:
>Tassilo v. Parseval wrote:

>> Anyway, since strict type checking would certainly be optional there's
>> not much to complain about. It's just an additional feature that would
>> be useful in a lot of situations (perhaps even as a run time
>> optimization).
>
>I dunno... a compile-time optomization could be done.  Eg, suppose that
>if you have:
>   my Dog $spot = ...;
>   $spot->bark(@args);
>It does Dog->can('bark') at compile time, stores that sub in the optree,
>and effectively does:
>   Dog->can('bark')->($spot, @args);

Won't that go kabloee if someone fiddles with @Dog::ISA ? (if bark's
defined in a base class).


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

Date: Wed, 30 Oct 2002 10:08:14 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Why is DESTROY called in scalar context?
Message-Id: <bn4vruo5t211g2cgf4uv9i055nrcsoj43u@4ax.com>

Rafael Garcia-Suarez bravely attempted to attach 10 electrodes of
knowledge to the nipples of comp.lang.perl.misc by saying:
>Teh (tî'pô) wrote in comp.lang.perl.misc :
>> I wrote a trivial test and DESTROY seems to be called in scalar
>> context, is this always so?
>> 
>> I would have expected void context. I don't know if this has any
>> significance, just wondering.
>
>I just hacked perl to have DESTROY called in void context, and ran the
>test suite. Nothing appeared to break. I'll ask for further
>clarification on P5P.

So... probably no significance.

Thanks, for looking into it.


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

Date: Wed, 30 Oct 2002 10:09:06 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Why is DESTROY called in scalar context?
Message-Id: <fr4vrus0014gs4jhs5uuofsja55c1o7bsv@4ax.com>

brian d foy bravely attempted to attach 13 electrodes of knowledge to
the nipples of comp.lang.perl.misc by saying:
>In article <8uhsru8433uhp1sqld26js8dvl8kcdu60b@4ax.com>, tÓ'pÙ <teh@mindless.com> wrote:
>
>> I wrote a trivial test and DESTROY seems to be called in scalar
>> context, is this always so?
>
>DESTROY is called just before object destruction. 
>
>what are you dong?

Just fooling around [unless you didn't mean "doing" and in that case:
that's a rather personal question ;o)] 


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

Date: Wed, 30 Oct 2002 09:53:46 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Why is DESTROY called in scalar context?
Message-Id: <evavru0fmg7irkqmhi9d5kspf132vvscig@4ax.com>

Teh (tî'pô) wrote:

>I wrote a trivial test and DESTROY seems to be called in scalar
>context, is this always so?
>
>I would have expected void context. I don't know if this has any
>significance, just wondering.

void context is a special case of scalar context. I don't understand why
you even care.

-- 
	Bart.


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

Date: Wed, 30 Oct 2002 12:09:37 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Why is DESTROY called in scalar context?
Message-Id: <7lbvru0uiusikk09kt48tp564vtguevu4f@4ax.com>

Bart Lateur bravely attempted to attach 13 electrodes of knowledge to
the nipples of comp.lang.perl.misc by saying:
>Teh (tî'pô) wrote:
>
>>I wrote a trivial test and DESTROY seems to be called in scalar
>>context, is this always so?

>void context is a special case of scalar context. I don't understand why
>you even care.

That makes two of us.

I dunno, when I see something unexpected (and I'm not in a lazy mood)
I try to understand it, otherwise it might bite me in the rear end at
the least appropriate time.

This specific "unexpected thing" seems to be toothless, which is what
I wanted to find out. On the other hand if someone does check the
return value of DESTROY (as wantarray being defined should indicate)
then I need to know what I should return. I saw nothing in the
documentation so I assumed it's meaningless but I decided to make sure
just to be on the safe side.


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

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


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