[15912] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3325 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 12 03:06:10 2000

Date: Mon, 12 Jun 2000 00:05:15 -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: <960793515-v9-i3325@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 12 Jun 2000     Volume: 9 Number: 3325

Today's topics:
        "list slice" vs "array slice" [was: Dummy Variable avoi (jason)
    Re: "list slice" vs "array slice" [was: Dummy Variable  (jason)
    Re: ActiveState web site <justin@lolofie.com>
    Re: ANSI Perl: No Way !!! <bkennedy99@home.com>
    Re: ANSI Perl: No Way !!! (David H. Adler)
    Re: Build error in module IO <chahn@eleganceintime.com>
    Re: Build error in module IO <chahn@eleganceintime.com>
    Re: DBD-ODBC connect gives runtime exception (William Herrera)
    Re: Does Perl have a simple way to simulate C's "#INCLU (brian d foy)
    Re: Does Perl have a simple way to simulate C's "#INCLU <trevor@trevorsky.com>
    Re: Dummy Variable avoidance (jason)
    Re: Dummy Variable avoidance (Tad McClellan)
    Re: Expect & IO:Pty & Win2000/NT & Cygwin <crosebrugh@inetarena.com>
    Re: Expect & IO:Pty & Win2000/NT & Cygwin <crosebrugh@inetarena.com>
    Re: Finding repeated words -- e.g. the the <godzilla@stomp.stomp.tokyo>
    Re: Finding repeated words -- e.g. the the <godzilla@stomp.stomp.tokyo>
        Help wtih Regular Expression kittycspot@my-deja.com
    Re: Is it possible: Dumping Package Method Names <jdb@wcoil.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 12 Jun 2000 05:08:17 GMT
From: elephant@squirrelgroup.com (jason)
Subject: "list slice" vs "array slice" [was: Dummy Variable avoidance]
Message-Id: <MPG.13af0d73d605f22498972d@news>

Tad McClellan writes ..
>On Mon, 12 Jun 2000 01:42:24 GMT, jason <elephant@squirrelgroup.com> wrote:
>>Tad McClellan writes ..
>>>On Sun, 11 Jun 2000 21:45:29 GMT, jason <elephant@squirrelgroup.com> wrote:
>>>>Christopher Hahn writes ..
>>>>>This is a newbie-red-flag-avoidance clinic question.
>>>>>
>>>>>I am wanting to use the new Astro::MoonPhase module
>>>>>but I only need the percentage of Illumination, the second of
>>>>>seven items available.
>>>>>
>>>>>Now in order to avoid the aforementioned "red flags" I tried
>>>>>using this:
>>>>>                     (,$MoonIllum,,,,,) = phase();
>>>>>but this generates an error.
>>>>
>>>>you want what's called an array slice .. search for the word 'slice' in
>>>                           ^^^^^^^^^^^
>>>>  perldoc perldata
>>>
>>>
>>>But he needs a "list slice" not an "array slice", since his
>>>data in not in an array.
>>
>>I doubt that the implication that functionally there are two different 
>>things an "array slice" and a "list slice" is helpful to the originator 
>
>
>You are wrong then.
>
>It _is_ helpful to the originator to know the difference,
>because there _is_ a difference!
>
>from perldata:
>
>----------------------
>    ($him, $her)   = @folks[0,-1];              # array slice
>    @them          = @folks[0 .. 3];            # array slice
>    ($who, $home)  = @ENV{"USER", "HOME"};      # hash slice
>    ($uid, $dir)   = (getpwnam("daemon"))[2,7]; # list slice
>----------------------

ok .. this is not in my perldata - as you mention elsewhere in your post 
it's not in the 5.005_03 docs (well .. you said 5.003 but I presume I 
know what you meant)

I take your point but always thought of these as the same thing .. just 
that

  subName()[]

needed some parens in order to resolve the ambiguity .. whereas with

  @arrayName[]

there's no ambiguity .. it is the same thing to write

  (@arrayName)[]

so .. is that then a "list slice" ? .. or an "array slice" ?

my contention is that there is no real "array slice" (I used the term 
because it was the only one there in the docs) .. only a "list slice" .. 
and what we think of as an array slice really involves first generating 
a list from the array .. then taking a slice (a "list slice" if you must 
:)

ie. they are functionally equivalent .. just that you don't HAVE to use 
parens when taking a slice from an array .. calling them functionally 
different would be like calling

  print "blah";

and

  print("blah");

functionally different

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Mon, 12 Jun 2000 05:22:16 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: "list slice" vs "array slice" [was: Dummy Variable avoidance]
Message-Id: <MPG.13af10b6906d18ae98972e@news>

jason writes ..
>ie. they are functionally equivalent .. just that you don't HAVE to use 
>parens when taking a slice from an array .. calling them functionally 
>different would be like calling
>
>  print "blah";
>
>and
>
>  print("blah");
>
>functionally different

the above came out wrong :)

I really do take your point Tad .. it's a very worthwhile point to make 
about the "list slice" .. especially because the discussion in perldata 
that I directed the originator to may have led him fruitlessly to the 
incorrect attempt of

  funcName()[];

at some point I wandered off on a tangent regarding some naming issue 
and whether "array slice" should be there .. apologies to the originator

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sun, 11 Jun 2000 23:29:42 -0700
From: "Justin" <justin@lolofie.com>
Subject: Re: ActiveState web site
Message-Id: <sk90bde9h5131@corp.supernews.com>


Aaron <asentell@my-deja.com> wrote in message
news:8h39fs$b0a$1@nnrp1.deja.com...
> I am trying to download the latest binary versions of Perl and the
> DBI/DBD drivers for Oracle from the ActiveState web site
> (www.activestate.com), but I can't get the web page to come up.  Is
> anybody else having this problem?  Any idea what's going on?
>
> Thanks.
>

Yeah, you caught them while they were changing to their new and improved
communist theme.   :)





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

Date: Mon, 12 Jun 2000 04:19:27 GMT
From: "Ben Kennedy" <bkennedy99@home.com>
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <jxZ05.252305$Tn4.2274936@news1.rdc2.pa.home.com>

It seems later in this thread you say you think that CPAN is a good idea,
that it has a lot of potential.  If you have root access and a recent
version of Perl on a well configured box, try

perl -MCPAN -e shell

this gets you into the CPAN shell, and makes installing modules a breeze,
for instance 'install LWP' would install that module.  Its also very easy to
search for specific modules.

As to the subject of Perl 4 vs Perl 5, remember that Perl 5 contains all the
OO features that allow for modules (and CPAN) to exist in the first place -
compiled code can be dynamically added at run time, and there is a clean
interface to use it.  Also, remeber that Perl 5 is a superset of Perl 4,
nearly all scripts that would run with a Perl 4 interpreter will run under
Perl 5.  There is no elegance to the language of Perl 4 that cannot be
completely duplicated now.  As for bugs, if you honestly thing the Perl 5
interpreter is buggy, then report the bugs you find.  This helps everyone.
Do you think all development of software should stop at the the first stable
version?  In that case, it probably never would have gotten to Perl 4.  The
features added in Perl 5 (esp. the object oriented ones) make Perl one step
closer to being a 'complete' programming language and helps general
acceptance.  This again helps everyone  As for speed of Perl 4 and Perl 5, I
have a feeling that a lot of time was spent making enhancements to the regex
engine, and lots of other good stuff.  Why do you say Perl 4 is faster?  Its
fine for you to have an opinion, but you really should back it up with
something.  I am willing to be persuaded, but not by statements without
base.

And stop accusing me of harassing you.  All along I've just been trying to
have a discussion.  Sometimes you seem receptive to new ideas which is good,
sometimes not.

--Ben Kennedy




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

Date: 12 Jun 2000 04:46:22 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <slrn8k8qou.8vg.dha@panix6.panix.com>

On Sat, 10 Jun 2000 17:29:51 GMT, John from PUNY <john@thinman.com> wrote:
>LR: I have never needed to write an object in any program.  And, as I
>said, to me OO is a big yawner.
>
>ME: Hey, news flash: CPAN = OO modules !!

Uh, no, not really. (and I'm assuming you are using that as an
equality op, not an assignment... :-)

CPAN contains a lot of things, many of which are neither modules nor
OO.  And, just so the common misconception doesn't crop up yet again,
there is nothing about modules that forces them to be OO.

Just wanted to clear that up...

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Tegan's always being posessed!  She just wants attention.
	- Adric


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

Date: Sun, 11 Jun 2000 21:53:55 -0700
From: Christopher Hahn <chahn@eleganceintime.com>
Subject: Re: Build error in module IO
Message-Id: <39446CE3.7458F780@eleganceintime.com>

Hello,

I think that I am seeing a side-effect of my previous install
of perl.  I am seeing instructions in the 5.6 INSTALL file
regarding dealing with previous installs.

Christopher

Christopher Hahn wrote:

> Hello,
>
> Afterthought: I am running Redhat Linux on a Pentium-233
> using kernel 2.2.5-15.
>
> Thanks,
>
> Christopher
>
> Christopher Hahn wrote:
>
> > Hello,
> >
> > (Thanks to all for the array slice pointer)
> >
> > Well, in order to use the Napster module
> > sample from TPJ I needed to install the
> > threaded version of perl.
> >
> > I decided to use this occasion to upgrade from
> > 5.00503 to 5.6 with threads.
> >
> > The build went fine, but I find that rebuilding all
> > the modules that I had added to my system in the
> > past has run into problems.
> >
> > For the module IO-1.20, I found that the "perl Makefile.PL"
> > stage like my setup, but the following "make all" failed with
> > this error:
> > ========================
> > [chahn@lazarus IO-1.20]$ make all
> > cc -c  -D_REENTRANT -fno-strict-aliasing -I/usr/local/include
> > -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2     -DVERSION=\"1.20\"
> > -DXS_VERSION=\"1.20\" -fpic
> > -I/usr/local/lib/perl5/5.6.0/i586-linux-thread/CORE -DI_POLL  IO.c
> > In file included from
> > /usr/local/lib/perl5/5.6.0/i586-linux-thread/CORE/perl.h:24,
> >                  from IO.xs:9:
> > /usr/local/lib/perl5/5.6.0/i586-linux-thread/CORE/config.h:2306:
> > warning: `I_POLL' redefined
> > *Initialization*:1: warning: this is the location of the previous
> > definition
> > IO.xs: In function `XS_IO__Seekable_getpos':
> > IO.xs:208: `sv_undef' undeclared (first use in this function)
> > IO.xs:208: (Each undeclared identifier is reported only once
> > IO.xs:208: for each function it appears in.)
> > IO.xs: In function `XS_IO__File_new_tmpfile':
> > IO.xs:252: `sv_undef' undeclared (first use in this function)
> > make: *** [IO.o] Error 1
> > ========================
> >
> > Now does this indicate that I need a new version of this module?
> > (I will look...)
> >
> > Or that I am seeing a failure of the threaded version of perl?
> >
> > Christopher



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

Date: Sun, 11 Jun 2000 23:36:59 -0700
From: Christopher Hahn <chahn@eleganceintime.com>
Subject: Re: Build error in module IO
Message-Id: <3944850B.CF10FCB2@eleganceintime.com>

OK, so this is a one-sided conversation!

I thought that I ought to load my own "final" answer.

Here is the snippet that lead to IO-1.20 installing into
perl 5.6:
=============
=head1 WARNING:  This version requires an extra step to build old extensions.

5.005_53 and later releases do not export unadorned
global symbols anymore.  This means you may need to build older
extensions that have not been updated for the new naming convention
with:

        perl Makefile.PL POLLUTE=1
=============

OK, onward and ....upward?

Christopher

Christopher Hahn wrote:

> Hello,
>
> I think that I am seeing a side-effect of my previous install
> of perl.  I am seeing instructions in the 5.6 INSTALL file
> regarding dealing with previous installs.
>
> Christopher
>
> Christopher Hahn wrote:
>
> > Hello,
> >
> > Afterthought: I am running Redhat Linux on a Pentium-233
> > using kernel 2.2.5-15.
> >
> > Thanks,
> >
> > Christopher
> >
> > Christopher Hahn wrote:
> >
> > > Hello,
> > >
> > > (Thanks to all for the array slice pointer)
> > >
> > > Well, in order to use the Napster module
> > > sample from TPJ I needed to install the
> > > threaded version of perl.
> > >
> > > I decided to use this occasion to upgrade from
> > > 5.00503 to 5.6 with threads.
> > >
> > > The build went fine, but I find that rebuilding all
> > > the modules that I had added to my system in the
> > > past has run into problems.
> > >
> > > For the module IO-1.20, I found that the "perl Makefile.PL"
> > > stage like my setup, but the following "make all" failed with
> > > this error:
> > > ========================
> > > [chahn@lazarus IO-1.20]$ make all
> > > cc -c  -D_REENTRANT -fno-strict-aliasing -I/usr/local/include
> > > -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2     -DVERSION=\"1.20\"
> > > -DXS_VERSION=\"1.20\" -fpic
> > > -I/usr/local/lib/perl5/5.6.0/i586-linux-thread/CORE -DI_POLL  IO.c
> > > In file included from
> > > /usr/local/lib/perl5/5.6.0/i586-linux-thread/CORE/perl.h:24,
> > >                  from IO.xs:9:
> > > /usr/local/lib/perl5/5.6.0/i586-linux-thread/CORE/config.h:2306:
> > > warning: `I_POLL' redefined
> > > *Initialization*:1: warning: this is the location of the previous
> > > definition
> > > IO.xs: In function `XS_IO__Seekable_getpos':
> > > IO.xs:208: `sv_undef' undeclared (first use in this function)
> > > IO.xs:208: (Each undeclared identifier is reported only once
> > > IO.xs:208: for each function it appears in.)
> > > IO.xs: In function `XS_IO__File_new_tmpfile':
> > > IO.xs:252: `sv_undef' undeclared (first use in this function)
> > > make: *** [IO.o] Error 1
> > > ========================
> > >
> > > Now does this indicate that I need a new version of this module?
> > > (I will look...)
> > >
> > > Or that I am seeing a failure of the threaded version of perl?
> > >
> > > Christopher



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

Date: Mon, 12 Jun 2000 04:48:28 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: DBD-ODBC connect gives runtime exception
Message-Id: <394469e4.19201624@news.rmi.net>

On Sun, 11 Jun 2000 15:46:34 -0400, Tom Bates <tfbiv@SPAMMENOTerols.com> wrote:

>Last week, the statement below worked perfectly well. This week, I get
>the not very informative "Error: Runtime exception", with no script
>changes. I am hosted on an NT 4.0 server. Anybody have any clues?
>

In my recent ODBC experience, this may be due to an exception generated within
the (non-perl) ODBC driver code running on the Windows machine. This exact
error happens here on occasion while doing an update of local Berkely DB files
via an ODBC connection to a large Unix database when the database server gets
backed up on requests and the driver times out. If you find a good way to keep
the Windows ODBC driver trap from shutting down the Perl process, let me know.
We could use a fix :/




---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.


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

Date: Sun, 11 Jun 2000 21:41:25 -0500
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Does Perl have a simple way to simulate C's "#INCLUDE"?
Message-Id: <brian-1106002141260001@112.sanjose-08-09rs16rt.ca.dial-access.att.net>

In article <Q7Q05.15960$bH5.926697@nntp1.onemain.com>, "Trevor Sky Garside" <trevor@trevorsky.com> wrote:

>I now have partial success using "require", however I would like to have a
>"global" hash available to all subroutines - even those inclluded in the
>"require"'d files.  What I am finding is that each file is using its own
>namespace. 

unless you are telling Perl to change namespaces, it shouldn't be.

perhaps you can post a minimal example of your attempts so far...

-- 
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ 
  <URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>



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

Date: Sun, 11 Jun 2000 22:58:34 -0700
From: "Trevor Sky Garside" <trevor@trevorsky.com>
Subject: Re: Does Perl have a simple way to simulate C's "#INCLUDE"?
Message-Id: <QV_05.489$oz2.449312@news.pacbell.net>

I have discovered that my problem was in the order in which I was declaring
things.  Since I did not tell the included subroutines to "use strict", they
were making their own hashes as needed, then, when my main script got to the
my() declarations, I ended up with new private versions of the same hashes.

:)

"Always use strict" applies to require'd files as well...  whoops.

--Trevor

"brian d foy" <brian@smithrenaud.com> wrote in message
news:brian-1106002141260001@112.sanjose-08-09rs16rt.ca.dial-access.att.net..
 .
> In article <Q7Q05.15960$bH5.926697@nntp1.onemain.com>, "Trevor Sky
Garside" <trevor@trevorsky.com> wrote:
>
> >I now have partial success using "require", however I would like to have
a
> >"global" hash available to all subroutines - even those inclluded in the
> >"require"'d files.  What I am finding is that each file is using its own
> >namespace.
>
> unless you are telling Perl to change namespaces, it shouldn't be.
>
> perhaps you can post a minimal example of your attempts so far...
>
> --
> brian d foy
> Perl Mongers <URI:http://www.perl.org>
> CGI MetaFAQ
>   <URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
>
>




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

Date: Mon, 12 Jun 2000 01:42:24 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Dummy Variable avoidance
Message-Id: <MPG.13aedd324a224ba098972c@news>

Tad McClellan writes ..
>On Sun, 11 Jun 2000 21:45:29 GMT, jason <elephant@squirrelgroup.com> wrote:
>>Christopher Hahn writes ..
>>>This is a newbie-red-flag-avoidance clinic question.
>>>
>>>I am wanting to use the new Astro::MoonPhase module
>>>but I only need the percentage of Illumination, the second of
>>>seven items available.
>>>
>>>Now in order to avoid the aforementioned "red flags" I tried
>>>using this:
>>>                     (,$MoonIllum,,,,,) = phase();
>>>but this generates an error.
>>
>>you want what's called an array slice .. search for the word 'slice' in
>                           ^^^^^^^^^^^
>>  perldoc perldata
>
>
>But he needs a "list slice" not an "array slice", since his
>data in not in an array.

I doubt that the implication that functionally there are two different 
things an "array slice" and a "list slice" is helpful to the originator 
- who is a self classified newcomer to Perl

it's not as though he'll find "list slice" in the docs

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sun, 11 Jun 2000 22:48:44 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Dummy Variable avoidance
Message-Id: <slrn8k8jsc.5rr.tadmc@magna.metronet.com>

On Mon, 12 Jun 2000 01:42:24 GMT, jason <elephant@squirrelgroup.com> wrote:
>Tad McClellan writes ..
>>On Sun, 11 Jun 2000 21:45:29 GMT, jason <elephant@squirrelgroup.com> wrote:
>>>Christopher Hahn writes ..
>>>>This is a newbie-red-flag-avoidance clinic question.
>>>>
>>>>I am wanting to use the new Astro::MoonPhase module
>>>>but I only need the percentage of Illumination, the second of
>>>>seven items available.
>>>>
>>>>Now in order to avoid the aforementioned "red flags" I tried
>>>>using this:
>>>>                     (,$MoonIllum,,,,,) = phase();
>>>>but this generates an error.
>>>
>>>you want what's called an array slice .. search for the word 'slice' in
>>                           ^^^^^^^^^^^
>>>  perldoc perldata
>>
>>
>>But he needs a "list slice" not an "array slice", since his
>>data in not in an array.
>
>I doubt that the implication that functionally there are two different 
>things an "array slice" and a "list slice" is helpful to the originator 


You are wrong then.

It _is_ helpful to the originator to know the difference,
because there _is_ a difference!

from perldata:

----------------------
    ($him, $her)   = @folks[0,-1];              # array slice
    @them          = @folks[0 .. 3];            # array slice
    ($who, $home)  = @ENV{"USER", "HOME"};      # hash slice
    ($uid, $dir)   = (getpwnam("daemon"))[2,7]; # list slice
----------------------


If he does

   phase()[]

he has neither an "array slice" (no array there at all), 
nor a "list slice" (no parens).


If he does

   @phase()[]

then it just plain doesn't work.


He needs a list slice.

A list slice is a list in parens followed by square brackets.

That is, he needs

   (phase())[]

And that is NOT an "array slice".

There is no array in his code to take a slice from, there
is only a list to take a slice from.


>- who is a self classified newcomer to Perl
>
>it's not as though he'll find "list slice" in the docs


On my system (5.6):

   grep 'list slice' *pod | wc -l

      8

I do see that it is not mentioned in the 5.003 docs, so it is
understandable to not know about it.

But those docs (perldata) _do_ mention what is different
(parens required) about "list slices":

   "A list value may also be subscripted like a normal array.  
    You must put the list in parentheses to avoid ambiguity."


Which is pretty much why I mentioned it...


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 11 Jun 2000 23:02:25 -0700
From: "Chris Rosebrugh" <crosebrugh@inetarena.com>
Subject: Re: Expect & IO:Pty & Win2000/NT & Cygwin
Message-Id: <Z1%05.1996$nh5.125218@news-west.usenetserver.com>

Nothing like answering one's own post...

I hacked Expect.pm to work with IPC::open3() instead of
IO::Pty and it seems to work fine against our apps.

I renamed it from Expect to Suspect since I suspect that
I don't understand everything and that it won't work
for the general case (since our app always flushes its
stdio I think that it allows open3() to be a viable
alternative) to using pseudo-ttys.

Anyhow, if anyone's interested I'll put it together offically
(including maintaining 99+44/100% of the credit with Auston
Schultz, who wrote Expect) else not.

Cheers.


"Chris Rosebrugh" <crosebrugh@inetarena.com> wrote in message
news:0mg05.15744$MJ6.398965@news-west.usenetserver.com...
> I'm trying to get this combo of stuff to work within
> Cygwin (using Perl 5.6.0) but always get EOF on a read.
>
> IO:Pty did not install cleanly (I faked things out by
> just 'touch'ing /dev/ptyp# and /dev/ttyp#) so I'm
> sure that I'm just missing some needed brain power.
>
> If someone has figured this stuff out - even without
> having to use Cygwin - I'd like to hear how.
>
> Thanks.
>
>
>
>
>






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

Date: Sun, 11 Jun 2000 23:06:54 -0700
From: "Chris Rosebrugh" <crosebrugh@inetarena.com>
Subject: Re: Expect & IO:Pty & Win2000/NT & Cygwin
Message-Id: <a6%05.2018$nh5.126612@news-west.usenetserver.com>

Great, I stumble with the 'credit to' name. The Expect
module creator is Austin Schutz. Sorry for the lameness.

"Chris Rosebrugh" <crosebrugh@inetarena.com> wrote in message
news:Z1%05.1996$nh5.125218@news-west.usenetserver.com...
> Nothing like answering one's own post...
>
> I hacked Expect.pm to work with IPC::open3() instead of
> IO::Pty and it seems to work fine against our apps.
>
> I renamed it from Expect to Suspect since I suspect that
> I don't understand everything and that it won't work
> for the general case (since our app always flushes its
> stdio I think that it allows open3() to be a viable
> alternative to using pseudo-ttys).
>
> Anyhow, if anyone's interested I'll put it together offically
> (including maintaining 99+44/100% of the credit with Auston
> Schultz, who wrote Expect) else not.
>
> Cheers.
>
>
> "Chris Rosebrugh" <crosebrugh@inetarena.com> wrote in message
> news:0mg05.15744$MJ6.398965@news-west.usenetserver.com...
> > I'm trying to get this combo of stuff to work within
> > Cygwin (using Perl 5.6.0) but always get EOF on a read.
> >
> > IO:Pty did not install cleanly (I faked things out by
> > just 'touch'ing /dev/ptyp# and /dev/ttyp#) so I'm
> > sure that I'm just missing some needed brain power.
> >
> > If someone has figured this stuff out - even without
> > having to use Cygwin - I'd like to hear how.
> >
> > Thanks.
> >
> >
> >
> >
> >
>
>
>
>






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

Date: Sun, 11 Jun 2000 21:18:15 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Finding repeated words -- e.g. the the
Message-Id: <39446487.AD6CC4CD@stomp.stomp.tokyo>

OBrien-Malone wrote:
 
> I'm new to Perl, but I would like to use it (or perhaps AWK with which
> I am much more familiar) to find
> repeated words in a TeX document. I mean the simple typing errors where
> I would have typed "See the the figure on ..."
> Of course the repeated words might be split over lines.
 
> Can anyone see an easy (Reg Exp) way of doing this?



An easy way Mr. Diamond. I suppose this is relative
to just what all you wish to accomplish.

I have tossed together an exceptionally verbose
test script for you. It is verbose to better
display a step-by-step methodology which will
do a bit more than you ask. You have asked how
to 'find' double words but have not indicated
if you wish to replace those words. My script
will do both, if this is what you want.

This script will find those double words,
tell you which line they are located within
and tell you, numerically, which words are
doubled up. This should make your work easier.
My test script will also repair your typos,
if you leave this feature in.

A word of caution. This is not a catch all
script. It does have limits. This methodology
relies on a clean space between double words.
Double words which are run together, thethe,
or double words with a comma, a quote or
whatever between, will be missed.

Rather than comment my script, I have elected
to keep it clean and comment 'up here' for you.
Again, this is a deliberately verbose script
for easier reading and better comprehension.

I selected some verses from a song to give
this a firm but fair test. This is your 
input which could be from a file, a data
base or a different source. Within those
verses, I randomly doubled up some words,
including in one instance, a set of words
with one having an uppercase letter and
the following word, all lowercase.


Only major steps will be commented,


@Line_Array = split (/\n/, $string);

This first step, breaks down the input
into individual lines.


$line_counter = 1;
$word1_counter = 1;
$word2_counter = 2;

Those lines initialize counters for
both lines and words within lines.
You can follow the logic on those
as my script progresses.


  $line =~ tr/A-Z/a-z/;
  @Word_Array = split (/ /, $line);

Those two lines lowercase all words,
then create a second array containing
individual words for matching.


    if ($line =~ /$word $word/)
     {
      print "Match At Line $line_counter, \n",
            "Words $word1_counter And $word2_counter:",
            "     $word $word\n\n";
      $line =~ s/$word $word//;
      $string =~ s/($word) $word/$1/i;

This small block looks for a double match,
if found, prints a line number and prints
numerical location of words. Within that
small block, locate:

      $line =~ s/$word $word//;

With this line, double words are knocked
out so my script won't locate the same
double words twice. You could do this
in a slightly different way, by knocking
out double elements of my word array.
Either way works well. Comment out that
line if you need to understand better.
My print will display what happens.


Locate this line in that block up there:

      $string =~ s/($word) $word/$1/i;

This is the magic line which repairs your
input. If you don't want your input repaired,
comment out or remove this line. You could
also modify this script to protect your
original string with a new variable set
equal to your input string. You could also
modify this to print to a new data base
to protect your original data base. Lots
of options here upon which you can decide.
Note the ' i ' to ignore case to catch
double words, uppercase or lowercase, but
it replaces with the FIRST instance of
double words. This could be a bug if
uppercase versus lowercase is a typo.
The FIRST instance of double words
will be saved, the second tossed. Be
careful on this.


  $line_counter++;
  $word1_counter = 1;
  $word2_counter = 2;
 }

True bulk of this script is actually in
keeping count of lines and words. If you
remove those last TWO lines above, your
numercial count will change to an actual
count position relative to the total
number of words for your input. Comment
those out and you understand when you
see the print. As is now, those last
two counter lines reset your counters
to keep 'human perspective' count. Of
course you can remove all counters and
prints, just leaving the 'repair' feature.
Including all these features, however,
gives you more options and choices.


My hopes are this long drawn out script
will show you some methods which you
might be able to use. Clearly, many
lines can be combined, shortened,
variations on this could be used,
all as you see fit. However, if this
script was written to be short as
possible and fast as possible, chances
are real good you wouldn't be able to
make a lick of sense of what happens.

I have extensively tested this script.
Again, it is not perfect but I did not
find any glaring bugs or glitches. My
cautions are for you not to expect this
to work miracles. It won't. Nonetheless,
this might give you a head start on
what you want to do.

Have fun with this if it suits your fancy.


Godzilla!



PRINTED RESULTS
_______________

Input Is:

There is a house down in in New Orleans
They call the risin' sun.
An' it's been the ruin of many a poor girl
And me me, oh God, I'm one.

My mother was a tailor
She sewed these new new blue jeans
My sweetheart was a gambler, Lord
Down in New Orleans.

Now the the only thing a gambler needs
Is a suitcase and a trunk
And the only time he's satisfied
Is is when he's on on a drunk.


Match At Line 1, 
Words 6 And 7:     in in

Match At Line 4, 
Words 2 And 3:     me me

Match At Line 7, 
Words 4 And 5:     new new

Match At Line 11, 
Words 2 And 3:     the the

Match At Line 14, 
Words 1 And 2:     is is

Match At Line 14, 
Words 5 And 6:     on on


Output Is:

There is a house down in New Orleans
They call the risin' sun.
An' it's been the ruin of many a poor girl
And me, oh God, I'm one.

My mother was a tailor
She sewed these new blue jeans
My sweetheart was a gambler, Lord
Down in New Orleans.

Now the only thing a gambler needs
Is a suitcase and a trunk
And the only time he's satisfied
Is when he's on a drunk.



TEST SCRIPT
___________

#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";

$string = "There is a house down in in New Orleans
They call the risin' sun.
An' it's been the ruin of many a poor girl
And me me, oh God, I'm one.

My mother was a tailor
She sewed these new new blue jeans
My sweetheart was a gambler, Lord
Down in New Orleans.

Now the the only thing a gambler needs
Is a suitcase and a trunk
And the only time he's satisfied
Is is when he's on on a drunk.";


print "Input Is:\n\n$string\n\n\n";

@Line_Array = split (/\n/, $string);

$line_counter = 1;
$word1_counter = 1;
$word2_counter = 2;

foreach $line (@Line_Array)
 {
  $line =~ tr/A-Z/a-z/;
  @Word_Array = split (/ /, $line);
  foreach $word (@Word_Array)
   {
    if ($line =~ /$word $word/)
     {
      print "Match At Line $line_counter, \n",
            "Words $word1_counter And $word2_counter:",
            "     $word $word\n\n";
      $line =~ s/$word $word//;
      $string =~ s/($word) $word/$1/i;
     }
    $word1_counter++;
    $word2_counter++;
   }
  $line_counter++;
  $word1_counter = 1;
  $word2_counter = 2;
 }

print "\nOutput Is:\n\n";
print $string;

exit;


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

Date: Sun, 11 Jun 2000 23:20:05 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Finding repeated words -- e.g. the the
Message-Id: <39448115.CE76BC5A@stomp.stomp.tokyo>

"Godzilla!" wrote:
 
> OBrien-Malone wrote:

> ... to find repeated words in a TeX document. I mean the 
> simple typing errors where I would have typed 

> "See the the figure on ..."

> I have tossed together an exceptionally verbose
> test script for you. 

Mr. Diamond, tonight, while upgrading a thesaurus
on my system, a bug in my script came to mind.

If your input contains,

the thesaurus

or

abrazo zorro

 ...you will get a match between 'the' and
'the'saurus or abra'zo' and 'zo'rro. 
Odds are low of this type of coincidence 
but you need to know this. A cure would be
use of \b for word boundry or perhaps a 
similar technique. Another very easy method,
would be to append a space to $word, which 
is lost by the array split.

$word = "$word ";

or..

$word = join ("",  $word, " ");

I suspect your final solution will be
to tag word boundries in there. This
would be the best and safest solution.
So, now you have a bit of a challenge
which hopefully will be entertaining.

Here is a great site which is very easy
reading and will introduce you to regex
matching, without pain:

http://wdvl.com/Authoring/Languages/Perl/PerlfortheWeb/pattern_matching.html

That URL should be one long line. Watch the
word wrapping.

I really think you should improve upon my
/$word $word/ match operator for safety.
This is a glaring bug which did not come
to me until the thesaurus clued me in.

Should I think of other bugs, I will post.

Godzilla!


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

Date: Mon, 12 Jun 2000 06:38:35 GMT
From: kittycspot@my-deja.com
Subject: Help wtih Regular Expression
Message-Id: <8i20ha$jos$1@nnrp1.deja.com>

OK heres the deal...

lets say ive got the string "<!--ThisStays-->"
i need to replace the beginning part of the HTML comment (<!--) and the
ending (-->) with different strings (lets say we make it into a named
anchor tag) so it looks like <A NAME="ThisStays">

Also, The string that stays is made of variable length alphanumeric
characters.

ive dug around for hours and im sure that im just looking too deep, by
now i couldve written a loop to do it but i want to do it with pattern
matching...can anyone out there help me?

Thank you in advance,
Cheyenne


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


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

Date: 12 Jun 2000 05:15:49 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: Re: Is it possible: Dumping Package Method Names
Message-Id: <8i1rm5$lpa$0@206.230.71.61>

Greets,

LOL, I'm sorry for the confusion.
Ok, some might have heard about the Remote
Scripting solutions my Microft as a combo of
ASP and Java applets, and JavaScript. No use
to me, as I dont like ASP or Java.

I have developed a simple interface, which, no doubt others
have come up with before. I just put some code together
that allows JScript'ers to do a virtual-import of subs perl scripts
on the server, complete with a run-time wrapper, conversion
to- and from- Perl scalar, hash, and array types for transmission
between client and server.

The reason I asked about the OO method dumping code was
an attempt to allow interfacing Perl objects from the server and
javascript objects on the client. By dumping the method names,
I simply could create a wrapper function on client to be evaled
to call the server when a method was needed. I know I sound
like a fool, but this all does really work. I have not
got the Perl-OO interface to work, but my remote scripting
method is available for review at
http://www.josiah.countystart.com/remote/remote.zip
I havn't documented it much, yet, this is just code I zipped
so that you all could see what i was reffering to with this post.

As an afterthought, I found the below code to work quite
well for my needs, and I am working on interfacing it into
an object eval'uator to interface Perl and Javascript soon.
Code Snippet:

 require 'jlib/jlib.pm';

require Devel::Symdump;
my $obj = Devel::Symdump->rnew(jLIB::jDATA);       # with recursion
my $string = $obj->as_string;
my @p1 = split(/\n/,$string);
foreach $p (@p1) {
    if (substr($p,0,1) eq "\t")

       $p =~ s/\t//g;
       print "VALUE: [$p]\n";
    } else {
       print "TYPE: [$p]\n";
    }
 }

jLIB::jDATA is just a internal module of mine, any module would
work with this. But for example purposes this works fine.

Any comments appreciated.

--
Josiah Bryan
jdb@wcoil.com

Neil Kandalgaonkar <nj_kanda@alcor.concordia.ca> wrote in message
news:8hua6t$hmv$1@newsflash.concordia.ca...
> In article <Pine.GSO.4.10.10006101213140.10286-100000@user2.teleport.com>,
> Tom Phoenix  <rootbeer@redcat.com> wrote:
>
> >Most OO modules shouldn't export their methods, so no. Oh, well!
>
> Oh dear, that was really brain-damaged of me to say. Comes from examining
> CGI which has that functional/OO split personality and thinking about
> two different ways of doing it simultaneously.
>
> >But part of the _point_ of OO is that you should learn everything you
need
> >to know about the class from its public interface - which, in Perl, is
the
> >docs. If you need more than that, read the source!
>
> Absolutely. I wonder why the OP wanted to do this. It might be a quick
> way of making a template for writing docs.
>
> (...goes back to finish reading Object-Oriented Perl).
>
>
> --
> Neil Kandalgaonkar
> neil@brevity.org




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

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


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