[10319] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3912 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 7 00:07:24 1998

Date: Tue, 6 Oct 98 21:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 6 Oct 1998     Volume: 8 Number: 3912

Today's topics:
    Re: "Many Jars" Mystery <hetrick@acm.org>
    Re: (PERL vs VisualBasic) and (PERL with VisualBasic) C (Adam Turoff)
    Re: (PERL vs VisualBasic) and (PERL with VisualBasic) C <lembark@wrkhors.com>
    Re: Are there any "perl.newbie" group or forum? <mp@mkt2mkt.com>
    Re: Are there any "perl.newbie" group or forum? <eashton@bbnplanet.com>
        Can Perl Change Current Drive? <mharris@donet.com>
    Re: Data Search Question (Ilya Zakharevich)
    Re: eq on if statement causing problems with string (Kevin Reid)
        foreach peculiarities (Dave Shaw)
    Re: foreach peculiarities (Andre L.)
    Re: foreach peculiarities <rick.delaney@shaw.wave.ca>
        ftp within a perl program <jbach@teleport.com>
        mSQL2 Perl5 Insert Status Checking <chi@cybie.com>
    Re: Need method to round real number to two decimal pla <lembark@wrkhors.com>
    Re: Need method to round real number to two decimal pla (Sam Holden)
    Re: NEEDED: A good perl programer to... (Mike)
    Re: NEEDED: A good perl programer to... <eashton@bbnplanet.com>
    Re: newbie trying to parse one file into three (Bart Lateur)
        Opening Perl documentation (Kevin Reid)
        Perl as a dumb terminal <buxx@buxx.com>
    Re: perl html tag parser <jdf@pobox.com>
        Perl pattern matching implementation <otroyans@richmond.edu>
    Re: Perl pattern matching implementation (Ilya Zakharevich)
    Re: Q: Speed up a regular expression <lembark@wrkhors.com>
    Re: Q: Speed up a regular expression (Larry Rosler)
        regexps and cntl chars pfeilgm@jmu.edu
    Re: soft reference to object? (Kevin Reid)
        SSI <brettr@centuryinter.net>
    Re: What's is wrong here? (Abigail)
    Re: Why does this program chomp 18 MB of memory? (Snowhare)
    Re: Why does this program chomp 18 MB of memory? (Ilya Zakharevich)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 6 Oct 1998 22:35:20 -0400
From: "George C. Hetrick" <hetrick@acm.org>
Subject: Re: "Many Jars" Mystery
Message-Id: <6vek1p$7nc$1@wbnws01.ne.highway1.com>

>In article <6vdm5d$a9l$1@nnrp1.dejanews.com>, ptimmins@netserv.unmc.edu
>(Patrick Timmins) wrote:
>
>+ Could this explain the "Many Jars" mystery?
>


John Many Jars was one of the lectroids in _Buckaroo_Banzai_, yes?

(Along with John Yaya and John Smallberries...)




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

Date: 6 Oct 1998 21:22:44 -0400
From: ziggy@panix.com (Adam Turoff)
Subject: Re: (PERL vs VisualBasic) and (PERL with VisualBasic) Can it be done??
Message-Id: <6vefp4$lku@panix.com>

Guy Doucet  <gdoucet@ait.acl.ca> wrote:
>I wrote a few Web applications with PERL 5. My apps sit on our Novell
>Web Server, in our office network.

<cringe!>

>From the HTML documents on our web site, our employees submit info that
>is posted to my Perl scripts. The Perl scripts modify databases and
>return HTML documents. (By the way: The databases are simply tabulated
>text files).

Reasonable.  Beware that this technique has some problems scaling.

>This is great for our remote employees. But for our employees in our
>office, I wrote a VisualBasic app that deals with the same databases.
>With VB I can write more powerful apps with grids, etc... (this maybe
>because I'm new with PERL?)

VB has more sugary bells and whistles.  Perl has more useful ones.  :-)

If you want to do GUI programming with perl, check out the TK modules.
They should be coming standard with any recent build/dist. of perl for win32.

The grids shouldn't be that difficult, but don't expect the interface
to match what you're used to with VB grids...

O'Reilly is coming out with a few books on Perl/TK RSN.  Might be on
the shelves already.  IIRC, there's a discussion of Perl/TK in the Panther
book, Advanced Perl Programming.

>I basically learned PERL from one book (Using Perl5 for web
>programming), and also  from examples.

Check out the Llama and the Camel.  You've probably got some gaps
if you're main exposure to perl is some thick book by SAMS or somesuch.

And don't forget to peruse the documentation that came with your 
perl distribution.  :-)

>I don't know much about PERL itself, but... Is there a way to submit
>data to a PERL app from an EXE, and can it return data back to the EXE.

I'm pretty sure perl is able to do this (unless my win32perl is really 
crusty), so yes, it is possible.  I don't know what the Win32 API calls
would be (and quite happy to say that!), but it should be mentioned
along the lines of popen()-ish thingys, spawn, system or something like that.

>Or could a DLL be written with PERL. Basically I am wondering what the
>limits are as far as a Win95 environment. I like PERL a lot with its
>foreach, push, and tr/// commands. I would like to be able to use it
>more than just on our web site, but I don't imagine its a compilable
>language that can run on a Win95 PC. If it can, what software is needed
>to do so?

If you absolutely require binary distributions, there are a few tools
out there that may help you get there.  Check www.activestate.com first.

Realistically, with all of the black magic required to make sure
multiple VB applications work happily on one machine, distributing a
series of perl scripts/modules as source is actually *more* workable than 
VB Apps.  If you just want to install pretty icons in the start menu, it's 
rather simple to make a shortcut with an icon to execute the proper 
commandline for your perl application.

If you *absolutely* *must* distribute perl binaries, look into embedding
perl into your C application and going from there.  You'll probably be
better off sticking to one language (perl), though.

HTH!

Z.



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

Date: Tue, 06 Oct 1998 21:04:57 -0500
From: Steven Lembark <lembark@wrkhors.com>
Subject: Re: (PERL vs VisualBasic) and (PERL with VisualBasic) Can it be done??
Message-Id: <361ACC49.62AC95AD@wrkhors.com>

> This is great for our remote employees. But for our employees in our
> office, I wrote a VisualBasic app that deals with the same databases.
> With VB I can write more powerful apps with grids, etc... (this maybe
> because I'm new with PERL?)

definately.   you can get the grids, etc, via html or tcl.

> I basically learned PERL from one book (Using Perl5 for web
> programming), and also  from examples.

pick up: Learning Perl, Programming Perl (llama & Camel books, 
respectively).  there are also CGI Programming in Perl &
WEB client side programming from O'Reilly also (just love them
animal books :-).  

> I don't know much about PERL itself, but... Is there a way to submit
> data to a PERL app from an EXE, and can it return data back to the EXE.
> Or could a DLL be written with PERL. Basically I am wondering what the
> limits are as far as a Win95 environment. I like PERL a lot with its
> foreach, push, and tr/// commands. I would like to be able to use it
> more than just on our web site, but I don't imagine its a compilable
> language that can run on a Win95 PC. If it can, what software is needed
> to do so?

also might pick up a copy of using the Win32 book from -- you
guessed it -- O'Reilly press.

also might want to check the perl FAQ's.

-- 
 Steven Lembark                                   2930 W. Palmer St.
 Workhorse Computing                             Chicago, IL  60647
 lembark@wrkhors.com                                   800-762-1582
---------------------------------------------------------------------
  The opinions expressed here are those of this company.
  I am the company.
---------------------------------------------------------------------


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

Date: Tue, 06 Oct 1998 18:54:57 -0800
From: madame philosophe <mp@mkt2mkt.com>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <361AD7CC.2D0EDE68@mkt2mkt.com>



Abigail wrote:

> madame philosophe (mp@mkt2mkt.com) wrote on MDCCCLXIII September MCMXCIII
> in <URL:news:361AB178.19EDD3C4@mkt2mkt.com>:
> ++
> ++ If the people at this group are tired of hearing the same questions.. why
> ++ doesn't someone start a newbie perl newsgroup? Or why don't you
> ++ "professionals" migrate to another more stylin' hangout? As the web grows
> ++ there will be more newbies. GET USED TO IT. And don't shoot me for saying so.
>
> *PLONK*
>
> Start a newsgroup yourself.
>

Am I qualified to do so?  Time will tell....

As far as people's responses to my posting, I thank you for your civility. It's
been more so than I'm accustomed to.I do think that my brain is damaged enough to
learn this stuff, however.  So no need to get personal...

I've been *PLONK*'d loads thank you.  In fact I can do it in my sleep.

One reason I feel qualified is that I'm beginning to dream in Perl.

*PLONK* is the sound of the last perl book book falling on my head as I .....

zzzzzz......


> Abigail
> --
> perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'





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

Date: Wed, 07 Oct 1998 03:41:13 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <361AE060.1421B04D@bbnplanet.com>

madame philosophe wrote:

> One reason I feel qualified is that I'm beginning to dream in Perl.
> 
> *PLONK* is the sound of the last perl book book falling on my head as I .....

Hrm...You just simply must be a troll. 

e.


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

Date: Tue, 6 Oct 1998 22:08:19 -0400
From: "Mark W. Harris" <mharris@donet.com>
Subject: Can Perl Change Current Drive?
Message-Id: <R5AS1.392$013.500659@newsfeed.slurp.net>

I can't believe I've never run into this before.  I can't seem to make Perl
change the current drive on Windows NT.  System and backticks seem to have
no effect.  In fact the basic chdir() doesn't work either, I had to use
Cwd::chdir(). Has anyone dealt with this before?

Mark Harris
Staff Engineer
Standard Register




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

Date: 7 Oct 1998 03:11:44 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Data Search Question
Message-Id: <6vem5g$a9m$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.10842b3e310f609f9897ea@nntp.hpl.hp.com>:
> ! > Then one should get a new compiler, one that works properly.
> ! 
> ! Please tell me where can I get this better Perl compiler.
> 
> Are you implying that the current Perl compiler cannot free up the entire 
> space?  leaks?  inefficiencies?

There is no signifant difference between Perl compiler and
perl-which-is-compiler, so I would think you meant the second.  Perl's
reason for existence is to get the tasks done, no matter what the
memory footprint is.  The user has always an option to buy more
memory.

Cannot say I like this, but this is life.

> It is hard to believe that the same space, wherever it is, is not reused 
> on every trip through the loop, and returned somehow on loop exit.

Perl never returns any memory it thinks there is a slightest chance to
request again.  Perl *is* a memory pig.

Ilya


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

Date: Tue, 6 Oct 1998 23:50:26 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: eq on if statement causing problems with string
Message-Id: <1dgi4ac.1e46glc9uqn5gN@slip-32-100-246-124.ny.us.ibm.net>

John Porter <jdporter@min.net> wrote:

> 0. Always, *Always*, *ALWAYS* check the result of open().
>    There is never, NEVER a situation in which you can safely
>    neglect to check the result of open().

if ($^O eq 'MacOS') {
  open CON, '> Dev:Console:Ha!';
  print CON "Never say never!\n";
  close CON;
} else {
  print 'This example requires the Mac OS.';
}

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 7 Oct 1998 01:52:35 GMT
From: dshaw@iworks.interworks.org (Dave Shaw)
Subject: foreach peculiarities
Message-Id: <6vehh3$q9p$1@server05.icaen.uiowa.edu>


I was trying to explain an aspect of 'foreach' processing to a friend and
discovered that I didn't have a very good understanding of what was going
on myself. I was trying to explain why the program:
  #!perl5.4
  # example 1
  foreach $i ($x) {  # gets into the block one time
    print "-$i-\n";  # prints '--'
  }
seemed to behave differently from the program:
  #!perl5.4
  # example 2
  foreach $i (@x) {  # doesn't get into block at all
    print "-$i-\n";
  }

My explanation involved some hand waving describing how $x was undefined
in example 1, and the "undef" value was an ok thing for foreach to try
to iterate across, while the empty array @x didn't provide anything for
foreach to iterate over. Even though it is also undefined..

I wasn't being very convincing.

This discussion came about because my friend was trying to use foreach
somewhat differently:
  #!perl5.4
  # example 3
  $_="abc";
  foreach $i (/z/) {  # returns a null array?
    print "-$i-\n";   # prints '--'
  }
and had discovered that this code behaved somewhat better if written as:
  #!perl5.4
  # example 4
  $_="abc";
  foreach $i (/z/g) { # returns a null array
    print "-$i-\n";   # doesn't get into block at all
  }
Examples 3 and 4 would appear to be directly related to examples 1 and 2
(i.e., the same principles seem to be involved), even though example 3
and 4 would both seem to have foreach operating on a null array, based
in part on the following from the perlop man page:
  > If used in a context that requires a list value, a
  > pattern match returns a list consisting of the
  > subexpressions matched by the parentheses in the
  > pattern.  If the match fails, a null array is
  > returned.
and the fact that perl will promote a scalar to a single element array
if needed.

Another interpretation might be that the /z/ in example 3 is being
evaluated in a scalar context, and returning 'false', which is somehow
allowing the foreach to succeed one time. It would be easier to explain
the relationship between example 1 and 3 this way, as each are then
having foreach work on a 'false' scalar (while examples 2 and 4 are
more clearly working on null arrays).

In any case, I couldn't find a good description of what was going on
anywhere in the man pages.

Can anyone help explain the behavior above?



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

Date: Tue, 06 Oct 1998 23:13:42 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: foreach peculiarities
Message-Id: <alecler-0610982313420001@dialup-694.hip.cam.org>

In article <6vehh3$q9p$1@server05.icaen.uiowa.edu>,
dshaw@iworks.interworks.org (Dave Shaw) wrote:

> I was trying to explain an aspect of 'foreach' processing to a friend and
> discovered that I didn't have a very good understanding of what was going
> on myself. I was trying to explain why the program:
>   #!perl5.4
>   # example 1
>   foreach $i ($x) {  # gets into the block one time
>     print "-$i-\n";  # prints '--'
>   }
> seemed to behave differently from the program:
>   #!perl5.4
>   # example 2
>   foreach $i (@x) {  # doesn't get into block at all
>     print "-$i-\n";
>   }

[snip]

The explanation is simple. With $x and @x undefined,

foreach ($x) {  }                 ($x)  is a list with one element
$_ = 'abc'; foreach (/z/) {  }    (/z/) is a list with one element

foreach (@x) {  }                 (@x)   is an empty list
$_ = 'abc'; foreach (/z/g) {  }   (/z/g) is an empty list

Andre


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

Date: Wed, 07 Oct 1998 03:50:54 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: foreach peculiarities
Message-Id: <361AE6A8.595F47A4@shaw.wave.ca>

Andre L. wrote:
> 
> The explanation is simple. With $x and @x undefined,
> 
> foreach ($x) {  }                 ($x)  is a list with one element
> $_ = 'abc'; foreach (/z/) {  }    (/z/) is a list with one element

How's that?  Why would (/z/) not put the pattern match in a list
context.  If it does, why is it not returning a null list like perlop
says?

This is perl, version 5.004_02

    If used in a context that requires a list value, a pattern match
    returns a list consisting of the subexpressions matched by the 
    parentheses in the pattern, i.e., ($1, $2, $3...). (Note that here 
    $1 etc. are also set, and that this differs from Perl 4's
    behavior.) If the match fails, a null array is returned. If the 
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    match succeeds, but there were no parentheses, a list value of (1) 
    is returned. 

$_ = 'abc';
@a = /z/;
@b = (/z/);
print scalar( @a ), " ", scalar( @b ), "\n";

produces: 1 1

I believe this is a bug in 5.004.  Since the docs for 5.005 have been
corrected (they now say, "With or without parentheses, an empty list is
returned upon failure."  Note 'empty *list*'), I hope the behaviour has
also been fixed.

Perhaps someone living in the present could clear this up.

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Wed, 07 Oct 1998 02:50:23 GMT
From: "jbachofner" <jbach@teleport.com>
Subject: ftp within a perl program
Message-Id: <01bdf19e$108f5e80$17aecacc@jb>

Anyone know how to ftp files from with in a perl script? I need to get
files from a UNIX box daily and save them on a NT machine.

Any help is appreciated.

jeff Bachofner


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

Date: Tue, 06 Oct 1998 19:12:02 -0700
From: Chi Yu <chi@cybie.com>
Subject: mSQL2 Perl5 Insert Status Checking
Message-Id: <361ACDF2.B6505FF2@cybie.com>

Greetings,

Can anyone please give me the proper code for checking the status of an
INSERT statement?

My insert statement looks like this:

  $sql_statement = "...some valid SQL statement";
  $sth = $dbh->query($sql_statement);

When checking the status of a SELECT, I use the following code but it
does not work for the INSERT:

  $num = $sth->numrows;
  if ($num gt 0) {
    ...process successful statement }
  else {
    ...no rows processed }

Using SQLMonitor I can see the INSERT statement worked, but the script
fails (error 500) on any subsequent query to the $sth variable.

Any useful suggestions are much appreciated.

Best regards,
Chi Yu


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

Date: Tue, 06 Oct 1998 20:57:30 -0500
From: Steven Lembark <lembark@wrkhors.com>
Subject: Re: Need method to round real number to two decimal places
Message-Id: <361ACA8A.3258456F@wrkhors.com>

Roy Kenneth Scaife wrote:
> 
> I am looking for a method of rounding a real number to two decimal places.
> e.g. 3.534364 --> 3.53
> 
> Using printf is _not_ an option as
> the new value will then be used for further calculations.
> 
> Thanks in advance.
> 
> Roy K Scaife
> 
> Keywords: --

leave one extra place and truncate it:

	$rounded = int( 1000 * $floating ) / 1000;


or you could use a regular expression to hack the digits
after the decimal point.

	

-- 
 Steven Lembark                                   2930 W. Palmer St.
 Workhorse Computing                             Chicago, IL  60647
 lembark@wrkhors.com                                   800-762-1582
---------------------------------------------------------------------
  The opinions expressed here are those of this company.
  I am the company.
---------------------------------------------------------------------


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

Date: 7 Oct 1998 03:29:53 GMT
From: sholden@staff.cs.usyd.edu.au (Sam Holden)
Subject: Re: Need method to round real number to two decimal places
Message-Id: <slrn71lo1h.jfe.sholden@staff.cs.usyd.edu.au>

On Tue, 06 Oct 1998 20:57:30 -0500, Steven Lembark <lembark@wrkhors.com> wrote:
>Roy Kenneth Scaife wrote:
>> 
>> I am looking for a method of rounding a real number to two decimal places.
>> e.g. 3.534364 --> 3.53
>> 
>> Using printf is _not_ an option as
>> the new value will then be used for further calculations.
<snip>
>
>leave one extra place and truncate it:
>
>	$rounded = int( 1000 * $floating ) / 1000;
>
>
>or you could use a regular expression to hack the digits
>after the decimal point.

Or you could use sprintf...

-- 
Sam

 "... the whole documentation is not unreasonably transportable in a
 student's briefcase." - John Lions describing UNIX 6th Edition
 "This has since been fixed in recent versions." - Kernighan & Pike


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

Date: 7 Oct 1998 01:51:36 GMT
From: schutzmd@SPAMFREEjmu.edu (Mike)
Subject: Re: NEEDED: A good perl programer to...
Message-Id: <6vehf8$99j$1@lark.jmu.edu>

> >> You forgot to mention a price which you are willing to pay. Therefore
> >> dont expect any serious offer.
> >
> >I'll bet you don't play poker very well. ;)

> Poker's very different... if an agent/client isn't able to start talking
> money in a matter of seconds the conversation has a pretty short lifespan.

Wow, I didn't realize that our society is so twisted...  I've donated
literally hundreds of hours of perl programming to a couple worthy
recipients.  I've created an entire realtime site generated with perl
pulling information from a handful of large databases.  Granted, my perl
is mediocre, but I am more than willing to donate time to a worthy cause.

Anyway... moral of this story is:  work only for yourself if you want to,
but don't assume the rest of the world is so caught up in money as you
might be.

 .02 

- mike -


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

Date: Wed, 07 Oct 1998 03:20:33 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: NEEDED: A good perl programer to...
Message-Id: <361ADB87.1B24BFC6@bbnplanet.com>

Mike wrote:

> Anyway... moral of this story is:  work only for yourself if you want to,
> but don't assume the rest of the world is so caught up in money as you
> might be.

*sigh* point totally missed here. Why are geeks so intensely literal
sometimes?
My point was that noone offers what they are willing to pay up front. It
is a matter of doing business, both sides know their price point,
negotiation ensues if interest is there. I'm always willing to bend if
the problem is interesting enough...I've done a lot of pro bono stuff
too just because the problem was cool. It's like poker, ante up and show
me your cards. It has nothing to do with money. Money is so pointless as
a passion. If you do not love what you do then you need to find
something else as it will never ever make you happy. I truly wish the
world would learn that. The faces of people on the train in the morning
make me sad even if they have armani suits on.

e.


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

Date: Tue, 06 Oct 1998 22:22:43 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: newbie trying to parse one file into three
Message-Id: <361e975b.5783437@news.ping.be>

Tad McClellan wrote:

>   print FH147 join(',', @fields[0,3,6]), "\n";

My first reaction whenever I see code like this (the essential 3 lines),
I convert it to:

($\,$,) = ("\n",",");
while (<DATA>) {
   chomp; @fields = split /,/;
   print FH147 @fields[0,3,6]);
   print FH25  @fields[1,4]);
   print FH36  @fields[2,5]);
}

$, replaces the join, $\ takes care of the newline.

	Bart.


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

Date: Tue, 6 Oct 1998 23:15:51 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Opening Perl documentation
Message-Id: <1dgi1y4.1rhqn7q5gm2coN@slip-32-100-246-124.ny.us.ibm.net>

I have noticed that, when somebody asks a question that is answered in
the Perl documentation, often the 'perldoc' command is mentioned.
Unfortunately, AFAIK, perldoc is specific to UNIX; e.g. if you're using
MacPerl, you have to launch Shuck instead.

I think it would be useful to have a way to open up a given section of
the Perl documentation (or the documentation for a particular module)
built into the standard Perl distribution; perhaps like this:

  use Help;
  doc('perlfunc');

or:
  
  use Help;
  doc('File::Find');



The doc() function would open up the documentation named by its
parameters.

In order to find the documentation for a module, it would search for POD
in either 'File/Find.pod' or 'File/Find.pm' in @INC, and display it if
found.

To get it started, here's how to view POD under the Mac OS:

MacPerl::DoAppleScript <<"EOS";
  tell application "Shuck"
    activate
    open "Apps & Data:Applications:MacPerl:pod:perlfunc.pod"
  end tell
EOS

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Tue, 06 Oct 1998 20:35:26 -0500
From: Buxx <buxx@buxx.com>
Subject: Perl as a dumb terminal
Message-Id: <361AC55E.4468@buxx.com>

I'm needing to interface a pc thru a serial port to a Meridian phone
system to moniter and issue commands. All ascii text and emulating a
dumb terminal.

Anyone have any words of wisdom or done such a thing ??

Steve Vandiver 
Miracle Recreation
buxx#buxx.com


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

Date: 07 Oct 1998 05:55:58 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: ekaull@my-dejanews.com
Subject: Re: perl html tag parser
Message-Id: <m3ogrphvox.fsf@joshua.panix.com>

ekaull@my-dejanews.com writes:

>   Jonathan Feinberg <jdf@pobox.com> wrote:

> >    require HTML::Filter;
> >    @ISA = qw( HTML::Filter );
> >    sub start {
> >      my $self = shift;
> >      my ($tag, $attr, $attrseq, $text) = @_;
> >      if ($tag eq 'a') {
> >        $attr->{href} = lc $attr->{href} ;
> >        $_[3] = '<a ' . (join ' ', map qq($_="$attr->{$_}"),@$attrseq) . '>';
> >      }
> >      $self->SUPER::start(@_);
> >    }

>    To be honest, this code is a bit over my head.

You know, when I wrote and tested the example, I struggled to make it
simple. I'd hoped that just tweaking the $attr hash itself would
affect the HTML::Filter output, but you must re-create the raw HTML
itself and pass it on to the superclass. Looking at it now, I'd use
"$text" instead of "$_[3]", and then explicity invoke
$self->SUPER::start($tag, $attr, $attrseq, $text).

In order to understand this code you'll need to read and understand
several docs: perlref (since $attr and $attrseq are references to a
hash, and a list, respectively), perlmod (packages), perlobj &
perltoot (objects, the SUPER:: pseudo-package, the @ISA array), and
especially the documentation for HTML::Parse and HTML:Filter.

> If I could only get inside the quotes to change it I'd be all set.

For this you'll want perlre and the book _Mastering Regular
Expressions_. Here's a very simple idea that *will* fail in some
cases:

  $html =~ s/(href=")([^"]*)/$1\L$2/gi;

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 7 Oct 1998 01:11:18 GMT
From: Olga Troyanskaya <otroyans@richmond.edu>
Subject: Perl pattern matching implementation
Message-Id: <361ABF19.77897BFB@richmond.edu>

I've been trying to find out how pattern matching is implemented in PERL
(algorithms etc.), but cannot find any sort of reference on the
subject.  Does anyone know a good place to check on that?  I'd really
appreciate any help/advice.

Thanks



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

Date: 7 Oct 1998 03:22:26 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl pattern matching implementation
Message-Id: <6vempi$ank$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Olga Troyanskaya 
<otroyans@richmond.edu>],
who wrote in article <361ABF19.77897BFB@richmond.edu>:
> I've been trying to find out how pattern matching is implemented in PERL
> (algorithms etc.), but cannot find any sort of reference on the
> subject.  Does anyone know a good place to check on that?  I'd really
> appreciate any help/advice.

$CPAN/blah/latest.tar.gz, peruse your eyeballs looking through the source.

Ilya


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

Date: Tue, 06 Oct 1998 21:10:07 -0500
From: Steven Lembark <lembark@wrkhors.com>
Subject: Re: Q: Speed up a regular expression
Message-Id: <361ACD7F.A64FF252@wrkhors.com>

> Is there a way to speed up this regular expression ?
> 
> if ($line =~ /(^$Search )|( $Search )/io)
> 
> I want to match a string $Search either in the beginning of $line or
> within the string $line, but then with a leading SPACE.

probably faster as

	$line =~ /^$blah/ || $line =~ / $blah/

the first one can 
short circut the second if they are separate regexes; with 
an or-ed regex you end up having to search for both before 
deciding what's correct.

check the camel book's section on performance for a few more
tips.  there's also jeff friedl's book on regexes: has quite
a thick section on perl (around 1/2 the book).

-- 
 Steven Lembark                                   2930 W. Palmer St.
 Workhorse Computing                             Chicago, IL  60647
 lembark@wrkhors.com                                   800-762-1582
---------------------------------------------------------------------
  The opinions expressed here are those of this company.
  I am the company.
---------------------------------------------------------------------


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

Date: Tue, 6 Oct 1998 19:44:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Q: Speed up a regular expression
Message-Id: <MPG.1084755ece9abd2b9898a2@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <361ACD7F.A64FF252@wrkhors.com> on Tue, 06 Oct 1998 21:10:07 -
0500, Steven Lembark <lembark@wrkhors.com> says...
> > Is there a way to speed up this regular expression ?
> > 
> > if ($line =~ /(^$Search )|( $Search )/io)
 ...
> probably faster as
> 
> 	$line =~ /^$blah/ || $line =~ / $blah/
> 
> the first one can 
> short circut the second if they are separate regexes; with 
> an or-ed regex you end up having to search for both before 
> deciding what's correct.

This is not so.  The alternatives in an or-ed regex are tried in 
sequence, and the first one that matches stops the search (assuming that 
the rest of the pattern, if any, is also matched).

Rather than start up two regex matches (in case the first one fails), one 
should write simply:

    if ($line =~ /(?:^| )$Search /io)
 
-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 7 Oct 1998 02:25:56 GMT
From: pfeilgm@jmu.edu
Subject: regexps and cntl chars
Message-Id: <6vejfk$5me$7@lark.jmu.edu>

I want do substitution on some control characters.

Obviously, "s/^M/\n/g" and such won't work.  How can I do this?

Thanks.

-- 
Greg Pfeil --- Software Engineer --- (pfeilgm@|http://)technomadic.org
"The people who created MIME not only should be convicted, they should
 be shot on the spot."                                --Linus Torvalds



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

Date: Tue, 6 Oct 1998 23:15:46 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: soft reference to object?
Message-Id: <1dgh3jl.somfqkf2998cN@slip-32-100-246-124.ny.us.ibm.net>

Kin Cho <kin@omni.c-cube.com> wrote:

> What's the 
> If I have a class BAR, what's syntax to soft reference BAR->new?
> I tried:
> 
> $a = ${'BAR->new'};
> 
> which doesn't work.
> 
> Any ideas?

$p = 'BAR';
$obj = $p->new;

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Tue, 6 Oct 1998 21:19:37 -0500
From: "brettr" <brettr@centuryinter.net>
Subject: SSI
Message-Id: <6vejb1$cq5$1@newsread1-mx.centuryinter.net>

I've recently started implementing some server side includes. Does anyone
know what I should be looking for with this message [an error occurred while
processing this directive] ? I get it when I reference the .shtml page.

This is the actual include in that page <!--#exec
cgi="/cgi-bin/lookwho.cgi" --> . The permissions are set correctly in the
cgi-bin. There's also a .txt file in the cgi-bin.

Any help would be appreciated.
brettr




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

Date: 7 Oct 1998 02:19:33 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: What's is wrong here?
Message-Id: <6vej3l$f6r$1@client3.news.psi.net>

Allen Choy (achoy@us.oracle.com) wrote on MDCCCLXII September MCMXCIII in
<URL:news:361A95CC.310A6638@us.oracle.com>:
++ 
++ 
++ $cnt = $foo =~ tr#$SEP#$SEP#;;
++ 
++ But it's not producing the same results.
++ 
++ I look at the Camel book, and it states that tr accepts a char list, so
++ if $SEP eq  '/',
++ it should work, right? Unless it's interpolating it in a way I'm not
++ familiar with.


tr/// doesn't interpolate.

Either use s///, or eval.


Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: 7 Oct 1998 01:19:49 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: Why does this program chomp 18 MB of memory?
Message-Id: <6vefjl$jtq$1@nnrp2.snfc21.pbi.net>



Nothing above this line is part of the signed message.

In article <Pine.WNT.4.03.9810062035520.326-100000@legacy.cs.virginia.edu>,
David Coppit  <dwc3q@cs.virginia.edu> wrote:
>
>When I run the following program:
>
>----
>
>#!/usr/cs/bin/perl
>
>open (A,"xxx");
>
>while ($line = <A>)
>{
>  $string .= $line;
>}
>
>print length $string;
><STDIN>;
>
>-----
>
>it reads the file and prints "4440797", but Unix top says:
>
>  PID USERNAME THR PRI NICE  SIZE   RES STATE   TIME    CPU COMMAND
>14256 dwc3q      1   0    0   18M   14M sleep   0:00  2.02% tester
>
>What's going on? Does Perl really need 3-4 times the memory to hold a
>string?
Not exactly. But it may need 3-4 times the memory to hold the
_temporary copies_ of the string as it is processed because
of the way you read and append it. You should just gulp
the whole file in one swoop instead of looping. It will be
faster and should take less memory.

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

use strict;

if (! open(THEFILE,"xxx")) {
   die ("Couldn't open xxx\n$!");
} else {
   local $/ = undef;
   my $string;
   $string = <THEFILE>;
   close (THEFILE);
   print (length($string),"\n");
   <STDIN>;
}

Benjamin Franz


Version: 2.6.2

iQCVAwUBNhrBXujpikN3V52xAQGQIQP/doNSOaRpVKoAJxGfvkMIITf7S9IXC/Od
AoDY4qNyrh0nYa+2sYadc0r8xh+++oFNHuEXwbDLJAQXNDQrxWTsYDj20988v1Yo
GREMMa7c/5OW6aH3zCWW/lqDl16YH+UXINQKK+94mpdvafR6ajlLAxCjgMVkOq9u
aTQ6Dd+MJc4=
=O1ZH
-----END PGP SIGNATURE-----


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

Date: 7 Oct 1998 03:21:15 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Why does this program chomp 18 MB of memory?
Message-Id: <6vemnb$ak6$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Snowhare
<snowhare@devilbunnies.org>],
who wrote in article <6vefjl$jtq$1@nnrp2.snfc21.pbi.net>:
> >it reads the file and prints "4440797", but Unix top says:
> >
> >  PID USERNAME THR PRI NICE  SIZE   RES STATE   TIME    CPU COMMAND
> >14256 dwc3q      1   0    0   18M   14M sleep   0:00  2.02% tester
> >
> >What's going on? Does Perl really need 3-4 times the memory to hold a
> >string?
> Not exactly. But it may need 3-4 times the memory to hold the
> _temporary copies_ of the string as it is processed because
> of the way you read and append it. You should just gulp
> the whole file in one swoop instead of looping. It will be
> faster and should take less memory.
> 
> #!/usr/cs/bin/perl -w
> 
> use strict;
> 
> if (! open(THEFILE,"xxx")) {
>    die ("Couldn't open xxx\n$!");
> } else {
>    local $/ = undef;
>    my $string;
>    $string = <THEFILE>;
>    close (THEFILE);
>    print (length($string),"\n");
>    <STDIN>;
> }

With Perl's malloc (and Solaris malloc()) it will take some small
memory overhead indeed.  With some other malloc()s it may be better to
preallocate the string (in the example below step right or step left
is considered as a try to run away):

   $string = 'a';
   $string x= -S 'xxx';
   $string = <THEFILE>;

(here I assume binary mode for the file, otherwise you may need
different size than what is given by -S.)

Ilya


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3912
**************************************

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