[8741] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2358 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 18 10:07:22 1998

Date: Sat, 18 Apr 98 07:00:31 -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           Sat, 18 Apr 1998     Volume: 8 Number: 2358

Today's topics:
        ANNOUNCE: update of HTML::TableLayout <sfarrell+usenet@farrell.org>
    Re: Array / List question <road@apdo.com>
    Re: array of matches in s/// (Bart Lateur)
    Re: Fastest "smallest power of 2 >= N" in Perl? <igork@pacbell.net>
    Re: Fastest "smallest power of 2 >= N" in Perl? (Abigail)
    Re: Fastest "smallest power of 2 >= N" in Perl? <tchrist@mox.perl.com>
    Re: function pointers <Pat_kane@compuserve.com>
    Re: function pointers <grinch@whoville.com>
    Re: How can i see if a proc/prog is running <igork@pacbell.net>
    Re: how to remove blanks? <zenin@archive.rhps.org>
    Re: how to remove blanks? <zenin@archive.rhps.org>
        How to skip HTML codes? <noels@chilli.net.au>
    Re: How to skip HTML codes? <grinch@whoville.com>
        Implementation of map. <richard@cs.newcastle.edu.au>
    Re: Macperl news group (Rich Morin)
        Multiline RegExp problem <Tomi.Tuominen@iki.fi>
    Re: new syntax for tied variables? <tchrist@mox.perl.com>
    Re: Perl Performace: CPU, and System Resource Usage. <ebohlman@netcom.com>
    Re: Perl Performace: CPU, and System Resource Usage. <ebohlman@netcom.com>
    Re: Perl, MySQL on my home PC <gwynne@utkux.utk.edu>
    Re: uninitialized <STDIN> chunk 1. ???? Please ignore a <toby@he-net.demon.co.uk>
    Re: Wanna laugh?  (My First cgi.pm Script) (Craig Berry)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 18 Apr 1998 13:16:02 GMT
From: stephen farrell <sfarrell+usenet@farrell.org>
Subject: ANNOUNCE: update of HTML::TableLayout
Message-Id: <6ha92i$ea8$1@news.neta.com>


-------------------------------------------------------------------
This is a Perl package (available from CPAN) for creating web-based
graphical user interfaces. It provides an extensible, OO widget set
allowing a high degree of abstraction comparable (I hope) in many ways
to widget sets commonly used for normal graphical user interfaces. At
its core is an integrated layout management capability based on HTML
tables.

If you want to create a user-interface on the web with cgi in perl,
this package could make you life a lot easier.
-------------------------------------------------------------------

This is a bugfix release.  HTML::TableLayout has been updated.  It
should make it to a CPAN near you soon.  It is available immediately
at http://people.healthquiz.com/sfarrell/TableLayout/.  The new
version is 1.001005.


Some future directions: 

	1. integrate with CGI.pm (*)
	2. discover extent of, and fix, memory leakage

(*) If this is of particular interest to you (i.e., you have some
thoughts or are willing to do some of the work, please let me know!)

Changes

## 1. fixed another sawanampersand problem pointed out by AK.
## 2. slipped the forms inside the table (and cell) so they don't
##    cause an extra space in the containing table (if any).
## 3. added support for breaks after list elements
## 4. fixed problem with >< in FormComponentMulti items, plus can now
##    embed real components (not just text) in FormComponentMulti.
## 9. Make a generic container for grouping things together (no
##    formatting)... call it "box" or somesuch.2/8/1998 11:43pm
##    (modified componentcontainer to have a tl_print)
## 11. added "getName()" to Form class... this will get the
##     appropriate "name"... if there is no name, or you set the
##     "force_numeric" flag, then it returns a number for the name.
##     This number, of course, happens to correspond to the number of
##     the component in the javascript document model.  this is
##     important for supporting IE3, which doesn't support symbolic
##     naming of such.
## +. moved form back *outside* of the cell, otherwise it incurs a
##    mess of extra padding. (but should be *inside* table... gotta
##    love it)
## +. added setParams()
## +. added HTML::TableLayout::VERSION variable.
## +. tinkered with padding of text (tl_do_not_pad()) 4/14/1998 
## +. added delete() method to base class.  NOT YET IMPLEMENTED. 4/14/1998 





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

Date: Sat, 18 Apr 1998 13:17:53 +0200
From: "A.P." <road@apdo.com>
Subject: Re: Array / List question
Message-Id: <35388BE1.B81A8481@apdo.com>

Well,
First of all, thanks a lot to all of you for your help. My real question
has been answered. I really didn't see a difference between an array an a
list. Now I can see they are different. Anyway, I've been scanning through
the documentation and I've been unable to find a reference to the behaviour
of a list in an scalar context.
I knew I was doing some silly questions, obviously I knew that

@j=@i[@i]**2; #really the same IN THIS CASE as @j=@i**2

wouldn't square all the elements of the array, it was just an example.
Anyway it was a bit silly, I should have written @j=@i**2 for the sake of
clearity.
Well, once again, thanks a lot!!!

A.P. wrote:

> Hi!
> I don't understand the behaviour of the following code:
>
> print ((0,4)**2);
>
> It prints 16, why doesn't it print 0? I discovered this trying to do it
> with an array. I'm a Perl beginner and I wondered if there was a way of
> doing some operation (like squaring) all the elements of an array/list
> without using a loop block. What I tried was:
>
> @i=(0..4);
> @j=@i[@i]**2;
> print @j;
>
> I thought that it should print 25, but it prints 16!!! I say this
> because an array in an scalar context  I think it should return the
> number of elements, not the value of the last one. Please help! I can't
> stand not knowing the solution! Thanks a lot!





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

Date: Sat, 18 Apr 1998 09:34:26 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: array of matches in s///
Message-Id: <353d677e.1712122@news.tornado.be>

Charles DeRykus wrote:

>Could you substitute format strings in the key values 
>or did something get mangled in translation... :) 

 $key = 'It is now (\d+) to (\d+)\.';
>>  $translate{$key} = 'Il est %s heures moins %s.'; 
>  if (my @matches = /^$key/) {
>     s/^$key/sprintf "$translate{$key}", @matches/e;
>  }

<GRIN> Fooled you. I purposely took this particular phrase as the
example, because the required order of the submatches is different in
French and English.

But anyway, the cleanest way do to it with current Perl indeed seems to 
be, to do the matching twice, like you did.

    if (my @matches = /^$key/) {
        s/^$key/&interpolate($translate{$key}, @matches)/e;
    }

Except, of course, that now matching needs to be done twice. This isn't
very efficient, especially since we can't use the //o option, as we need
to test various phrases.

	Bart.


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

Date: 18 Apr 1998 09:01:11 GMT
From: "Igor Krivokon" <igork@pacbell.net>
Subject: Re: Fastest "smallest power of 2 >= N" in Perl?
Message-Id: <01b41e85$d09ed5c0$8418aace@igork>

Well, what about this:   

   f(N) = 1 << log(N-0.5)/log(2.0) + 1 

As far as I understand (from original post),  for N<=0 the function should
return 1,
(btw, why not 0?) 
so we get the following:

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

sub igors_smallestPowerOfTwoGE {
   return ($_[0] > 0) ? (1 << log($_[0]-0.5)/log(2.0) + 1) : 1;
}

sub toms_SmallestPowerOfTwoGE {
    use integer;
    my $a=sprintf("%o",(shift)-1);
    return 1<<(3*length($a)+(-3,-2,-1,-1,0,0,0,0)[ord($a)-48]) ;
}

use Benchmark;

timethese (2**16, {
TOM   => q{ my $spot = toms_SmallestPowerOfTwoGE(31) },
IGOR  => q{ my $spot = igors_smallestPowerOfTwoGE(31) },
TOM1   => q{ my $spot = toms_SmallestPowerOfTwoGE(1 << 30) },
IGOR1  => q{ my $spot = igors_smallestPowerOfTwoGE(1 << 30) },
});

__END__

Benchmarks:
1) PC, Win95:
Benchmark: timing 65536 iterations of IGOR, IGOR1, TOM, TOM1...
      IGOR:  8 secs ( 7.25 usr  0.00 sys =  7.25 cpu)
     IGOR1:  8 secs ( 7.28 usr  0.00 sys =  7.28 cpu)
       TOM: 11 secs (10.12 usr  0.00 sys = 10.12 cpu)
      TOM1: 11 secs (10.10 usr  0.00 sys = 10.10 cpu)

2)UltraSPARC, Solaris:
Benchmark: timing 65536 iterations of IGOR, IGOR1, TOM, TOM1...
      IGOR:  2 secs ( 1.72 usr  0.00 sys =  1.72 cpu)
     IGOR1:  2 secs ( 1.64 usr  0.00 sys =  1.64 cpu)
       TOM:  3 secs ( 2.88 usr  0.00 sys =  2.88 cpu)
      TOM1:  3 secs ( 2.89 usr  0.00 sys =  2.89 cpu)


Regards,

Igor Krivokon
<igor.k@usa.net>


Larry Rosler <lr@hpl.hp.com> wrote in article
<35383658.7C118BBE@hpl.hp.com>...
> Benchmark: timing 16384 iterations of CARL, CARL1, LLOYD, LLOYD1, TOM,
> TOM1...
>       CARL:  2 secs ( 1.30 usr  0.01 sys =  1.31 cpu)
>      CARL1:  4 secs ( 4.00 usr  0.00 sys =  4.00 cpu)
>      LLOYD:  2 secs ( 1.76 usr  0.01 sys =  1.77 cpu)
>     LLOYD1:  8 secs ( 7.21 usr  0.01 sys =  7.22 cpu)
>        TOM:  1 secs ( 1.20 usr  0.01 sys =  1.21 cpu)
>       TOM1:  0 secs ( 1.21 usr  0.00 sys =  1.21 cpu)
> 
> Conclusion:  Tom's clever loopless algorithm is a clear winner.
> 
> Larry Rosler
> Hewlett-Packard Laboratories
> lr@hpl.hp.com
> 


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

Date: 18 Apr 1998 10:38:40 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Fastest "smallest power of 2 >= N" in Perl?
Message-Id: <6h9vrg$c0k$1@client2.news.psi.net>

Lloyd Zusman (ljz@asfast.com) wrote on MDCXCI September MCMXCIII in
<URL: news:ltg1jbvjhi.fsf@asfast.com>:
++ Lloyd Zusman <ljz@asfast.com> writes:
++ 
++ > [ ... ]
++ >
++ > Benchmark: timing 8 iterations of CARL, NEWLLOYD, TOM, VARIATION...
++ >       CARL: 17 secs (16.56 usr  0.00 sys = 16.56 cpu)
++ >   NEWLLOYD: 12 secs (12.25 usr  0.00 sys = 12.25 cpu)
++ >        TOM:  8 secs ( 8.22 usr  0.00 sys =  8.22 cpu)
++ >  VARIATION:  8 secs ( 7.90 usr  0.00 sys =  7.90 cpu)
++ 
++ OOPS!  I forgot to put a "use integer" into the Perl-ized version of
++ Carl's routine.  Here's the corrected version, followed by the updated
++ results.  Carl's routine ran noticeably better, but the overall
++ rankings remained the same.
++ 
++   sub carls_version {
++     use integer;
++     my $x = shift;
++     my $nbits = 32;
++     while(($x>>=1) != 0) {
++       --$nbits;
++     }
++     return 1<<(++$nbits);
++   }

sub foo {
    use integer;
    my ($x, $y) = (shift, 2);
    $y <<= 1 while $x >>= 1;
    $y;
}

sub bar {
    use integer;
   (my $x = unpack "B32", pack "N", shift) =~ s/^0+//;
    1 << length $x;
}

sub bar2 {
    use integer;
    1 << (32 - index unpack ("B32", pack "N", shift), 1);
}



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: 18 Apr 1998 11:50:19 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Fastest "smallest power of 2 >= N" in Perl?
Message-Id: <6ha41r$pfq$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Lloyd Zusman <ljz@asfast.com> writes:
:The following algorithm (see below) returns the smallest power of 2
:which is greater than or equal to a given integer.  For example:
:
:  smallestPowerOfTwoGE(15) -> 16
:  smallestPowerOfTwoGE(16) -> 16
:  smallestPowerOfTwoGE(17) -> 32

Look at the number in binary.  Find the first bit set.  If there are no
other bits set, that's the number you want.  Otherwise, the number you
want is the one with only the previous (one place left) bit set.

You might see Programming Perl version 1 (magenta), page 211.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    I think it's a new feature.  Don't tell anyone it was an accident.  :-)
            --Larry Wall on s/foo/bar/eieio in <10911@jpl-devvax.JPL.NASA.GOV>


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

Date: Sat, 18 Apr 1998 03:00:13 -0400
From: Pat Kane <Pat_kane@compuserve.com>
Subject: Re: function pointers
Message-Id: <35384F7D.49@compuserve.com>

Richard Pocklington wrote:
> 
> Is there a perly way to accomplish what function pointers do?


Check out the Randall Schwartz Unix Review column that discusses this
very topic. Its at
http://www.stonehenge.com/merlyn/UnixReview/col08.html

Pat

> 
> in my rather sheltered programming experience this means ...
> pass a variable into a subroutine that determines what function
> that subroutine will call at a given spot.
> 
> thanks.
> richard


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

Date: Sat, 18 Apr 1998 09:00:04 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: function pointers
Message-Id: <6ha79c$34f@fridge.shore.net>

Richard Pocklington wrote in message <6h94eb$1b8@epic11.Stanford.EDU>...

>Is there a perly way to accomplish what function pointers do?


Yep.

#!/usr/bin/perl -w

$a = sub {
    return "Subroutine a";
};

$b = sub {
    return "Subroutine b";
};

print &$a, &$b;

For more/better help, look through the docs/faq/books for anonymous
subroutines.

HTH!

-grinch

--
-----
"Yes, I'm paranoid, but that doesn't mean
no one's out to get me." - me

Sherm Pendley
grinch@whoville.com
http://www.whoville.com





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

Date: 18 Apr 1998 10:24:34 GMT
From: "Igor Krivokon" <igork@pacbell.net>
Subject: Re: How can i see if a proc/prog is running
Message-Id: <01b41e91$a62cefa0$b118aace@igork>

Torfinn Keringen <tor@kmd.dk> wrote in article
<6h77br$mpk$1@news1.tele.dk>...
> Hy
> How can i see if an process is running on an Win95/NT, something like
> 
> ps -ef | grep process_to_look_for
> 

1) If you have NT + Resource Kit, use `tlist` (not sure about Win95)

2) Standard Win32 Perl distribution includes Win32::Process module.
It has create(...) and wait(...) functions; seems like that's what you
need.

Regards,

Igor Krivokon
<igor.k@usa.net>



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

Date: 18 Apr 1998 09:57:25 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: how to remove blanks?
Message-Id: <892893872.942721@thrush.omix.com>

[ posted & mailed ]

Mike Heins <mikeh@minivend.com> wrote:
: I think we should care, for your test code does nothing except create a
: subroutine reference thousands of times,

	You'll *really* need to explain what you meen, as my test code
	does no such thing that I can see.  If you refer to the use of
	code refs instead of code strings, this is both a supported
	and clearly documented feature of the Benchmark interface.
	If you refer to anything else, please explain.

: and one has a syntax error.

	Ah yes, so it does at that.  However, do you know that you made the
	exact *same* syntax error in *your* test code?!?  I wouldn't normally
	jump on anyone that hard for such an error as it's an easy typo to
	make, however when you call someone on an error and then within the same
	message commit the exact same error...well, you get the idea. :-)

	HOWEVER, even when fixed it makes no difference:

	$ perl foo.pl 
	Benchmark: timing 100000 iterations of WITH, WITHOUT...
	      WITH: 17 secs ( 4.02 usr  0.01 sys =  4.03 cpu)
	   WITHOUT: 19 secs ( 4.05 usr  0.01 sys =  4.06 cpu)
	$ cat foo.pl 
	#!/usr/local/bin/perl
	
	use Benchmark;
	
	timethese 100000, {
	        WITH    => sub {
	                $foo = '    foo         ';
	                $foo =~ s/(?:^\s+|\s+$)//g;
	        },
	        WITHOUT => sub {
	                $foo = '    foo         ';
	                $foo =~ s/^\s+|\s+$//g;
	        }
	};

	__END__

	If the \+ instead of \s+ was not what you refereed too as the syntax
	error, please explain.  I no longer see a syntax error here, and have
	yet to see any "creation of a subroutine reference thousands of times".

: A more meaningful comparision would be:

	You're *highly* mistaken.  It's the other way around infact.  Read
	on.

:         WITH    => q{

	You use code strings, I use code references. No meaningful difference.
	Actually, if you check Benchmark::runloop() you'll see that the only
	difference is that code refs have one extra stack layer as they need
	to be called.  I'd call this a bug myself, as it would be trivial to
	make code strings perform exactly the same, but it really would only
	make a difference if the tests where mixed with some string, some
	code ref, which neither of our code does.

	I'm still looking for that repeated sub ref you mentioned...

:               $foo = '    foo         ';
:               $foo =~ s/(?:^\s+|\+$)//g;
                                 /|\
                                  |
                I'm not the only one with syntax errors! :-)

	Now, when we pull your code back into reality, we find that once
	again the perl compiler has completely optimized away the (?:) code
	such that it makes to speed difference what so ever if you use it
	or not. -And why should it, since it does NOT create the back
	references that might otherwise slow it down?

	$ perl foo.pl 
	Benchmark: timing 1000000 iterations of TWOOPS, WITH, WITHOUT...
	    TWOOPS: 32 secs (25.50 usr  0.01 sys = 25.51 cpu)
	      WITH: 39 secs (29.29 usr  0.03 sys = 29.32 cpu)
	   WITHOUT: 36 secs (27.89 usr  0.02 sys = 27.91 cpu)
	$ perl foo.pl 
	Benchmark: timing 1000000 iterations of TWOOPS, WITH, WITHOUT...
	    TWOOPS: 32 secs (25.95 usr  0.06 sys = 26.02 cpu)
	      WITH: 36 secs (28.05 usr  0.05 sys = 28.10 cpu)
	   WITHOUT: 40 secs (29.01 usr  0.04 sys = 29.05 cpu)
	$ cat foo.pl
	#!/usr/local/bin/perl
	
	use Benchmark;
	
	timethese 1_000_000, {
	        WITH    => q{
	                $foo = '    foo         ';
	                $foo =~ s/(?:^\s+|\s+$)//g;
	        },
	
	        TWOOPS => q{
	                $foo = '    foo         ';
	                $foo =~ s/^\s+//;
	                $foo =~ s/\s+$//g;
	        },
	
	        WITHOUT => q{
	                $foo = '    foo         ';
	                $foo =~ s/^\s+|\s+$//g;
	        },
	};
	$ perl -V
	Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
	  Platform:
	    osname=freebsd, osvers=2.2.5-stable, archname=i386-freebsd
	    uname='freebsd thrush 2.2.5-stable freebsd 2.2.5-stable #0: wed dec 10 08:40:31 pst 1997 byron@thrush:usrsrcsyscompilethrush i386 '
	    hint=recommended, useposix=true, d_sigaction=define
	    bincompat3=y useperlio=undef d_sfio=undef
	  Compiler:
	    cc='cc', optimize='-O', gccversion=2.7.2.1
	    cppflags='-I/usr/local/include'
	    ccflags ='-I/usr/local/include'
	    stdchar='char', d_stdstdio=undef, usevfork=true
	    voidflags=15, castflags=0, d_casti32=undef, d_castneg=define
	    intsize=4, alignbytes=4, usemymalloc=n, prototype=define
	  Linker and Libraries:
	    ld='ld', ldflags =' -L/usr/local/lib'
	    libpth=/usr/local/lib /usr/lib
	    libs=-lgdbm -lm -lc -lcrypt
	    libc=/usr/lib/libc.so.3.0, so=so
	    useshrplib=false, libperl=libperl.a
	  Dynamic Linking:
	    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
	    cccdlflags='-DPIC -fpic', lddlflags='-Bshareable  -L/usr/local/lib'


	Characteristics of this binary (from libperl): 
	  Built under freebsd
	  Compiled at Dec 15 1997 12:33:05
	  @INC:
	    /usr/local/lib/perl5/i386-freebsd/5.00404
	    /usr/local/lib/perl5
	    /usr/local/lib/perl5/site_perl/i386-freebsd
	    /usr/local/lib/perl5/site_perl
	    .

: As has been exposed in the group many times before, the two operations
: with a fixed beginning or ending string anchor blows away the alternation
: operator.

	Not under x86 FreeBSD it doesn't.  It's faster yes, but only by a
	matter of a couple clock ticks.  It's *vary* hardware/OS related
	however, as a test of the exact same code under Solaris is quite
	different still:

	$ perl foo.pl 
	Benchmark: timing 1000000 iterations of TWOOPS, WITH, WITHOUT...
	    TWOOPS: 41 secs (39.00 usr  0.01 sys = 39.01 cpu)
	      WITH: 64 secs (51.98 usr  0.00 sys = 51.98 cpu)
	   WITHOUT: 71 secs (48.27 usr  0.00 sys = 48.27 cpu)
	$ uname -a
	SunOS omix 5.5.1 Generic_103640-12 sun4m sparc SUNW,SPARCstation-20
	$ perl -e 'print "$]\n"'
	5.00404

	I'll save the full config dump this time unless you really want to
	see it.

: The parens do nothing but slow things down.

	You didn't stop soon enough.  The correct information is simply, "The
	parens do nothing", period.

: Just because something is           131 Willow Lane, Floor 2  | ||  _ \
: obviously happening doesn't         Oxford, OH  45056         | || |_) |
: mean something obvious is           <mikeh@minivend.com>     |___|  _ <
: happening. --Larry Wall             513.523.7621 FAX 7501        |_| \_\

	Exactly!  I think we could have peace on earth, if people would only
	read there own .sig files. :-)

-- 
-Zenin (zenin@archive.rhps.org)
 The Bawdy Caste (San Jose, CA)       http://www.netmagic.net/~dmcgrath/bawdy/
 Barely Legal   (Berzerkly, CA)                    http://www.barelylegal.org/
 Zenin's Rocky Horror Archive (I MOVED!)          http://www.archive.rhps.org/


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

Date: 18 Apr 1998 09:59:47 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: how to remove blanks?
Message-Id: <892894015.429484@thrush.omix.com>

Craig Berry <cberry@cinenet.net> wrote:
: That grouping paren set around the entire pattern seems pointless to me --
: am I missing something?

	Clarity, nothing else.

	As we have beaten to death here through a number of benchmarks, it
	makes no difference what so ever either to the action or speed of
	the code, only it's readability.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Sat, 18 Apr 1998 19:20:36 +1000
From: "Noel Sampol" <noels@chilli.net.au>
Subject: How to skip HTML codes?
Message-Id: <892855951.821756@ajatar.dragon.net.au>

Hi,  I'm trying to write a CGI script that basically ignores and skips past
HTML code - anything and including between < > like <p align=center>.

Basically I want to display any text in a HTML file that is not between < >
and assume that it's HTML code so that it won't be displayed on screen.

For example, Suppose I have HTML code as follows:

<HTML><HEAD><TITLE>Test File</TITLE></HEAD>
<BODY>
<!--ENTRY BEGIN-->
<P><CENTER>This is only a test file</CENTER></P>
<P><CENTER>Entry Code=ENTRY01</CENTER></P>
<!--ENTRY END-->
</BODY></HTML>

 ...and, I want to only display "This is only a test file" and "Entry
Code=ENTRY01". That is, any non-HTML code between <!--ENTRY BEGIN--> and
<!--ENTRY END--> . How would I display it?
What if the HTML code is variable, that is I don't know for sure that it
will have <P><CENTER> before each line of text I'm interested in?

I've tried doing a substitute like s|<*.>|| but it doesn't work - I think it
just substitutes the whole line with a null string.

Thank you and I'd appreciate any help very much.

Noel Sampol
noels@chilli.net.au





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

Date: Sat, 18 Apr 1998 09:15:59 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: How to skip HTML codes?
Message-Id: <6ha872$45l@fridge.shore.net>

Noel Sampol wrote in message <892855951.821756@ajatar.dragon.net.au>...

>Hi,  I'm trying to write a CGI script that basically ignores and skips past
>HTML code

It sounds like you could use a template processing module. I use
Text::Template, but there are several others. With Text::Template, you embed
Perl code within a template that is mostly just text, HTML, or whatever.
Each embedded code snippet is eval()'d, and the result is inserted into the
template in its place.

Here's a simple example:

<!-- Before evaluating with Text::Template. -->
<p align="center">
    { $foo = '';
        foreach $i (1..5) { $foo .= $i; }
        $foo; }
</p>

<!-- After evaluating with Text::Template. -->
<p align="center">
    12345
</p>

HTH!

-grinch

--
-----
"Yes, I'm paranoid, but that doesn't mean
no one's out to get me." - me

Sherm Pendley
grinch@whoville.com
http://www.whoville.com





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

Date: Sat, 18 Apr 1998 18:53:36 +1000
From: Richard Webber <richard@cs.newcastle.edu.au>
Subject: Implementation of map.
Message-Id: <35386A10.3007@cs.newcastle.edu.au>

Hi all,

A quick techie question.

Does the builtin map function guarantee that it will process
each element of a list in order (actually process, not just output)?
This is important if you want the block passed to map to have
side-effects.

If not, is there a cleaner way to do it than this?

    foreach (@in) { effects($_); push(@out, func($_)); }

Email replies please.

Richard.

-- 
Richard Webber              .-_|\      Department of Computer Science
room: ES237                /     \       and Software Engineering,
phone: +61 2 49216034      \.--._/ <-- University of Newcastle,
fax: +61 2 49216929             v      Callaghan 2308, Australia
mailto:richard@cs.newcastle.edu.au
http://www.cs.newcastle.edu.au/~richard/
Caffeine -> Thesis -> Job -> Melbourne -> Love -> Life


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

Date: Sat, 18 Apr 1998 02:18:33 -0700
From: rdm@cfcl.com (Rich Morin)
Subject: Re: Macperl news group
Message-Id: <rdm-1804980218330001@140.174.42.30>

In article <3303A2B7.3F82@callisto.si.usherb.ca>,
eslcafe@callisto.si.usherb.ca wrote:

> Is there a macperl news group? ...

AFAIK, there is no news group, but there is a quite active email list.
Visit the MacPerl Pages (http://www.ptf.com/macperl) for details...

-r

-- 
Canta Forda Computer Laboratory       | Prime Time Freeware - quality 
UNIX consulting, training, & writing  | freeware at affordable prices
+1 415-873-7841                       | +1 408-433-9662   -0727 (Fax)
Rich Morin, rdm@cfcl.com              | www.ptf.com, info@ptf.com


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

Date: Sat, 18 Apr 1998 13:13:13 +0300
From: Tomi Tuominen <Tomi.Tuominen@iki.fi>
Subject: Multiline RegExp problem
Message-Id: <35387CB9.B0FC194B@iki.fi>

Hi there!

My goal is to make a script which reads files specified
in the command line and then remove first (and _only_ first)
comments.
Comments can be written in C or C++ style. (ie. // or /* ... */)

The question is how do I match multiple lines if the file looks like

/**** start ****
	blaa1 blaa1
	blaa2 blaa2
**** end ****/

// more comments
//

and I want it to look like

// more comments
//

 ...after execution of my script.

---8<---snip---

I have tried this

open (FILE, $file) || die "Can't open $file - $!\n";
@temp = <FILE>;

$i = 0;
foreach (@temp) {
	# remove if match
	next if (/^\s+/ && $i == 0);
	next if (/^\/\// && $i == 0);
	$i = 1;

	print $_;
}

 ...but could not came up with good regexp to match
standard C comments.

Can I solve this using /m ?

Thanks in advance.

 ..T..


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

Date: 18 Apr 1998 11:55:50 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: new syntax for tied variables?
Message-Id: <6ha4c6$pfq$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, ken@forum.swarthmore.edu (Ken Williams) writes:
:tie(%hash, 'MyTie');
:$hash{one} = 'two';          # Regular access
:%hash->extra_method("arg");  # Special access

$hash = tie(%hash, MyTie);

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "Have the appropriate amount of fun." --Larry Wall


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

Date: Sat, 18 Apr 1998 07:14:18 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Perl Performace: CPU, and System Resource Usage.
Message-Id: <ebohlmanErLLFv.G8B@netcom.com>

phdss@writeme.comm wrote:

: Any faqs or articles discussing perl system performance?  Speed tips
: and other related matters?

In the Camel, there's a 9-page section called "efficiency" which 
discusses the various factors that contribute to the various kinds of 
efficiency that apply to Perl programs (speed efficiency, space 
effeciency, maintenance efficiency, etc.) and the tradeoffs between them.



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

Date: Sat, 18 Apr 1998 07:19:42 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Perl Performace: CPU, and System Resource Usage.
Message-Id: <ebohlmanErLLou.LKE@netcom.com>

Eric Bohlman <ebohlman@netcom.com> wrote:
: In the Camel, there's a 9-page section called "efficiency" which 
: discusses the various factors that contribute to the various kinds of 
: efficiency that apply to Perl programs (speed efficiency, space 
: effeciency, maintenance efficiency, etc.) and the tradeoffs between them.
    ^^^
This is a typo, not an implication that anyone who optimizes for space is 
full of shit :)



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

Date: Sat, 18 Apr 1998 09:15:53 -0400
From: "Bob Gwynne" <gwynne@utkux.utk.edu>
Subject: Re: Perl, MySQL on my home PC
Message-Id: <6ha94v$quc$1@gaia.ns.utk.edu>

See the Perl FAQ at
http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html.

Bob Gwynne
Speech Comm
University of Tennessee


darren vollmer wrote in message <35384995.4B411D1F@mail.anet-stl.com>...
>Ill try not to sound like a bonified moron:
>
>I would like to install Perl (5.004) and MySQL on my laptop(win95) so
>that I can build and debug scripts without connecting to a server.  The
>scripts, once finished will be uploaded to a Linux server running Perl
>5.004 and MySQL.
>
>What download of Perl should I get?  Theres a quite a list of files.  Do
>I need to "build" the perl install with a c compiler?  Where can I get a
>compatible c compiler (free).  I have a non compatable version boreland
>compiler.
>
>If someone out there could take the time to layout in newbie speak how
>to correctly install and make perl, correctly install and make MySQL on
>a win95 laptop/desktop it would be greatly appreciatted.  The simplest
>route to install that permits me to use the MySQL module is what I'm
>looking for.
>
>I realize that most , if not all, of this information is available on
>the net, but the problem is:  There is an overwhelming amount of it.   I
>have quite a bit of experience scripting in perl, but never setting it
>up.
>
>Thanks
>Darren Vollmer
>




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

Date: Sat, 18 Apr 1998 07:55:33 +0100
From: Toby Heywood <toby@he-net.demon.co.uk>
Subject: Re: uninitialized <STDIN> chunk 1. ???? Please ignore as problem solved!
Message-Id: <35384E65.A7EA99F9@he-net.demon.co.uk>

This is a multi-part message in MIME format.
--------------C47B5E87ACBA3DD44A87B665
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Toby Heywood wrote:
> 
> Hi folks
> 
> If you have read any of my other messages to the comp.lang.perl.misc
> group you will already know that I'm ne to perl, and have only just
> started to learn the language.  I'm using the book Learning Perl by
> Randal L. Schwartz, to teach my self to program in perl.
> 
> anyway I'll get to the point.  I have typed out one of the scripts, and
> compiled it with the -w flag on, and I get a message which says:-
> 
> Use of uninitialized value at eercise2.6.pl line 6, <STDIN> chunk 1.
> 
> No I have read through the script about a dozen times now and I can't
> find the problem.  The one thing that has really stumped me is that the
> error message is complaining about line 6 when
> $guess = <STDIN>; is on line 5.
> 
> Can anyone shed some light on this?
> 
> Thank you for your help in advance.
> 
Sorry for sending a message which as it turned out if I stared at the
code long enough I would fine it, which I did and no I feel a little
silly, but any how.

Thanks all the same.

-- 
Toby Heywood <toby@he-net.demon.co.uk>
Proprietor, Heywood Enterprises
----------------------------------------
Website - http://www.he-net.demon.co.uk/
----------------------------------------
--------------C47B5E87ACBA3DD44A87B665
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Toby Heywood
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Toby Heywood
n:              Heywood;Toby
org:            Heywood Enterprises
email;internet: toby@he-net.demon.co.uk
title:          Proprietor
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard


--------------C47B5E87ACBA3DD44A87B665--



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

Date: 18 Apr 1998 06:52:58 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Wanna laugh?  (My First cgi.pm Script)
Message-Id: <6h9ika$g8$4@marina.cinenet.net>

Mark-Jason Dominus (mjd@op.net) wrote:
: Craig Berry <cberry@cinenet.net> wrote:
: >> >That can be written as:  print <HEADER>;
: >M-J. Dominus:
: >> Maybe you meant
: >> 
: >> 	print while <HEADER>;
: >
: >That works too, but is (a little bit) slower.  

: Is that an `I think' or `I know'?  Because I was surprised to hear you
: say it, and when I tried it, the one you said would be slower was
: about 10% faster:
[annoying facts toppling my lovely theory snipped]

It was an 'I think', and it turns out I thunk wrong.  Thanks for striking 
a blow for empiricism.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.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 2358
**************************************

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