[17370] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4792 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 2 09:10:28 2000

Date: Thu, 2 Nov 2000 06:10:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973174211-v9-i4792@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 2 Nov 2000     Volume: 9 Number: 4792

Today's topics:
    Re: Perl Question <flavell@mail.cern.ch>
    Re: Perl Question <james@NOSPAM.demon.co.uk>
    Re: Perl Question <camerond@mail.uca.edu>
    Re: Perl style and module searches <kent@darwin.eeb.uconn.edu>
    Re: regexp substitution help needed <bart.lateur@skynet.be>
        regexp-question (probably simple?) <fd@orga.com>
    Re: regexp-question (probably simple?) (Rafael Garcia-Suarez)
    Re: SMS - text messaging <MiGuenther@lucent.com>
    Re: SMS - text messaging <ubl@schaffhausen.de>
        strftime and Perl-Version problems pelle1970@my-deja.com
    Re: times array <Peter.Dintelmann@dresdner-bank.com>
        Unix commands via perl? (Dave)
    Re: What's wrong with this regex? <dlorre@caramail.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 2 Nov 2000 11:19:22 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Perl Question
Message-Id: <Pine.GHP.4.21.0011021115480.27197-100000@hpplus03.cern.ch>


On Thu, 2 Nov 2000, James Taylor wrote:

> It's spooky to think that a choice of subject line could render my
> post invisible to a number of knowledgeable people. It feels like an
> indiscriminate censorship, 

On the contrary.  These are discerning readers who are applying 
a justifiably discriminate procedure.

> Do many newsreaders support scorefiles (as opposed to killfiles)?

That's a question that you might raise on an appropriate group.

p.s although I wouldn't count myself amongst the experts, I too would
have disregarded this thread on the basis of its subject header.
I'm only reading it because I see f'ups by people whose judgment I
have learned to respect.



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

Date: Thu, 2 Nov 2000 12:34:08 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Perl Question
Message-Id: <ant0212086d2fNdQ@oakseed.demon.co.uk>

In article <Pine.GHP.4.21.0011021115480.27197-100000@hpplus03.cern.ch>,
Alan J. Flavell <URL:mailto:flavell@mail.cern.ch> wrote:
> 
> p.s although I wouldn't count myself amongst the experts, I too would
> have disregarded this thread on the basis of its subject header.

I felt compelled to read it just because the subject was *such* an
archetypical example of a bad choice. :-D

> I'm only reading it because I see f'ups by people whose judgment
> I have learned to respect.

I tend to read most initial postings just to see if I can help, then
ignore it until someone I respect answers to see if I understand the
answer. So the "score" of the thread varies over time. I don't
suppose these automatic scorefile systems can do that can they?

Getting even further off topic... I find myself going back to old
threads that I evaluate to be more interesting suddenly. However my
newsreader is not good at displaying old articles once I've marked
them read. I was thinking of writing a Perl prog to use the message
references stored in the news spool indexes to track a thread back to
its root and display the articles in date order say. When following
the thread back, should I just stack *all* the references of the
article, find the articles referred to and stack *all* their references
recursively, or is there a more intelligent way of doing this?

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Thu, 02 Nov 2000 07:44:57 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Perl Question
Message-Id: <3A016FD9.A6B39B29@mail.uca.edu>

James Taylor wrote:
> 
> 
> Yes I see what you're saying. The bit I found "spooky" was that
> someone might score certain words very negatively, and I might
> then unknowingly use them in my subject line. For example, say
> you were to score down "money" to avoid make money fast schemes,
> "Perl" and "question" to avoid newbies, and say "CGI" too.
> Then by chance someone might post a subject of
> 
> Questionable ethics of money laundering at Perl/CGI conference
> 
> and get completely ignored by everyone leading the poster to
> think there must be a conspiracy of silence.

If I saw the above subject, I would probably reply that the question is
more suitable at mach.washing.maytag or misc.entrepreneurs.laundry.coin.

Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu


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

Date: 02 Nov 2000 07:50:07 -0500
From: Kent Holsinger <kent@darwin.eeb.uconn.edu>
Subject: Re: Perl style and module searches
Message-Id: <m0hf5qv8qo.fsf@darwin.eeb.uconn.edu>

>>>>> "Dave" == Dave E <dave_at_hm@hotmail.com> writes:

    Dave> 1) Is there a style, or "best
    Dave> practices" guide for Perl?  I am a network administrator

perldoc perlstyle

-- 
Kent E. Holsinger                kent@darwin.eeb.uconn.edu
                                 http://darwin.eeb.uconn.edu
-- Department of Ecology & Evolutionary Biology          
-- University of Connecticut, U-3043                                       
-- Storrs, CT   06269-3043                                               


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

Date: Thu, 02 Nov 2000 11:43:14 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: regexp substitution help needed
Message-Id: <ifk20t8taj4c0d2a68h0mcp8m55nem8d16@4ax.com>

Ren Maddox wrote:

>> s/[\w'-]+/ TEXT /gis;
>> will substitute TEXT for all words including TAG;
>> Can I get this to substitute all words in the text except for the word TAG.


That would be a great job for semantic checks. But these aren't to be
expected before Perl6.  ;-) Not unless you want to do it in a very
unreadable way, anyway.

>s/\b(?!TAG)[\w'-]+/TEXT/g;
>
>You apparently want to include ' and - as part of a word, so I have
>done the same.

What do you have against "TAGGY"? I think that in your lookahead, you
want to test for word boundaries too.

	s/\b(?!TAG\b)[\w'-]+/TEXT/g;

That still will exclude

	TAG'O'GRAM

which is a "word" according to the OP's definition. And you can't put
lookahead inside lookahead, AFAIK.

	s/\b(?!TAG(?:[^\w'-]|$))[\w'-]+/TEXT/g;

Er... clumsy, innit?

-- 
	Bart.


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

Date: Thu, 02 Nov 2000 13:23:29 +0100
From: Felix =?iso-8859-1?Q?Dr=FCke?= <fd@orga.com>
Subject: regexp-question (probably simple?)
Message-Id: <3A015CC1.D18D57BD@orga.com>

Hi,

why doesn't the following work?

@list = ("line1 xline1","line2 xline2","line3 xline3");
print "---  print \$_ if xline1 not matched\n";
for (@list) { print "$_\n" if !/xline1/ }
print "---  print \$_ if ^line2 not matched (?)\n";
for (@list) { print "$_\n" if /^(?!line2)/ }
print "---   print \$_ if xline3 not matched (?why does it not
work?)\n";
for (@list) { print "$_\n" if /(?!xline3)/ }

My output is:
---  print $_ if xline1 not matched
line2 xline2
line3 xline3
---  print $_ if ^line2 not matched (?)
line1 xline1
line3 xline3
---   print $_ if xline3 not matched (?why does it not work?)
line1 xline1
line2 xline2
line3 xline3

But I did not expect the last line. 
Why was "line2" not matched in the second example, but xline3 was
matched in the third example ?
What would be the best method to NOT match something without
saying "if !/bla/" ?

Felix


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

Date: Thu, 02 Nov 2000 12:45:00 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: regexp-question (probably simple?)
Message-Id: <slrn902ohp.nik.rgarciasuarez@rafael.kazibao.net>

Felix Drüke wrote in comp.lang.perl.misc:
>Hi,
>
>why doesn't the following work?
>
>@list = ("line1 xline1","line2 xline2","line3 xline3");
>print "---  print \$_ if xline1 not matched\n";
>for (@list) { print "$_\n" if !/xline1/ }
>print "---  print \$_ if ^line2 not matched (?)\n";
>for (@list) { print "$_\n" if /^(?!line2)/ }
>print "---   print \$_ if xline3 not matched (?why does it not
>work?)\n";
>for (@list) { print "$_\n" if /(?!xline3)/ }
>
>My output is:
>---  print $_ if xline1 not matched
>line2 xline2
>line3 xline3
>---  print $_ if ^line2 not matched (?)
>line1 xline1
>line3 xline3
>---   print $_ if xline3 not matched (?why does it not work?)
>line1 xline1
>line2 xline2
>line3 xline3
>
>But I did not expect the last line. 
>Why was "line2" not matched in the second example, but xline3 was
>matched in the third example ?

(?!xline3) is an assertion, not a negation. The third regexp says :
match an empty string that is not followed (or preceded) by xline3. The
2d example works because of the ^ anchor : "match a beginning-of-string
that is not followed by line2". See the perlre documentation for
details.

>What would be the best method to NOT match something without
>saying "if !/bla/" ?

I don't think there's a general solution for this question. It looks
like you're using user-supplied patterns in your program. Try another
approach.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Thu, 2 Nov 2000 09:30:49 +0100
From: "Michael Guenther" <MiGuenther@lucent.com>
Subject: Re: SMS - text messaging
Message-Id: <8tr8mn$q43@nntpa.cb.lucent.com>


Steve wrote in message <3A00C420.2914@yahooNOSPAM.co.uk>...
>Richard J. Rauenzahn wrote:
>>
><snip>
>>
>> I wish many posters on clpm would try to write clearer questions.
>
>Sorry I thought it was clear ;-) - I want visitors to my site to be
>able to send text messages (sms) from my site to a mobile phone
>of their choice. They type a text message into an input box - then
>type the phone number and then press send and it's sent to the phone.
>
>Any Ideas?
>
>cheers
>
>
>Steve

What you need is gateway where you can drop your messages to be send to the
specific phone
(I unless you work for a phone you will not have something like this
available for free. Or you work like an asshole and use the WebPages from
e.g.. www.blu.it they allow to send messages for "free" means on their cost,
to all over the world.)

Then you have to find out which way they will have the data.
It's simple just debug their page ( It's your task).
once you have done this do a HTML ( or what ever ..: It's browser
communication you should be able to imitate this) request on their page .

(Its a real hack)
And I'm not sure if using their holes is illegal or not








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

Date: Thu, 02 Nov 2000 09:46:41 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: SMS - text messaging
Message-Id: <3A0129F1.4A99183B@schaffhausen.de>

Steve schrieb:
> 
> Richard J. Rauenzahn wrote:
> >
> <snip>
> >
> > I wish many posters on clpm would try to write clearer questions.
> 
> Sorry I thought it was clear ;-) - I want visitors to my site to be
> able to send text messages (sms) from my site to a mobile phone
> of their choice. They type a text message into an input box - then
> type the phone number and then press send and it's sent to the phone.
> 
> Any Ideas?

This should be an FAQ. HAve you ever noticed you pay for an SMS. If your 
visitors are supposed to send it for free, youÄll have to pay for the message
so you first have to cut a deal with a cell phone service provider, before
you can start thinking about programming

malte


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

Date: Thu, 02 Nov 2000 08:38:40 GMT
From: pelle1970@my-deja.com
Subject: strftime and Perl-Version problems
Message-Id: <8tr96g$k6i$1@nnrp1.deja.com>

Hi everyone,
I had posted this to alt.perl without an answer. Maybe someone here can
comment?

Hi there,

 I've got two (or more) LINUX-machines. Perl installations are:
 This is perl, version 5.005_03 built for i386-linux
 This is perl, version 5.004_04 built for i586-linux

 And I have something like this:
   use POSIX qw(strftime);

   my @mytime1 = localtime();
   my @mytime2 = @mytime1;
   if( $mytime1[4]==1 )
     { $mytime1[4]=11; }  # change of year
   else
     { $mytime1[4]--; }
   print "\nBareTime1: $mytime1[4] -- BareTime2: $mytime2[4]";   my
$datestr1 = strftime("%Y%m01",@mytime1);
   my $datestr2 = strftime("%Y%m01",@mytime2);
   print "\nDateString1: $datestr1 -- DateString2: $datestr2";

 When I run this on Perl 5.004..., everythings works fine.
 But on 5.005, if mytime[4]==8 or mytime[4]==9, I always get month 10,
that is october. Well, for mytime[4]==9 that is what I'd expect, but for
mytime[4]==8 that is
 definately not what I expect!!!
 Every other month works fine!!! (Well, I haven't tested EVERY month,
but a couple of them)

 In other words: My output is something like this:

 BareTime1: 8 -- BareTime2: 9
 DateString1: 20001001 -- DateString2: 20001001


 Any ideas anyone?
 I've also tried to add a "use locale;" without any results. Your help
is greatly appreciated!

 Thanks,
 Carsten.



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 2 Nov 2000 10:53:23 +0100
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: times array
Message-Id: <8trdkb$gq81@intranews.bank.dresdner.net>

    Hi,

    see the posting of Chris for the difference between
    time() and times().

    The special $^T contains the starting time of your script.
    Thus

        sleep 5;
        print time - $^T;

    should simply print "5".

    Best regards,

        Peter Dintelmann





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

Date: Thu, 02 Nov 2000 11:32:03 GMT
From: dave@;so-.mail (Dave)
Subject: Unix commands via perl?
Message-Id: <3a01504b.8185466@news.redhotant.com>

Is it possible to use all unix commands via perl ?

e.g. rm with a switch -  

rm -s something ?

Dave


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

Date: Thu, 02 Nov 2000 09:59:15 GMT
From: Dominique Lorre <dlorre@caramail.com>
Subject: Re: What's wrong with this regex?
Message-Id: <8trdth$nf9$1@nnrp1.deja.com>

In article <3A00C754.69AE014@ot.com.au>,
  Ian Boreham <ianb@ot.com.au> wrote:
>  Dominique Lorre wrote:
>
> > In article <39FCAB13.15D27DC8@ot.com.au>,
> >   Ian Boreham <ianb@ot.com.au> wrote:
> > > Dominique Lorre wrote:
> > >
> > > > $some_variable = $1 + $2/$3
> > > >
> > > > when $3 is zero you will get an error.
> > >
> > > True, but the code below gives an incorrect answer, when an error
is
> > > preferable.
> > >
> > Not here, you should first look at what is doing the code before
giving
> > your opinion.
>
> You didn't test this, though, did you? I did (see "Nov 10" example
below),
> and it gives an incorrect answer, when it should give an error.
>
I have tested it and I have performed *a few changes* (ahem) on the fly
during the posting. To be more precise, the changes I made were on the
last print line, I also moved from // pattern to || and I put a line
break for keeping the regexp integrity. This explains the errors you
found when compiling. Sorry about that.




>
> I'd recommend you use "undef" as an "undef marker". Negative numbers
can't
> be read from the data, but -1 may have some meaning in this (problem)
> context. It doesn't affect the examples in the OP, so I'll leave it
as is,
> here.
Ok, thanks for the advice.

> Yes, it makes more sense now, but I will argue that $1, $2 and $3 are
not
> always being set correctly.
Provided the set of examples these values are always set correctly. In
another world with different examples these values are not always set
correctly. So you have added examples illustrating that the level of
error detection was insufficient without real knowing of what is going
on.
>       "00 Nov 21 #9/11 (Blah)",
This example is irrealistic if the source is computer generated, and
much likely to happen if it is hand written. But then, I will say that
your code is not enough protected against errors, because why a
mistyping would add a # and never go wrong on the date (these are
obviously dates) ? So we should check against something like :
00 Niv 21
or
00 Feb 30
or
00 Nov 41

As you can see, the level of error detection is context dependent.


> > > > print "$some_variable = $some_variable\n" ;
> > >
> > > This will print the value twice. You should escape the first "$".
> > >
> > I am not sure to understand what you mean.
>
> This in known in computer science terms as "printing the same thing
twice".
Oh, I still don't understand why you are arguing about that, I
obviously mistyped here.

> Well, now that my misconception has been rectified, it certainly
seems to
> go a long way towards a correct solution.
If you really plan to improve the error checking, you will discover
that the problem is more complex than what you established.

But code can be designed to be a contract, i.e. the routine would be
guaranteed to have coherent input and would do no any error checking
that would have been done by the source generator. That is why the
divide by zero error is checked: it is produced in a normal case (i.e.
no / char). You cannot design a program efficiently if you don't trust
your source, so you check only the errors that are of your
responsibility : I am guaranteed that the format is "YY Mmm DD
[N/d]..." and I guarantee to provide a numeric result which is DD + N/d.

Setting $some_variable to -1 allows error detection in case of abnormal
use of this routine.

Regards


Sent via Deja.com http://www.deja.com/
Before you buy.


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4792
**************************************


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