[16447] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3859 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 31 14:11:15 2000

Date: Mon, 31 Jul 2000 11:10:22 -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: <965067021-v9-i3859@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 31 Jul 2000     Volume: 9 Number: 3859

Today's topics:
    Re: I Am An Idiot president@whitehouse.gov
    Re: I Am An Idiot <godzilla@stomp.stomp.tokyo>
    Re: I Am An Idiot <flavell@mail.cern.ch>
    Re: I Am An Idiot mexicanmeatballs@my-deja.com
    Re: I Am An Idiot <godzilla@stomp.stomp.tokyo>
    Re: I Am An Idiot <bkennedy@hmsonline.com>
    Re: I Am An Idiot <godzilla@stomp.stomp.tokyo>
    Re: I Am An Idiot <bkennedy@hmsonline.com>
    Re: I Am An Idiot (Marcel Grunauer)
    Re: I Am An Idiot <godzilla@stomp.stomp.tokyo>
    Re: I Am An Idiot <godzilla@stomp.stomp.tokyo>
    Re: Parse::RecDescent with left-recursive grammar. (Abigail)
    Re: Passing File Handler (Juho =?iso-8859-1?Q?Cederstr=F6m?=)
    Re: Perl and MySQL <mstyne@bownemgmt.com>
    Re: perl as part of unix distribution (Joe Broz)
        PERL SCRIPT devo_x@my-deja.com
    Re: PERL SCRIPT (Greg Bacon)
        printf %e exponent digits <jonathan.kuhn@gsfc.nasa.gov>
        Problems connecting DBD::Oracle <csanchez@uf-isf.es>
    Re: Problems connecting DBD::Oracle <gellyfish@gellyfish.com>
    Re: Question on sorting an array (Abigail)
    Re: Question on sorting an array (Abigail)
    Re: Question on sorting an array <fabascal@gredos.cnb.uam.es>
    Re: Question on sorting an array <mjcarman@home.com>
    Re: Question on sorting an array (Marcel Grunauer)
    Re: Question on sorting an array (Abigail)
    Re: Quotes in regex? (Eric Kuritzky)
        regular expression bernd1615@my-deja.com
    Re: Running other programs in background <bart.lateur@skynet.be>
    Re: Running other programs in background ericr@yankthechain.com
        simple regex? pcj1@my-deja.com
    Re: simple regex? (Greg Bacon)
    Re: System background work (Abigail)
    Re: tricky regexp (Abigail)
    Re: tricky regexp <aqumsieh@hyperchip.com>
    Re: tricky regexp (Abigail)
        Use MIME *and* specify the mail server mfreake@iii.co.uk
        When does it pay to presize an array? (Andrew J. Perrin)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 31 Jul 2000 16:13:53 +0100
From: president@whitehouse.gov
Subject: Re: I Am An Idiot
Message-Id: <398597B1.F3BEB2F2@whitehouse.gov>



"Godzilla!" wrote:

> > > > open HANDLE, "not_a_file" or die "Cannot open: $!";
> > > > open HANDLE, "not_a_file" || die "Cannot open: $!";
>
> > > Both kill your program. Reality dictates there is no difference.
>
> > The second of the two lines cannot kill the program, because the string
> > literal is always TRUE.  Failure to open the file will be ignored.
>
> > > * waves another white flag in sarcastic jest *
>
> > Is that an advance acknowledgment of your outright error?
>
> As you know Mr. Rosler ... etc, etc, etc.

[boring bit snipped]

> * smiles *
>
> Godzilla!

Argue, argue, wriggle, wriggle.

He's got you, you're wrong. Be man enough to admit it. ;-)



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

Date: Mon, 31 Jul 2000 08:19:25 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: I Am An Idiot
Message-Id: <398598FD.311C133B@stomp.stomp.tokyo>

Ben Kennedy wrote:

> Godzilla!

(shovels out yet more mule manure)
 
> If you would stop to listen, you might actually hear 
> what people are saying.


When I listen carefully to this group, I only
hear a calliope of mules and jackasses braying.

* cranks her rock & roll up to ten megawatts *

Much better.


Godzilla!

-- 
I will wayward rock you.
http://la.znet.com/~callgirl3/wayward.mid


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

Date: Mon, 31 Jul 2000 17:26:56 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: I Am An Idiot
Message-Id: <Pine.GHP.4.21.0007311724510.9724-100000@hpplus03.cern.ch>

On Mon, 31 Jul 2000, Godzilla! wrote:

> When I listen carefully to this group, I only
> hear a calliope of mules and jackasses braying.

Must seem unfair, then, that they come up with robust working code,
and you muddle around verbosely, never coming up with anything
particularly usable.



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

Date: Mon, 31 Jul 2000 15:44:44 GMT
From: mexicanmeatballs@my-deja.com
Subject: Re: I Am An Idiot
Message-Id: <8m46ta$vm$1@nnrp1.deja.com>

In article <39859381.D385CC5@stomp.stomp.tokyo>,
  "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> mexicanmeatballs@my-deja.com wrote:
>
> >  "Godzilla!" wrote:
> > > Larry Rosler wrote:
> > > > Godzilla! wrote:
>
> (snipped)
>
> > Showing that the || die was ignored, they are _NOT_ the same.
>
> Nobody has said they are the same.
> Where's the beef, meatball?
>
> Godzilla!

Er, you did:

From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: I Am An Idiot
Date: 30 Jul 2000 00:00:00 GMT
Message-ID: <3984C5A8.7320CFAF@stomp.stomp.tokyo>
----
 > open HANDLE, "not_a_file" or die "Cannot open: $!";
 > open HANDLE, "not_a_file" || die "Cannot open: $!";
 Both kill your program. Reality dictates there is no difference.
 * waves another white flag in sarcastic jest *
----

They don't both kill your program, you were wrong.
(It also shows that your famous testing needs work.)

Can you explain the white flag thing, I don't get it?

--
Jon
perl -e '$_="MrqEdunhuClqdph1frp"; print map {chr(ord($_)-3)} split //;'


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


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

Date: Mon, 31 Jul 2000 08:57:57 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: I Am An Idiot
Message-Id: <3985A205.899CD53@stomp.stomp.tokyo>

mexicanmeatballs@my-deja.com wrote:
 
> Godzilla! wrote:
> > mexicanmeatballs wrote:
> > >  "Godzilla!" wrote:
> > > > Larry Rosler wrote:
> > > > > Godzilla! wrote:

> > (snipped)

> > > Showing that the || die was ignored, they are _NOT_ the same.

> > Nobody has said they are the same.
> > Where's the beef, meatball?

> Er, you did:


At no time have I said " or die " and " || die " are
the same. Either you face significant challenges in
reading comprehension or have simply elected to lie.

I believe you may be a bit short on meatballs, meatball.

Godzilla!

-- 
Alturus 5, Gamma Sector, Perl Manglers:
  http://la.znet.com/~callgirl/webchat/nph-chahta.cgi


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

Date: Mon, 31 Jul 2000 16:22:46 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: I Am An Idiot
Message-Id: <qJhh5.74536$A%3.1021143@news1.rdc2.pa.home.com>

> > If you would stop to listen, you might actually hear
> > what people are saying.
>
>
> When I listen carefully to this group, I only
> hear a calliope of mules and jackasses braying.

As I said, maybe you stop listening only to yourself and listen what other
people are saying.  The fact that you are unwilling to enter into a
technical argument leads me to believe you are unable to participate in one.
The fact that you hurl thoughtless, baseless insults and me, someone who has
tried to treat you with respect even though others haven't, leads me to
believe that you are simply a mean-spirited and disrespectful person.  Have
a nice life.

--Ben Kennedy




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

Date: Mon, 31 Jul 2000 09:56:22 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: I Am An Idiot
Message-Id: <3985AFB6.D54A7F6@stomp.stomp.tokyo>

Ben Kennedy wrote:
 
> > > If you would stop to listen, you might actually hear
> > > what people are saying.

> > When I listen carefully to this group, I only
> > hear a calliope of mules and jackasses braying.
 
> As I said, maybe you stop listening only to yourself
> and listen what other people are saying.  The fact that
> you are unwilling to enter into a technical argument leads
> me to believe you are unable to participate in one.
> The fact that you hurl thoughtless, baseless insults and me,
> someone who has tried to treat you with respect even though
> others haven't, leads me to believe that you are simply a 
> mean-spirited and disrespectful person.  Have a nice life.



Clearly Francis, you have mistaken me for someone who cares.

Would you like some cheese with your whine?

Godzilla!

--
@© = (a .. z); @® = qw (7 15 4 26 9 12 12 1 18 15 3 11 19);
srand(time() ^ ($$ + ($$ << 15))); 
sub G { rand(1000) < 500 ? "\u$1" : "\l$1" ; }
foreach $¿ (@®) { $¢ = $©[$¿-1]; $¢ =~  s/([a-z])/G($1)/gie;
if ($¢ =~ /($©[0])/i) { $¢ = "$¢ "; } print $¢; }
print "!"; exit;


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

Date: Mon, 31 Jul 2000 16:57:57 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: I Am An Idiot
Message-Id: <peih5.74544$A%3.1021701@news1.rdc2.pa.home.com>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3985A205.899CD53@stomp.stomp.tokyo...
> At no time have I said " or die " and " || die " are
> the same. Either you face significant challenges in
> reading comprehension or have simply elected to lie.

A little history:

You - > > > Just as I thought; dogmatic || die.
Me -  > > Actually "or die" is better since its lower precedence
You - > Both kill your program. Reality dictates there is no difference.
You - > * waves a white flag in sarcastic jest *

You say in one sentence "Reality dictates there is no difference", but then
you later say "At no time have I said 'or die' and '|| die' are the same".
Most people think that when there is "no difference" between two things,
then the are "the same".  But perhaps you feel differently about this.

--Ben Kennedy







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

Date: Mon, 31 Jul 2000 16:54:12 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: I Am An Idiot
Message-Id: <slrn8obc45.b06.marcel@gandalf.local>

On Mon, 31 Jul 2000 16:57:57 GMT, Ben Kennedy <bkennedy@hmsonline.com> wrote:
>
>"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
>news:3985A205.899CD53@stomp.stomp.tokyo...
>> At no time have I said " or die " and " || die " are
>> the same. Either you face significant challenges in
>> reading comprehension or have simply elected to lie.
>
>A little history:


May I ask you both to take this to private email?


-- 
Marcel
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();


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

Date: Mon, 31 Jul 2000 10:11:21 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: I Am An Idiot
Message-Id: <3985B339.669E3A6E@stomp.stomp.tokyo>

"Alan J. Flavell" wrote:
 
> Godzilla! wrote:
 
> > When I listen carefully to this group, I only
> > hear a calliope of mules and jackasses braying.
 
> Must seem unfair, then, that they come up with robust working code,
> and you muddle around verbosely, never coming up with anything
> particularly usable.


Your braying sounds two semitones short of harmonizing
with the other mules and jackasses braying around here.

* plucks a tang on a barnyard pitchfork *

Middle C if you would please, or plus or minus
one octave keyed to Middle C. Leave semitones
and semantic harmony to those of us with well
practiced angelic, if not devilish voices.

Godzilla!

--
I will pensively rock you.
http://la.znet.com/~callgirl3/nights.mid


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

Date: Mon, 31 Jul 2000 10:30:38 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: I Am An Idiot
Message-Id: <3985B7BE.16C0CD31@stomp.stomp.tokyo>

Ben Kennedy wrote:
 
> Godzilla! wrote:

> > At no time have I said " or die " and " || die " are
> > the same. Either you face significant challenges in
> > reading comprehension or have simply elected to lie.
 
> A little history:
 
> You - > > > Just as I thought; dogmatic || die.
> Me -  > > Actually "or die" is better since its lower precedence
> You - > Both kill your program. Reality dictates there is no difference.
> You - > * waves a white flag in sarcastic jest *
 
> You say in one sentence "Reality dictates there is no difference", but then
> you later say "At no time have I said 'or die' and '|| die' are the same".
> Most people think that when there is "no difference" between two things,
> then the are "the same".  But perhaps you feel differently about this.


I carry a Beretta 9mm handgun within my fashionable personal 
valise of choice, at all times. However, a Smith & Wesson 38 
special will kill you just the same. Reality dictates there
is no difference between the two.

Interesting trivia with a bullet. Nearly twenty-five percent
of Americans are illiterate. Another twenty-five percent are
functional illiterates. Forty percent exhibit average literacy
skills. I gracefully fall within the remaining ten percent.

Godzilla!

--
I love to rock & roll, with an AR-15.
http://la.znet.com/~callgirl5/rockroll.mid


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

Date: 31 Jul 2000 11:16:54 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Parse::RecDescent with left-recursive grammar.
Message-Id: <slrn8ob62q.vcg.abigail@alexandra.foad.org>

Omri Schwarz (ocschwar@mit.edu) wrote on MMDXXVI September MCMXCIII in
<URL:news:398525F0.ABCA33F9@mit.edu>:
--
-- Say, um, a frieend of mine, yeh, that's it, a friend of mine,
-- writes a left-recursive grammar using RecDescent and sets 'nocheck', 
-- and runs it, what could happen?


Did your friend try?



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: 31 Jul 2000 16:49:35 GMT
From: cederstrom@kolumbus.REMOVE_THIS.fi (Juho =?iso-8859-1?Q?Cederstr=F6m?=)
Subject: Re: Passing File Handler
Message-Id: <slrn8oauk2.oe.cederstrom@sitruuna.cedenet.local>

On Mon, 31 Jul 2000 08:52:46 +0200, 
Mouse <glodalec@yahoo.com> wrote:
> Does anyone know, how to pass file handler into subroutine ?

This is a FAQ. 
See section "How do I pass filehandles between subroutines?"

Here's a short example:

-----
#!/usr/bin/perl -w
use strict;
use FileHandle;

my $H = new FileHandle;

open $H, ">foo" or die "A";
&DoSomething($H);
close $H or die "B";

sub DoSomething {
        my $handle = shift;
        print $handle "qwerty\n";
}
-----

-- 
Juho Cederström    -    cederstrom<a>kolumbus.fi    s/<a>/@/


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

Date: Mon, 31 Jul 2000 13:00:36 -0400
From: Mike Styne <mstyne@bownemgmt.com>
Subject: Re: Perl and MySQL
Message-Id: <3985B0B3.A4A8292E@bownemgmt.com>

Robert wrote:

>
> Also, can anyone recommend any good tutorial sites, or books,
> that can help me learn this strange new language?

I've been reading MySQL and mSQL by Yarger, Reese & King. I know nothing about MySQL, and so far it's been a pretty good tutorial.

Mike

--
Jealousy is all the fun you think they have.





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

Date: Mon, 31 Jul 2000 17:02:05 GMT
From: jb@yperite.demon.co.uk (Joe Broz)
Subject: Re: perl as part of unix distribution
Message-Id: <slrn8obfkr.8n.jb@yperite.demon.co.uk>

On 24 Jul 2000 22:02:55 +0200, Lupe Christoph 
<lupe@alanya.lupe-christoph.de> wrote:
>dgallardo@my-deja.com writes:
>
>>Sorry if this is off topic or inflammatory.
>
>>Is perl part of any standard unix distribution?  Are there any moves in
>>this direction.
>
>perl 5.005_03 is included with Solaris 8 (first time to have perl
>on board). It's not on the freeware CD, but on one of the OS CDs.
>
AIX 4.3.3 ships with perl 5.005_03 and IBM supports it as far as
I know. No earlier version of AIX included perl. They will also
support DBD::DB2.

joe



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

Date: Mon, 31 Jul 2000 16:16:04 GMT
From: devo_x@my-deja.com
Subject: PERL SCRIPT
Message-Id: <8m48nt$2g4$1@nnrp1.deja.com>

QUICK QUESTION --
I'M WORKING IN A COLLEGE COMPUETER LAB WITH PERL SCRIPTS
AFTER EXTRACTING "DENY" LOG ENTRIES, I'M ATTEMPTING TO USE NSLOOKUP TO
LOCATE THE SOURCE IP ADDRESS FROM THE URL IN THE DENY LOG
I NOTICED THE GETHOSTBYNAME & GETHOSTBY ADDRESS FUNCTIONS -- UNABLE TO
EXTRACT URL FROM THE DATA NSLOOKUP (DEFAULT -QUERYTYPE=ANY) PRODUCES
ANY HELP WOULD BE APPRECIATED --

DEVO-X@MY-DEJA.COM





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


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

Date: Mon, 31 Jul 2000 17:21:00 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: PERL SCRIPT
Message-Id: <sobdbssq9ft37@corp.supernews.com>

In article <8m48nt$2g4$1@nnrp1.deja.com>,
     <devo_x@my-deja.com> wrote:

: I'M WORKING IN A COLLEGE COMPUETER LAB WITH PERL SCRIPTS
: AFTER EXTRACTING "DENY" LOG ENTRIES, I'M ATTEMPTING TO USE NSLOOKUP TO
: LOCATE THE SOURCE IP ADDRESS FROM THE URL IN THE DENY LOG
: I NOTICED THE GETHOSTBYNAME & GETHOSTBY ADDRESS FUNCTIONS -- UNABLE TO
: EXTRACT URL FROM THE DATA NSLOOKUP (DEFAULT -QUERYTYPE=ANY) PRODUCES

You don't have to use nslookup.  Consider this simple program:

    #! /usr/bin/perl -w

    use strict;

    use Socket;

    my $name = shift || die "Usage: $0 hostname\n";

    if (my $addr = gethostbyname $name) {
        print "$name => ", inet_ntoa($addr), "\n";
    }
    else {
        die "$0: no address for '$name'\n";
    }

Look at recipe 18.1 in the Perl Cookbook (Simple DNS Lookups) for a more
thorough treatment.

: ANY HELP WOULD BE APPRECIATED --

    % perl -pe '$_ = lc'

Greg
-- 
Join the Army: travel to exotic distant lands; meet exciting, unusual people,
and kill them. 


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

Date: Mon, 31 Jul 2000 11:47:08 -0400
From: Jonathan Kuhn <jonathan.kuhn@gsfc.nasa.gov>
Subject: printf %e exponent digits
Message-Id: <39859F7C.96A1F360@gsfc.nasa.gov>

Hello,

How do you set the number of digits for the %e descriptor in printf? I
must have 2 digits, but activeperl under windows nt is giving 3. Perl on
an SGI with IRIX is giving 2.

Sorry if the answer to this is out there somewhere, but I have spent
over an hour searching and haven't found anything.

Jonathan

-- 
  Dr. Jonathan Kuhn
  Mechanical Systems Analysis and Simulation Branch
  NASA Goddard Space Flight Center Code 542
  Greenbelt, MD 20771

  Office: Bldg 5 Room C310A
  Phone:  (301) 286-4278
  FAX:    (301) 286-0204 
  Email:  jonathan.kuhn@gsfc.nasa.gov
  URL:    http://analyst.gsfc.nasa.gov/jkuhn


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

Date: Mon, 31 Jul 2000 17:34:40 +0200
From: "Mamen" <csanchez@uf-isf.es>
Subject: Problems connecting DBD::Oracle
Message-Id: <8m46ge$khm$1@diana.bcn.ttd.net>


When I tried to connect using

$dbh = DBI->connect('dbi:Oracle:ds01','user', 'passwd' )

I obtain this error:

DBI->connect(ds01) failed: Error while trying to retrieve text for error
ORA-12154 (DBD ERROR: OCIServerAttach)

Can anyone tell me what is wrong?




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

Date: Mon, 31 Jul 2000 16:20:33 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Problems connecting DBD::Oracle
Message-Id: <lHhh5.764$82.28797@news.dircon.co.uk>

On Mon, 31 Jul 2000 17:34:40 +0200, Mamen Wrote:
> 
> When I tried to connect using
> 
> $dbh = DBI->connect('dbi:Oracle:ds01','user', 'passwd' )
> 
> I obtain this error:
> 
> DBI->connect(ds01) failed: Error while trying to retrieve text for error
> ORA-12154 (DBD ERROR: OCIServerAttach)
> 

YOu havent got your environment set up correctly .  You might want to ask
on an Oracle newsgroup as it an Oracle configuration issue rather than a
Perl one.


/J\


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

Date: 31 Jul 2000 11:21:25 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Question on sorting an array
Message-Id: <slrn8ob6b9.vcg.abigail@alexandra.foad.org>

Federico Abascal (fabascal@gredos.cnb.uam.es) wrote on MMDXXVI September
MCMXCIII in <URL:news:39858BE3.9E8DC9E7@gredos.cnb.uam.es>:
%% Hello,
%% is there anyway to use the sort function in a way that you can know
%% where the old indexes (positions) go.
%% I mean, for example:
%%     $arr[0] = 12;
%%     $arr[1] = 2222;
%%     $arr[2] = 0.5;
%%     $arr[3] = 3241;
%%     $arr[4] = 5;
%%     $arr[5] = 122;
%% I don't want only to sort it, I want to know that the smallest (0.5)
%% corresponds to the position [2], , so I can go to another array and get
%% the information corresponding to the element [2]
%% I hope you could understand my question and help me
%% Thanks in advance,


@sorted_indices = sort {$arr [$a] <=> $arr [$b]} 0 .. $#arr;


Apply ST or GRT if this is a bottleneck and you want to speed it up.



Abigail
-- 
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: 31 Jul 2000 11:22:32 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Question on sorting an array
Message-Id: <slrn8ob6dc.vcg.abigail@alexandra.foad.org>

Marcel Grunauer (marcel@codewerk.com) wrote on MMDXXVI September MCMXCIII
in <URL:news:slrn8ob4ij.871.marcel@gandalf.local>:
** On Mon, 31 Jul 2000 16:23:32 +0200, Federico Abascal
** <fabascal@gredos.cnb.uam.es> wrote:
** 
** >is there anyway to use the sort function in a way that you can know
** >where the old indexes (positions) go.
** >I mean, for example:
** >    $arr[0] = 12;
** >    $arr[1] = 2222;
** >    $arr[2] = 0.5;
** >    $arr[3] = 3241;
** >    $arr[4] = 5;
** >    $arr[5] = 122;
** >I don't want only to sort it, I want to know that the smallest (0.5)
** >corresponds to the position [2], , so I can go to another array and get
** >the information corresponding to the element [2]
** 
** 
** Something like
** 
**     my @arr = (12, 2222, 0.5, 3241, 5, 122);
** 
**     my %oldpos;
**     @oldpos{@arr} = 0..$#arr;
** 
**     my @sortarr = sort { $a <=> $b } @arr;
** 
**     print "smallest is $sortarr[0], was at pos $oldpos{$sortarr[0]}\n";
** 
** prints
** 
**     smallest is 0.5, was at pos 2
** 
** 
** However, what should happen if there are several elements of equal value
** in @arr (e.g., what if the value 0.5 occurs three times)?


Then it would be shown that your proposed algorithm is flawed.



Abigail
-- 
:$:=~s:$":Just$&another$&:;$:=~s:
:Perl$"Hacker$&:;chop$:;print$:#:


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

Date: Mon, 31 Jul 2000 17:20:21 +0200
From: Federico Abascal <fabascal@gredos.cnb.uam.es>
Subject: Re: Question on sorting an array
Message-Id: <39859935.D0003C6@gredos.cnb.uam.es>

Federico Abascal wrote:

> is there anyway to use the sort function in a way that you can know
> where the old indexes (positions) go.

Well, I found a solution, may be it interests to somebody, may be you can
tell me something better:

for($i = 1; $i <= $#array; $i++) {
    $hash{$i} = $array[$i];
}
foreach $ref ( sort( { $hash{$a} <=> $hash{$b} } keys %hash ) ) {
    #"The smallest now is the value pointed through $ref key, which allows
us to go to the array at index $ref"
}

Cheers,
Federico





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

Date: Mon, 31 Jul 2000 10:15:40 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Question on sorting an array
Message-Id: <3985981C.89F3C68@home.com>

Federico Abascal wrote:
> 
> is there anyway to use the sort function in a way that you can know
> where the old indexes (positions) go.
> I mean, for example:
>     $arr[0] = 12;
>     $arr[1] = 2222;
>     $arr[2] = 0.5;
>     $arr[3] = 3241;
>     $arr[4] = 5;
>     $arr[5] = 122;
> I don't want only to sort it, I want to know that the smallest (0.5)
> corresponds to the position [2], , so I can go to another array and get
> the information corresponding to the element [2]

Sure, sort the indices by the values:

#!/usr/local/bin/perl -w
use strict;

my @arr = (12, 2222, 0.5, 3241, 5, 122);

my @sorted_indices = sort {$arr[$a] <=> $arr[$b]} (0 .. $#arr);

print "Smallest value occurs at index $sorted_indices[0].\n";

q.v. perlfaq4 "How do I sort an array by (anything)?

-mjc


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

Date: Mon, 31 Jul 2000 15:47:00 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: Question on sorting an array
Message-Id: <slrn8ob85f.8jg.marcel@gandalf.local>

On 31 Jul 2000 11:22:32 EDT, Abigail <abigail@foad.org> wrote:

>** However, what should happen if there are several elements of equal value
>** in @arr (e.g., what if the value 0.5 occurs three times)?
>
>
>Then it would be shown that your proposed algorithm is flawed.

Actually, I meant to point out that the OP didn't specify whether in
case of elements with equal value he wanted the lowest index, or the
highest one, or a random index.

    my @arr = (12, 2222, 0.5, 3241, 5, 0.5, 122);
    my @sorted_indices = sort {$arr [$a] <=> $arr [$b]} 0 .. $#arr;
    __END__
    2 5 4 0 6 1 3

But who is to say whether he wanted index 5 or 2?

-- 
Marcel
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();


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

Date: 31 Jul 2000 12:01:32 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Question on sorting an array
Message-Id: <slrn8ob8mf.vcg.abigail@alexandra.foad.org>

Marcel Grunauer (marcel@codewerk.com) wrote on MMDXXVI September MCMXCIII
in <URL:news:slrn8ob85f.8jg.marcel@gandalf.local>:
][ On 31 Jul 2000 11:22:32 EDT, Abigail <abigail@foad.org> wrote:
][ 
][ >** However, what should happen if there are several elements of equal value
][ >** in @arr (e.g., what if the value 0.5 occurs three times)?
][ >
][ >
][ >Then it would be shown that your proposed algorithm is flawed.
][ 
][ Actually, I meant to point out that the OP didn't specify whether in
][ case of elements with equal value he wanted the lowest index, or the
][ highest one, or a random index.
][ 
][     my @arr = (12, 2222, 0.5, 3241, 5, 0.5, 122);
][     my @sorted_indices = sort {$arr [$a] <=> $arr [$b]} 0 .. $#arr;
][     __END__
][     2 5 4 0 6 1 3
][ 
][ But who is to say whether he wanted index 5 or 2?


Since he wants to match with another array with associated data, both (5, 2)
and (2, 5) are acceptable. It's unlikely (2, 2) or (5, 5) are.



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: 31 Jul 2000 18:03:23 GMT
From: kuritzky@math.berkeley.edu (Eric Kuritzky)
Subject: Re: Quotes in regex?
Message-Id: <8m4f1b$h2l$1@agate.berkeley.edu>

In article <slrn8oa3d1.vcg.abigail@alexandra.foad.org>,
Abigail <abigail@foad.org> wrote:
>Eric Kuritzky (kuritzky@math.berkeley.edu) wrote on MMDXXVI September
>MCMXCIII in <URL:news:8m2tuh$dc2$1@agate.berkeley.edu>:
>,, In article <3q0h5.39$DT4.2034686@nnrp2.clara.net>,
>,, Colin Keith <ckeith@clara.net> wrote:
[stuff deleted]
>,, >
>,, >$x =~ s/<font\s+face="arial"\s+size=(2|"2")\s+>//ig;
>,, >
>,, >Takes longer than
>,, >
>,, >$x =~ s/<f.*?\".*?\".*?\".*?\">//ig;
>,, 
>,, Probably because you are using parentheses (see perlre for an
>,, explanation).  Try replacing (2|"2") with (?:2|"2") and see what
>,, happens.
>
>Rubbish. That doesn't change the fact something matches or not. It just
>chances what's in $1.

Yes.  However, Mr. Keith wasn't asking about whether something matched
or not.  He wanted to know why one pattern took longer than another.
According to the documentation, using $1, $', etc. causes _all_
pattern matches to take longer.

--Eric Kuritzky







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

Date: Mon, 31 Jul 2000 17:29:04 GMT
From: bernd1615@my-deja.com
Subject: regular expression
Message-Id: <8m4d0p$5re$1@nnrp1.deja.com>

Dear Readers,

I got the following problem with regular expression
I have comma delimited lines of  a file, from which
I want to extract some Information:

$_ =~ s/{5},(.*?)\,.*/$1/;

# i.e. I want to fetch everything between the 5th and the 6th comma

but I got the following error message:

Modification of a read-only value attempted at ./perl.pl line 16,
<FILE>
chunk 1

Your hints will be appriciated!

Markus




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


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

Date: Mon, 31 Jul 2000 16:52:20 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Running other programs in background
Message-Id: <lkbbos48enpe0qm6rvqcog2qgho07jdu9l@4ax.com>

ericr@yankthechain.com wrote:

>Sorry, I misread your post. I changed the 0 to a 6 and it worked
>perfectsly. Much thanks!

I think that some apps don't like to be hidden. Therefore, making it
minimized without focus (which is what the "6" does) is the better
solution.

-- 
	Bart.


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

Date: Mon, 31 Jul 2000 17:54:38 GMT
From: ericr@yankthechain.com
Subject: Re: Running other programs in background
Message-Id: <8m4egs$79q$1@nnrp1.deja.com>

In article <lkbbos48enpe0qm6rvqcog2qgho07jdu9l@4ax.com>,
  Bart Lateur <bart.lateur@skynet.be> wrote:
> ericr@yankthechain.com wrote:
>
> >Sorry, I misread your post. I changed the 0 to a 6 and it worked
> >perfectsly. Much thanks!
>
> I think that some apps don't like to be hidden. Therefore, making it
> minimized without focus (which is what the "6" does) is the better
> solution.
>
> --
> 	Bart.

Oy, now how do I close the application? The documentation on Win32::API
seems very cryptic to me; I know next to nothing about programming DLLs
or how they work, and if you hadn't said so I would never have guessed
to use it to open programs...


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


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

Date: Mon, 31 Jul 2000 16:28:35 GMT
From: pcj1@my-deja.com
Subject: simple regex?
Message-Id: <8m49fc$30b$1@nnrp1.deja.com>

I'm trying to write a regular expression which matches any text other
than a literal '<|'.  For example the input 'abc<def' should match
completely, while 'abc<|def' should match 'abc'.  I've tried the
following without success:

# anything other than a '<' or '<' followed
# by anything other than a '{'
([^<]|<[^{])+

# add a positive closure to the first option
([^<]+|<[^{])+

# blind swing...
([^<]+|(?:<[^{])+)+

Suggestions?  Thanks very much,
Paul

my $file = shift;
open (FILE, $file) or die "$!";
while (<FILE>) {
if (/
(
[^<]+
|
<[^{]
)+
/x) {
print $1;
}
}
close FILE;


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


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

Date: Mon, 31 Jul 2000 17:03:46 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: simple regex?
Message-Id: <sobcbi8f9ft64@corp.supernews.com>

In article <8m49fc$30b$1@nnrp1.deja.com>,
     <pcj1@my-deja.com> wrote:

: I'm trying to write a regular expression which matches any text other
: than a literal '<|'.  For example the input 'abc<def' should match
: completely, while 'abc<|def' should match 'abc'.  I've tried the
: following without success:
: 
: [snip]

How about a different approach?

    while (<>) {
        s/<\|.*$//;  # delete everything after first <| in $_
        print;
    }

Greg
-- 
Now, it might be true that www.mtv.com attracts more visitors and gets
more "hits" than a site that makes RFCs available. But who the fuck cares?
    -- Abigail


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

Date: 31 Jul 2000 11:26:40 EDT
From: abigail@foad.org (Abigail)
Subject: Re: System background work
Message-Id: <slrn8ob6l4.vcg.abigail@alexandra.foad.org>

Lucas Tsoi (lucas@cplhk.com) wrote on MMDXXVI September MCMXCIII in
<URL:news:8m3c9n$8eh1@imsp212.netvigator.com>:
&& Hi all,
&& How do I run some background work regularly by Perl in linux?
&& e.g. everyday's 12pm


In the same way as you would run a Tcl or Java program regulary.

Please consult your system administrator, your question is not a Perl
question.



Abigail
-- 
perl -wle 'eval {die ["Just another Perl Hacker"]}; print ${$@}[$#{@${@}}]'


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

Date: 31 Jul 2000 11:31:50 EDT
From: abigail@foad.org (Abigail)
Subject: Re: tricky regexp
Message-Id: <slrn8ob6up.vcg.abigail@alexandra.foad.org>

Ala Qumsieh (aqumsieh@hyperchip.com) wrote on MMDXXVI September MCMXCIII
in <URL:news:7au2d6fltx.fsf@merlin.hyperchip.com>:
|| 
|| Tarjei Vassbotn <tarjei@onsite.no> writes:
|| 
|| > > Despite hours of pondering, I haven't reached an elegant (or even
|| > > working) regular expression to handle the following: given a string
|| > > that contains an arbitrary name encapsulated by underscores (eg
|| > > "lorem _ipsum_ dolor"), the substring "_ipsum_" would need to be
|| > > replaced by the value of the perl variable $ipsum ..ie the variable to
|| > > be used would be determined by the name in between the
|| > > underscores.
|| > > Any help would be oh-so-much appreciated!
|| 
|| > $text=~ s/_([^_]+)_/$replacers{$1}/g;
|| 
|| Perl variables *can* contain underscores. So, in my opinion, a better
|| solution would be:
|| 
|| 	s/ _(.*?)_ / $replacers{$1} /g;
|| 
|| which would interpolate variables like $this_one.

Actually, it wouldn't, as there's a dot after this_one, and your regex
requires a space before, and after the variable name. It won't capture
variables at the beginning or end of a line, or when followed or preceded
by for instance punctuation (it could start the match at the beginning
of one variable and end a few variables later).



Abigail
-- 
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_=sub{print/::(.*)/};
$\=$/;q<Just another Perl Hacker>->();


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

Date: Mon, 31 Jul 2000 15:43:56 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: tricky regexp
Message-Id: <7ar98afgoy.fsf@merlin.hyperchip.com>


abigail@foad.org (Abigail) writes:

> Ala Qumsieh (aqumsieh@hyperchip.com) wrote on MMDXXVI September MCMXCIII
> in <URL:news:7au2d6fltx.fsf@merlin.hyperchip.com>:
> || 
> || Tarjei Vassbotn <tarjei@onsite.no> writes:
> || 
> || > > Despite hours of pondering, I haven't reached an elegant (or even
> || > > working) regular expression to handle the following: given a string
> || > > that contains an arbitrary name encapsulated by underscores (eg
> || > > "lorem _ipsum_ dolor"), the substring "_ipsum_" would need to be
> || > > replaced by the value of the perl variable $ipsum ..ie the variable to
> || > > be used would be determined by the name in between the
> || > > underscores.
> || > > Any help would be oh-so-much appreciated!
> || 
> || > $text=~ s/_([^_]+)_/$replacers{$1}/g;
> || 
> || Perl variables *can* contain underscores. So, in my opinion, a better
> || solution would be:
> || 
> || 	s/ _(.*?)_ / $replacers{$1} /g;
> || 
> || which would interpolate variables like $this_one.
> 
> Actually, it wouldn't, as there's a dot after this_one, and your regex
> requires a space before, and after the variable name. It won't capture
> variables at the beginning or end of a line, or when followed or preceded
> by for instance punctuation (it could start the match at the beginning
> of one variable and end a few variables later).

Ok, you're being too picky. I meant variables like _this_one_ ...
But you are right in your claims ... perhaps the regexp should be:

	s/\b_(.*?)_\b/$replacers{$1}/g;

--Ala


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

Date: 31 Jul 2000 12:07:24 EDT
From: abigail@foad.org (Abigail)
Subject: Re: tricky regexp
Message-Id: <slrn8ob91f.vcg.abigail@alexandra.foad.org>

Ala Qumsieh (aqumsieh@hyperchip.com) wrote on MMDXXVI September MCMXCIII
in <URL:news:7ar98afgoy.fsf@merlin.hyperchip.com>:
[] 
[] abigail@foad.org (Abigail) writes:
[] 
[] > Ala Qumsieh (aqumsieh@hyperchip.com) wrote on MMDXXVI September MCMXCIII
[] > in <URL:news:7au2d6fltx.fsf@merlin.hyperchip.com>:
[] > || 
[] > || Tarjei Vassbotn <tarjei@onsite.no> writes:
[] > || 
[] > || > > Despite hours of pondering, I haven't reached an elegant (or even
[] > || > > working) regular expression to handle the following: given a string
[] > || > > that contains an arbitrary name encapsulated by underscores (eg
[] > || > > "lorem _ipsum_ dolor"), the substring "_ipsum_" would need to be
[] > || > > replaced by the value of the perl variable $ipsum ..ie the variable to
[] > || > > be used would be determined by the name in between the
[] > || > > underscores.
[] > || > > Any help would be oh-so-much appreciated!
[] > || 
[] > || > $text=~ s/_([^_]+)_/$replacers{$1}/g;
[] > || 
[] > || Perl variables *can* contain underscores. So, in my opinion, a better
[] > || solution would be:
[] > || 
[] > || 	s/ _(.*?)_ / $replacers{$1} /g;
[] > || 
[] > || which would interpolate variables like $this_one.
[] > 
[] > Actually, it wouldn't, as there's a dot after this_one, and your regex
[] > requires a space before, and after the variable name. It won't capture
[] > variables at the beginning or end of a line, or when followed or preceded
[] > by for instance punctuation (it could start the match at the beginning
[] > of one variable and end a few variables later).
[] 
[] Ok, you're being too picky. I meant variables like _this_one_ ...
[] But you are right in your claims ... perhaps the regexp should be:
[] 
[] 	s/\b_(.*?)_\b/$replacers{$1}/g;


Maybe.

    But _what_if you have _this_?

That would replace '_what_if you have _'.

Maybe s/_(\w+)_/$replacers{$1}/g; is more appropriate, but then, what
about:

    Yada yada _foo__bar_ yada?

One variable, or two?



Abigail
-- 
$" = "/"; split $, => eval join "+" => 1 .. 7;
*{"@_"} = sub  {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


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

Date: Mon, 31 Jul 2000 17:23:18 GMT
From: mfreake@iii.co.uk
Subject: Use MIME *and* specify the mail server
Message-Id: <8m4cm1$5lt$1@nnrp1.deja.com>

I'm quite new to Unix mail systems which may be the cause of the
problem.

I want to attatch some files to an email *and* specify the mail server
to be used (mail3.ourdomain.co.uk, for a made up example).

My previous uses of MIME::Entity used ordinary sendmail which I cannot
see how you specify the server with. Normally to specify the server I
use Fido::Sendmail which seems either won't take the resulting
MIME::Entity as body (not surprisingly, it's an object not plain text)
or if I stringify the text it just sends the mail as ugy plain text
(all that "This is a multi-part message in MIME format... stuff" and no
attatched files)

Am I being really dense here ? Any help v.gratefully accepted.



Matt Freake


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


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

Date: 31 Jul 2000 12:33:06 -0400
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: When does it pay to presize an array?
Message-Id: <uwvi2fef1.fsf@demog.berkeley.edu>

I'm working on a project in which some fairly large arrays (around 100,000
to 200,000 elements) will be loaded from a file. I will know ahead of
time how many elements will be read in, so it is feasible to pre-size
the arrays using $#array = nnn where nnn is the size of the array.
perldoc perldata suggests that this will speed up the array filling
process.

I wrote a quick timing script to see if it would be worthwhile to
rewrite the pertinent code to do this.  The script follows; to my
surprise, results using array sizes of 1000 and 10000 are actually
faster just push()ing each element than they are setting $#array and
then populating it.  Even at 100000, the difference is quite minor.

I'd be interested in comments, including whether I've built in some
fallacy into the test script and other ideas on the topic in general.

Thanks.

Script:

#!/usr/local/bin/perl -w

use strict;
use Benchmark;

sub presize {
  my $size = shift;
  my @array;
  $#array = $size - 1;
  foreach (0..$#array) {
    $array[$_] = $_;
  }
}

sub bypush {
  my $size = shift;
  my @array;
  foreach (0..$size) {
    push(@array, $_);
  }
}

foreach (1000, 10000, 100000) {
  print STDERR "$_ Trials:\n\n";
  timethese(1000, {
		    Presized => "presize $_",
		    Pushed   => "bypush  $_"
		   }
	   );
  print STDERR "\n\n---*---\n";
}

Results (run on a Sun Enterprise 450 server):
aperrin@brass ~> perl presizetest.pl 
1000 Trials:

Benchmark: timing 1000 iterations of Presized, Pushed...
  Presized:  3 wallclock secs ( 2.83 usr +  0.01 sys =  2.84 CPU)
    Pushed:  3 wallclock secs ( 2.69 usr +  0.00 sys =  2.69 CPU)


---*---
10000 Trials:

Benchmark: timing 1000 iterations of Presized, Pushed...
  Presized: 29 wallclock secs (28.32 usr +  0.01 sys = 28.33 CPU)
    Pushed: 28 wallclock secs (27.44 usr +  0.00 sys = 27.44 CPU)


---*---
100000 Trials:

Benchmark: timing 1000 iterations of Presized, Pushed...
  Presized: 298 wallclock secs (292.77 usr +  0.03 sys = 292.80 CPU)
    Pushed: 280 wallclock secs (275.84 usr +  0.02 sys = 275.86 CPU)


---*---
aperrin@brass ~> 


-- 
----------------------------------------------------------------------
Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
       aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
----------------------------------------------------------------------


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

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


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