[8739] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2356 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 17 23:07:19 1998

Date: Fri, 17 Apr 98 20:00:25 -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           Fri, 17 Apr 1998     Volume: 8 Number: 2356

Today's topics:
    Re: Array / List question (Abigail)
    Re: CLPM CONTENT POLICE (was info on cookies) <ebohlman@netcom.com>
    Re: commenting a whole block? (Abigail)
    Re: Farnham's Freehold <jason@primal.ucdavis.edu>
    Re: Farnham's Freehold <sowmaster@juicepigs.com>
    Re: Fastest "smallest power of 2 >= N" in Perl? (Tom Rokicki)
    Re: Fastest "smallest power of 2 >= N" in Perl? (Andre L.)
    Re: Fastest "smallest power of 2 >= N" in Perl? (carl barron)
    Re: how to remove blanks? <zenin@archive.rhps.org>
    Re: how to remove blanks? <zenin@archive.rhps.org>
    Re: how to remove blanks? <zenin@archive.rhps.org>
        Informix <indu@healtheon.com>
        IS THERE SUCH A THING AS MULTI TASKING? <cwts@earthlink.net>
        Macperl news group <eslcafe@callisto.si.usherb.ca>
        Neutering exit in eval (Jack Applin)
    Re: new syntax for tied variables? <zenin@archive.rhps.org>
    Re: perl tutorial (WAS Re: General Rudeness, e.g. Re: N (Abby Franquemont)
    Re: Proplem with perl script (I'm new to perl) (Andre L.)
    Re: Send Message to Event Viewer <travisj@earthlink.net>
    Re: Snobby news group (John Callender)
    Re: Snobby news group <ebohlman@netcom.com>
        Special characters <bdkatz@collins.rockwell.com>
    Re: Special characters <sowmaster@juicepigs.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 18 Apr 1998 00:59:39 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Array / List question
Message-Id: <6h8ttr$6ge$1@client2.news.psi.net>

Dan Boorstein (danboo@negia.net) wrote on MDCXC September MCMXCIII in
<URL: news:3537B55B.9DC6284A@negia.net>:
++ 
++ @a = (10, 42);
++ timethese( 300_000, {
++   'foreach' =>  '@foo = @a; foreach (@foo) {$_**=2}',
++   'grep'    =>  '@foo = @a; grep($_**=2, @foo);',
++   'grep0'   =>  '@foo = @a; grep($_**=2 && 0, @foo);',

What's the point of this? 

$ perl -we '$a = 10; $a **= 2 && 0; print $a, "\n"'
1

You have your precedences wrong....




Abigail
-- 
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
           print+Just (), another (), Perl (), Hacker ();'


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

Date: Sat, 18 Apr 1998 02:15:00 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: CLPM CONTENT POLICE (was info on cookies)
Message-Id: <ebohlmanErL7L0.MHE@netcom.com>

Tad McClellan <tadmc@flash.net> wrote:

: Why can't they just have a single newsgroup with all 300,000 posts
: per day? 

Netcom *does* carry earth.general, which was newgrouped (by someone whose 
name is an anagram of "obtuse phrensy") for exactly that purpose.  
Doesn't seem to have taken off, though.



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

Date: 18 Apr 1998 01:16:43 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: commenting a whole block?
Message-Id: <6h8utr$6po$1@client2.news.psi.net>

Chris Nandor (pudge@pobox.com) wrote on MDCXC September MCMXCIII in
<URL: news:pudge-1704981518550001@ppp-12.ts-1.kin.idt.net>:
++ 
++ Personally, I like:
++ 
++ =pod
++ 
++ comment();
++ out();
++ all_this_code();
++ 
++ =cut


Yeah, but what if that section has a pod piece in it? ;)


Using an elegant editor:
      :x,ys/^/#/

where x and y are the line numbers of the beginning and end.



Abigail
-- 
perl -pwle '$_ .= reverse'


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

Date: Fri, 17 Apr 1998 17:03:55 -0700
From: Jason Christian <jason@primal.ucdavis.edu>
Subject: Re: Farnham's Freehold
Message-Id: <Pine.OSF.3.95.980417165516.973m-100000@primal.ucdavis.edu>

On Fri, 17 Apr 1998, Bob Trieger wrote:

> Tad McClellan wrote:
> > 
> > Bob Trieger (sowmaster@juicepigs.com) wrote:
> > : Grinch wrote:

print unless (/> > : > /);

> > : s/\n/\.\n/;
> >        ^
> >        ^
> >        ^ unnecessary (though desirable if you are paid by the character ;-),
> >          dot does not need to be escaped there...
> 
> Danke shone. The key-pushes I save by not escaping dots on the RHS of an
> re any more may just be the button pushes I use to dial a radio station
> and win a cruise.
|---------^^^^^^^^     
|
|> 
|> -- 
|> Bob Trieger               |  Titanic: big boat, bigger
|> sowmaster@juicepigs.com   |           iceberg, big deal
|                               ^^^^^^^^^^^^^^^^^^^^^^^^^^           
|                                          | 
|------------------------------------------|

You sure you wanna go on that cruise?  Maybe you should keep with the \.
--- 
Jason Christian                          University of California, Davis 
jason@primal.ucdavis.edu                  Agricultural and Resource Economics
Office:(530)752-1357 FAX:(530)752-5614   Davis, CA 95616



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

Date: Fri, 17 Apr 1998 20:09:39 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
Subject: Re: Farnham's Freehold
Message-Id: <3537EF43.54B9@juicepigs.com>

Jason Christian wrote:
> 
> On Fri, 17 Apr 1998, Bob Trieger wrote:
> 
> > Tad McClellan wrote:
> > >
> > > Bob Trieger (sowmaster@juicepigs.com) wrote:
> > > : Grinch wrote:
> 
> print unless (/> > : > /);
> 
> > > : s/\n/\.\n/;
> > >        ^
> > >        ^
> > >        ^ unnecessary (though desirable if you are paid by the character ;-),
> > >          dot does not need to be escaped there...
> >
> > Danke shone. The key-pushes I save by not escaping dots on the RHS of an
> > re any more may just be the button pushes I use to dial a radio station
> > and win a cruise.
> |---------^^^^^^^^
> |
> |>
> |> --
> |> Bob Trieger               |  Titanic: big boat, bigger
> |> sowmaster@juicepigs.com   |           iceberg, big deal
> |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^
> |                                          |
> |------------------------------------------|
> 
> You sure you wanna go on that cruise?  Maybe you should keep with the \.

Perhaps I should have stated a cruise in the Carribean. No icebergs
there unless of course Leona Helmsley is on vacation too.


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

Date: 17 Apr 1998 17:36:59 -0700
From: rokicki@cello.hpl.hp.com (Tom Rokicki)
Subject: Re: Fastest "smallest power of 2 >= N" in Perl?
Message-Id: <6h8sjb$pb3@cello.hpl.hp.com>



This is what I get:

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


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

Date: Fri, 17 Apr 1998 22:23:41 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Fastest "smallest power of 2 >= N" in Perl?
Message-Id: <alecler-1704982223410001@dialup-794.hip.cam.org>

In article <6h8sjb$pb3@cello.hpl.hp.com>, rokicki@cello.hpl.hp.com (Tom
Rokicki) wrote:

> This is what I get:
> 
>   sub mySmallestPowerOfTwoGE {
>     use integer;
>     my $a=sprintf("%o",(shift)-1);
>     return 1<<(3*length($a)+(-3,-2,-1,-1,0,0,0,0)[ord($a)-48]) ;
>   }

==============================

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

sub lloyds_smallestPowerOfTwoGE {
    use integer;
    my $value = shift;
    if ($value < 2) {
      return (1);
    }
    $value--;
    my $lastValue;
    do {
      $lastValue = $value;
    } while (($value &= ~(-$value)) != 0);
    return ($lastValue << 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**14, {

LLOYD => q{ my $spot = lloyds_smallestPowerOfTwoGE(31) },

TOM   => q{ my $spot = toms_SmallestPowerOfTwoGE(31) }

});

__END__

Benchmark: timing 16384 iterations of LLOYD, TOM...
     LLOYD:  7 secs ( 6.45 usr  0.00 sys =  6.45 cpu)
       TOM:  6 secs ( 5.68 usr  0.00 sys =  5.68 cpu)

A.L.


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

Date: Fri, 17 Apr 1998 22:42:54 -0400
From: cbarron3@ix.netcom.com (carl barron)
Subject: Re: Fastest "smallest power of 2 >= N" in Perl?
Message-Id: <199804172242546482639@buf-ny2-15.ix.netcom.com>

Tom Rokicki <rokicki@cello.hpl.hp.com> wrote:

> This is what I get:
> 
>   sub mySmallestPowerOfTwoGE {
>     use integer;
>     my $a=sprintf("%o",(shift)-1);
>     return 1<<(3*length($a)+(-3,-2,-1,-1,0,0,0,0)[ord($a)-48]) ;
>   }

int power_2(unsigned long x)
{
        int nbits = BITS_PER_LONG;


        while(x>>1) --nbits;
        return ++nbits;
}


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

Date: 18 Apr 1998 01:40:06 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: how to remove blanks?
Message-Id: <892864034.905965@thrush.omix.com>

Dan Boorstein <danboo@negia.net> wrote:
: what do they accomplish? actually, how is what they accomplish useful
: here? '$string =~ s/^\s+|\s+$//g' works just fine.

	Hmm, learn something new every day.

: i'm not sure if this is a truism or not, but it seems to me that any
: time you have:
: /(?:foo)/
: you can do away with the parens. you are merely being explicit in
: declaring the default grouping. it's overkill.

	Comming from a shell background where sed at al (at least, older
	versions.  Maybe it's different now...?) required that groups such
	as these be delimited explicitly.  I carried this over to perl, if
	for no other reason then I don't think I've seen anyone else leave
	them off either.

	I still don't consider it overkill, just cleaner to read the exact
	intent.  Speed is not affected at all (at least with ?: added so
	perl knows not to bother with storing it), as any tests will go one
	way or the other depending on the current phase of the moon:

	$ perl foo.pl 
	Benchmark: timing 100000 iterations of WITH, WITHOUT...
	      WITH:  4 secs ( 3.95 usr  0.01 sys =  3.95 cpu)
	   WITHOUT:  3 secs ( 3.90 usr  0.00 sys =  3.90 cpu)
	$ perl foo.pl 
	Benchmark: timing 100000 iterations of WITH, WITHOUT...
	      WITH:  4 secs ( 3.87 usr  0.00 sys =  3.87 cpu)
	   WITHOUT:  5 secs ( 3.84 usr  0.00 sys =  3.84 cpu)
	$ perl foo.pl 
	Benchmark: timing 100000 iterations of WITH, WITHOUT...
	      WITH:  5 secs ( 3.84 usr  0.00 sys =  3.84 cpu)
	   WITHOUT:  4 secs ( 3.84 usr  0.00 sys =  3.84 cpu)

	Now, we are really, really talking about splitting hairs here. :-)

	The test code, for those that care:
#!/usr/local/bin/perl

use Benchmark;

timethese 100000, {
	WITH	=> sub {
		$foo = '    foo  	';
		$foo =~ s/(?:^\s+|\+$)//g;
	},
	WITHOUT	=> sub {
		$foo = '    foo  	';
		$foo =~ s/^\s+|\+$//g;
	}
};

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: 18 Apr 1998 02:17:53 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: how to remove blanks?
Message-Id: <892866301.580261@thrush.omix.com>

Larry Rosler <lr@hpl.hp.com> wrote:
	>snip<
: Sorry, they don't perform any grouping at all (because '|' has the lowest
: precedence of any of the RE metacharacters).

	Learn something new everyday. -As I mentioned in another post,
	comming from a shell background put them into my common usage as
	other tools require them for grouping.

: Let me rephrase my comment above, less diffidently:
: "These parentheses don't accomplish anything, except a small slowdown (see
: below)."

	Even though not needed by the compiler, with the ?: at least they
	do not slow anything down as Benchmarks prove by going one way or
	the other (+ or - nano-seconds here...) depending on the exact
	location of my mouse xored with the exact about of coffee left in
	my cup. :-)

: And,  as indicated in my paraphrase above, I'm well aware that they don't
: capture anything.  BTW, the 'o' in your snippet below doesn't do anything
: either (no interpolation in the RE).
: >                $foo =~ s/(?:^\s+|\s+$)//go;

	Ya, I know.  I was just umm, making sure.  Ya...  That's it... :-)

: "I have measured the following variation to be FASTEST, provided you are
: sure there is at least one non-space character in the  operand.  (You can
: test the value of the expression -- FALSE if there are no non-space
: characters -- but that test dissipates the small speed advantage.)"

	We're still talking nano-seconds here.

: Here is the code for the new results reported below.  It is really your
: code, but with a little overhead factored out of the loops to make the
: distinctions clearer.

	Hmm, you have a bug in your code here.

	The problem with removing that "little overhead" out of the
	loops, is that you invalidate the test as the string gets all it's
	spaces removed on the first run of EASIEST (the first type tested)
	and from then on has no spaces.  If you put a print ">$val<\n";
	statement before the regex of EASIEST and run with a count of 2
	you can see this.  So, with the exception of count 1 of EASIEST,
	you're actually testing on the string 'string'.

	Taking this into account, the numbers change back a lot.  See below
	for a with/without test.

: Not at all, because that's what I did use.  Here are the latest results,
: noise and all:
: Benchmark: timing 100000 iterations of EASIEST, FASTEST, TWO_PART,
	>snip<

	If you run this a few times in a row you'll notice the Zenin
	with and without paren numbers will flip back and forth
	depending on the exact amount of coffee left in your cup and
	evaporation is taken into account when factoring in this number.
	Thus I stand by my claims that the parens do not have any effect
	what so ever on run time speed.

: Of course, I agree with that 100%.  But it's instructive about TMTOWTDI and
: it's fun (I guess, except for our difficulties of communication!).

	Yep. :-)

	BTW, here are the adjusted numbers I promised:

$ perl foo.pl
Benchmark: timing 100000 iterations of EASIEST, EASIEST_REAL, FASTEST,
FASTEST_REAL, TWO_PART, TWO_PART_REAL, ZENIN_NO_PAREN, ZENIN_NO_PAREN_REAL,
ZENIN_PAREN, ZENIN_PAREN_REAL...
            EASIEST:  7 secs ( 6.73 usr  0.01 sys =  6.73 cpu)
       EASIEST_REAL:  9 secs ( 8.78 usr  0.00 sys =  8.78 cpu)
            FASTEST:  6 secs ( 5.69 usr  0.00 sys =  5.69 cpu)
       FASTEST_REAL:  9 secs ( 7.98 usr  0.00 sys =  7.98 cpu)
           TWO_PART:  2 secs ( 2.09 usr  0.00 sys =  2.09 cpu)
      TWO_PART_REAL:  4 secs ( 3.49 usr -0.01 sys =  3.48 cpu)
     ZENIN_NO_PAREN:  5 secs ( 3.22 usr  0.00 sys =  3.22 cpu)
ZENIN_NO_PAREN_REAL:  7 secs ( 5.17 usr  0.00 sys =  5.17 cpu)
        ZENIN_PAREN:  4 secs ( 3.34 usr  0.00 sys =  3.34 cpu)
   ZENIN_PAREN_REAL:  6 secs ( 5.35 usr  0.01 sys =  5.36 cpu)

	Hmm, with TWO_PART's numbers now blowing away FASTEST, I think we have
	to change names, at least on my system.  Hell, my version is now
	blowing away "FASTEST" on my machine! :-)

	I find it vary funny there is such a difference between your system
	and mine.  What are you running your tests on?  I'm running under 5.00404
	on FreeBSD 2.2.5-stable (p5/200).  Hmm, maybe it's a CISC/RISC or
	bigending/littleending thing. :-P

	And of course, da code again :-)

#!/usr/local/bin/perl -w
use diagnostics;
use strict;
use Benchmark;
use vars '$val';
$val = ' ' x 12 . 'string' . ' ' x 11;

timethese (100000, {
    EASIEST => q{
 $val =~ s/^\s*(.*?)\s*$/$1/;
    },
    TWO_PART => q{
 $val =~ s/^\s*//;
 $val =~ s/\s*$//;
    },
    ZENIN_NO_PAREN => q{
 $val =~ s/^\s*|\s*$//g;
    },
    ZENIN_PAREN => q{
 $val =~ s/(?:^\s*|\s*$)//g;
    },
    FASTEST => q{
 $val =~ s/^\s*(.*\S)\s*$/$1/;
    },
    EASIEST_REAL => q{
 $val = ' ' x 12 . 'string' . ' ' x 11;
 $val =~ s/^\s*(.*?)\s*$/$1/;
    },
    TWO_PART_REAL => q{
 $val = ' ' x 12 . 'string' . ' ' x 11;
 $val =~ s/^\s*//;
 $val =~ s/\s*$//;
    },
    ZENIN_NO_PAREN_REAL => q{
 $val = ' ' x 12 . 'string' . ' ' x 11;
 $val =~ s/^\s*|\s*$//g;
    },
    ZENIN_PAREN_REAL => q{
 $val = ' ' x 12 . 'string' . ' ' x 11;
 $val =~ s/(?:^\s*|\s*$)//g;
    },
    FASTEST_REAL => q{
 $val = ' ' x 12 . 'string' . ' ' x 11;
 $val =~ s/^\s*(.*\S)\s*$/$1/;
    },
} );

__END__

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: 18 Apr 1998 02:21:29 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: how to remove blanks?
Message-Id: <892866517.760802@thrush.omix.com>

Larry Rosler <lr@hpl.hp.com> wrote:
	>snip<
: >         $foo = "            string           ";
: Thank you for the string, which I used in the tests recorded below.
	>snip<
: $val = ' ' x 12 . 'string' . ' ' x 11;

	Oh, and btw this isn't my string.  Since I cut and pasted using
	my mouse between xterms, the tabs I had in my real string
	turned into spaces.  Sorry about that. :-P

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Fri, 17 Apr 1998 17:31:43 -0700
From: Indu Bingham <indu@healtheon.com>
Subject: Informix
Message-Id: <3537F46E.84883B01@healtheon.com>

I need to build a web interface with infromix backend using perl.
Rather I have a dbm files at the backend right now and I need to use
informix.
I have no clue on how to start it, is there a book/site or a sample page

someone can send me.

Thanks and I apprecaite you help

--
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Happiness is not getting what you want, but wanting what you have.

 Indu Bingham
 Healtheon Corporation
 indu@healtheon.com
*/




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

Date: Fri, 17 Apr 1998 17:56:43 -0700
From: "K. Watson" <cwts@earthlink.net>
Subject: IS THERE SUCH A THING AS MULTI TASKING?
Message-Id: <6h8trv$p9k@bolivia.earthlink.net>

I'd like to be able to display a "PLEASE WAIT" screen while an independent
(credit card authorization) process is going on.  In MVS assembler, I'd call
it multi-tasking.  Is there a PERL equivalent?

Thanks.




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

Date: Fri, 17 Apr 1998 23:59:09 GMT
From: John Taylor-Johnston <eslcafe@callisto.si.usherb.ca>
Subject: Macperl news group
Message-Id: <3303A2B7.3F82@callisto.si.usherb.ca>

Is there a macperl news group? I'm DESPERATE to find out why our Mac
server is giving me grief - and get my sys admin off my back! My scripts
hang - for hours and days - from the simplest to the most complicated!

Please reply by e-mail


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

Date: 18 Apr 1998 01:23:54 GMT
From: neutron@fc.hp.com (Jack Applin)
Subject: Neutering exit in eval
Message-Id: <6h8vba$57j@fcnews.fc.hp.com>

I have some user Perl code (read from a file) that I want to execute
many times, with $_ set to something different each time.
It's similar to this:

	$usercode = <USERCODE>;
	for $_ (@messages) {
		eval $usercode;		# Process each message
	}

I can use $SIG{__DIE__} to intercept the user code if it does a die.
What can I do if it does an exit?  Using END {} is not convenient,
because I want to just keep going in the loop.


				-Jack Applin
				 neutron@fc.hp.com
				 http://www.geocities.com/HotSprings/6789/


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

Date: 18 Apr 1998 02:28:05 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: new syntax for tied variables?
Message-Id: <892866913.643427@thrush.omix.com>

Andrew M. Langmead <aml@world.std.com> wrote:
: There was a thread earlier this week, talking about tie()ing a
: bless()ed hash. Unfortunately I can't find the article I want right
: now. But the basic concept may be of use to you.
	>snip<
: Now the hash reference returned by new is both a blessed reference and
: it is tied.

	Hmm, was this about my tied Tk menubutton module?  It does exactly
	this.  For anyone that might be interested, it can be found at:

	ftp://thrush.omix.com/pub/perl/modules/Tk-Tie-MenuHash-1.10.tar.gz

	You don't even need to (and the user shouldn't, actually) call
	untie(), as the object can untie itself on destruction.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: 17 Apr 1998 18:39:29 -0700
From: abby@ucan.foad.org (Abby Franquemont)
Subject: Re: perl tutorial (WAS Re: General Rudeness, e.g. Re: Need a web login script)
Message-Id: <6h908h$ddq$1@ucan.foad.org>

In article <6h6jnf$3b0$1@towncrier.cc.monash.edu.au>,
Chris Wright <caw@belloc.med.monash.edu.au> wrote:
>
>Abby Franquemont wrote in message <6h5lfl$r6d$1@ucan.foad.org>...
>>
>>ObURL: http://agora.leeds.ac.uk/Perl/start.html but then I'd imagine
>>everyone knows that.
>
>As a newcomer to Perl, I had a look at this tutorial. I found the following
>discussion of "local" variables...
>
>
>sub inside
>{ 
>     local($a, $b);                   # Make local variables
>     ($a, $b) = ($_[0], $_[1]);       # Assign values 
>     $a =~ s/ //g;                    # Strip spaces from
>     $b =~ s/ //g;                    #   local variables
>     ($a =~ /$b/ || $b =~ /$a/);      # Is $b inside $a     
>                                      #   or $a inside $b?
>}
>&inside("lemon", "dole money");       # true
>
>
>This could be VERY confusing...Isn't he confusing "local" and "my" one
>changing the scope of a variable and the other providing a variable of local
>scope?

Yeah, I guess that is on the confusing side of things. OTOH I don't know
that it's harder to sort out than, say, the example in the llama book for
local variables in subroutines (p. 103 of my copy).

>I wouldn't recommend this tutorial to a fellow newbie.

In particular I thought it did a good job of being complete about some
core things like file handling, and that the section on control structures
was well done... though it does occur to me that if you aren't already
more or less familiar with concepts like foreach, for, while, and until
from someplace else, it doesn't explain the ideas of how such things 
could be used, or why...  

This tutorial also  makes statements like: "Note that when Perl 
assigns a value with $a = $b it makes a copy of $b and then assigns that 
to $a. Therefore the next time you change $b it will not alter $a."
I doubt such a statement is completely comprehensible by someone with
no programming or scripting background. It's essential, though, for
someone who might have pre-existing expectations.

I learned stuff from it, to be sure... but then I admit I'm more looking
to fill out spotty knowledge, and not starting 100% from scratch. I 
liked this tutorial better than any I remembered from last time I was
working on acquiring perl clue.
-- 
Abby Franquemont        Nothing cures insomnia like the realization 
J. Random BOFH          that it's time to get up. --Fortune program


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

Date: Fri, 17 Apr 1998 21:47:24 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Proplem with perl script (I'm new to perl)
Message-Id: <alecler-1704982147240001@dialup-794.hip.cam.org>

Toby,

There's a simple mistake at line 15, where the incorrect use of the ==
operator brings on a compiler warning.

The line should read,

while ($correct eq "maybe") {

One other thing : "$i = $i + 1;" can be replaced by "$i++;" (line 19).

Congratulations for your excellent habit of turning compiler warnings on
when testing your scripts. You see, you found an error that you may not
have caught otherwise.

Just a note: my name isn't Toby and I don't know the secret word, so I
found myself trapped in an infinite loop when testing your program. That
ain't very nice. :-)

HTH (hail thee, hacker),
A.L.


===========================
In article <35378983.59A28DF0@he-net.demon.co.uk>, Toby Heywood
<toby@he-net.demon.co.uk> wrote:

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

When posting from Netscape, make sure your news preferences are set to
plain text, not MIME.

> I have just started to learn to write perl scripts, I am using the book
> Learning Perl.
> 
> I have gotten upto what I have called the 5 exercise, and have been
> trying to debug my script.
> 
> here is the script that I have rewritten from the book.
> 
> _____________________________________ START OF CODE
> 
> #!/usr/bin/perl
> @words = ("camal","llama","oyster");
> print "What is your name? ";
> $name = <STDIN>;
> chop($name);
> if ($name eq "Toby") {
>         print "Hello, Toby! Back here again? oh well, have fun!\n";
> } else {
>         print "Hello, $name!\n"; # Ordinary greeting
>         print "What is the secret word? ";
>         $guess = <STDIN>;
>         chop($guess);
>         $i = 0; # Try this first
>         $correct = "maybe"; # is the guess correct or not?
>         while ($correct == "maybe") { # is the guess correct or not?
>              if ($words[$i] eq $guess) { # right?
>                      $correct = "yes"; # Yes!
>              } elsif ($i < 2) { # more words to look at?
>                      $i = $i + 1; # look at the next word next time
>              } else { # no more words, must be bad
>                      print "Wrong, try again.  What is the secret word?
> ";
>                      $guess = <STDIN>;
>                      chop($guess);
>                      $i = 0; # start check from the beginning
>              }
>         } # end of while not correct
> } # end of "not toby"
> 
> ________________________________________________ END OF CODE
> 
> Anyway, I used the the -w flag for trying to debug the script, and all I
> keep getting is this message.  I'm now stuck, and would be grateful if
> you can help.
> 
> Argument "yes" isn't numeric in eq at perl_exercise_5 line 16, <STDIN>
> chunk2.
> Argument "maybe" isn't numeric in eq at perl_exercise_5 line 16, <STDIN>
> chunk2.


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

Date: Wed, 15 Apr 1998 20:36:16 -0700
From: "Travis Johnson" <travisj@earthlink.net>
Subject: Re: Send Message to Event Viewer
Message-Id: <6h8vqa$7e1@chile.earthlink.net>

You might also look in the NT Reskit for rptevent.exe which is written to do
this exact procedure. If you are unable to locate rptevent or need any
examples feel free to drop me a line.

-Trav

David Corcoran wrote in message <35376D82.4F2A@boeing.com>...
>Curdin Vital wrote:
>>
>> Hi,
>>
>> How it is possible with Perl to send a message
>> to WinNT EventViewer?
>>
>> Thank you for the help
>>       Curdin
>
>Assuming you really meant the Event Log:
>
>BTW this is included in the ActiveState distribution...
>
>Win32::Eventlog
>
>     Functions
>     Methods
>     Examples
>
>Functions
>
>Open((out)$EventObj, $SourceName, [$ServerName])
>(out) $EventObj;
>     Reference to an EventLog Object.
>$SourceName;
>     Name of the source of the event.
>$ServerName;
>     Optional: name of machine. If none, assumes local.
>
>Open the eventlog on the specified machine, if no server is specified,
>the local machine is used. An Eventlog object is returned in $EventObj.
>
>
>
>OpenBackup((out)$EventObj, $FileName, [$ServerName])
>(out)$EventObj
>     Reference to an Eventlog Object.
>$FileName
>     name of the file containing the backup eventlog.
>$ServerName
>     Optional: UNC name of the server containing the backup log.
>
>Open a backup eventlog and return an object to control it. If
>$ServerName is not given the local machine is used.
>
>
>
>Methods
>
>Backup($filename)
>     $filename
>file to write the eventlog to.
>Save the current open event log to a file
>
>Read($ReadFlags,$RecordOffset,(out)%EventInfo)
>(out) $ReadFlags
>     Specifies how to read log
>$RecordOffset
>     Number of first record
>(out)%EventInfo
>     Event information
>The Read method reads an entry from the eventlog. $ReadFlags can be any
>combination of:
>
>ReadFlag option              Description
>EVENTLOG_FORWARDS_READ       Eventlog is read in
>                             forward chronological
>                             order.
>
>EVENTLOG_BACKWARDS_READ      Eventlog is read in
>                             reverse chronological
>                             order.
>
>EVENTLOG_SEEK_READ           The read begins at the
>                             record specified by the
>                             $RecordOffset parameter.
>                             Must also specify
>
>EVENT_LOG_FORWARD_READ or
>EVENTLOG_BACKWARDS_READ.
>
>EVENTLOG_SEQUENTIAL_READ     The read continues
>                             sequentially from the
>                             last read call.
>
>See the Report method for information on the %EventInfo hash.
>
>Report($EventInfo)
>$EventInfo
>     A hash containing the event info.
>
>Reports an event. Implicitly calls RegisterEventSource.
>
>The options for $Event are:
>
>$Event Options                Description
>EVENTLOG_ERROR_TYPE           Error event
>EVENTLOG_WARNING_TYPE         Warning event
>EVENTLOG_INFORMATION_TYPE     Information event
>EVENTLOG_AUDIT_SUCCESS_TYPE   Success Audit event
>EVENTLOG_AUDIT_FAILURE_TYPE   Failure Audit event.
>
>
>$EventInfo contains the following:
>Key             Value
>Category        integer value for the category of the event (app
>defined)
>EventID         ID value of the Event. Source specific, any
>value.
>Data            The Raw binary data
>Strings         Any text strings to merge
>
>GetOldest((out)$oldest)
>     Returns the Absolute record number of the oldest record in the
>event log.
>
>GetNumber((out)$NumberOfEvents)
>     Returns the number of events.
>
>Clear([ $filename ])
>     If the $filename option is given, then the current eventlog is
>written to the file Clears the event log.
>
>Example 1
>
>        use Win32::Eventlog;
>        sub TEST1
>

>                my $number, $EventLog;
>                Win32::EventLog::Open($EventLog , "System", '') || die
>$!;
>                $EventLog->GetNumber($number) || die $!;
>                print "There are $number records in the System Event
>Log\n";
>        }
>
>        TEST1
>
>Example 2
>
>        use Win32::Eventlog;
>        sub TEST2
>        {
>                my $number, $EventLog;
>                # open the event log.
>                Win32::EventLog::Open($EventLog , "PerlApp", '') || die
>$!;
>                # define the event to log.
>                $Event =
>                {
>                        'EventType' => EVENTLOG_INFORMATION_TYPE,
>                        'Category' => 0,
>                        'EventID' => 0x1003,
>                        'Data' => '',
>                        'Strings' => "Test report",
>                };
>                # report the event and check the error
>                $EventLog->Report($Event) || die $!;
>        }
>        TEST2




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

Date: 17 Apr 1998 17:02:31 -0700
From: jbc@west.net (John Callender)
Subject: Re: Snobby news group
Message-Id: <6h8qin$3qr@acme.sb.west.net>

Greg Bacon (gbacon@cs.uah.edu) wrote:
: 
: If people want comp.lang.perl.newbie-only, they are perfectly free to
: suggest it through the proper channels.

Actually, this might be the one case in which such a group would actually 
work. I know the conventional wisdom about how newbies would flood any 
c.l.p.wizards group with FAQs, but I don't see that it necessarily 
follows that they wouldn't use a newbies group if it existed. Sure, there 
would still be the current crop of lazy bastards who would bug the gurus 
with their rude intrusions, but there might very well be a critical mass 
of polite, earnest newcomers who would use the newbie group to good effect.

A *lot* of people with no programming background are learning Perl for 
Web (and other) purposes. Like it or not, Larry has made the perfect 
"gateway drug" for programming addiction: making the easy things easy not 
only means you veterans can whip up awesome applications in no time, but 
also that Biff can figure out how to print "hello world!\n" without even 
buying an O'Reilly book (or learning what a man page is).

As one of those accidental programmers, I would really appreciate a forum 
where I could discuss questions along the lines of "how do I do X with 
Perl?" without having to worry if X is something Perl-specific, or is 
merely something that any beginning programmer has to learn about, 
regardless of the language he or she is learning with.

Yes, the FAQs and man pages are a great resource. Yes, any beginning 
programmers trying to cut their teeth on Perl should contribute to the 
Larry Wall/Randal Schwartz/Tom Christiansen Retirement Fund by buying the 
Llama and the Camel. But the reality is that all those resources are 
pitched over the heads of many beginners.

"Screw 'em if they can't understand it," is the attitude of some longtime 
participants here. Personally, I find that attitude kind of sad.

I have no illusions that a newbies group would fly even if someone could 
be found to champion it; the political climate of this group has become 
so anti-newbie that I'm sure it would never be voted in. Which is a 
shame, given the many neat things about Perl from the standpoint of a 
beginning programmer.

Whatever.

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Sat, 18 Apr 1998 02:36:49 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Snobby news group
Message-Id: <ebohlmanErL8LD.Gp@netcom.com>

John Callender <jbc@west.net> wrote:
: "Screw 'em if they can't understand it," is the attitude of some longtime 
: participants here. Personally, I find that attitude kind of sad.

Ironically, here on Netcom this thread immediately follows the thread
started by the post "Proplem[sic] with Perl Script" 
(<35378983.59A28DF0@he-net.demon.co.uk>) by Toby somethingorother.  Toby,
as you may recall, had a rather elementary problem involving confusion
between numeric and string equality.  His post had a rather poor title
(including a misspelling), and had a MIME attachment.  Yet quite a few
longtime participants (including Randal) bent over backwards to help him. 
Why?  Because the text of his post screamed out "I did my homework and I
don't understand this part of it," not "I'm too busy to crack the books! 
Just give me the answer now!" 

Someone once compared c.l.p.m to a university and pointed out that 
universities don't generally assume that students can learn a subject all 
on their own; that's why they have classes.  But notice that little 
learning takes place in a class when most of the time is taken up by 
students who haven't done their homework asking the professor to answer 
questions that are clearly answered in the textbook (*not* the same thing 
as students who have done their homework asking the professor to clarify 
points made in the textbook).



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

Date: Fri, 17 Apr 1998 19:20:22 -0500
From: Brian Katz <bdkatz@collins.rockwell.com>
Subject: Special characters
Message-Id: <3537F1C6.51887BF2@collins.rockwell.com>

Greetings everyone.  I have to convert some old files which were
written on a vax and have these line-feed characters which translate
on UNIX into ^M.  I would like to be able to s/^M/ / or s/\^M/ /  for
these annoying things, but it appears no go.  (Like \n, \t, etc., ^M is
acting like a single character...for instance vi treats it as a single
char.

       Help much appreciated for how to tell Perl this is a charater
I want removed!  Thanks.


Brian Katz



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

Date: Fri, 17 Apr 1998 20:47:05 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: Brian Katz <bdkatz@collins.rockwell.com>
Subject: Re: Special characters
Message-Id: <3537F809.81D@juicepigs.com>

Brian Katz wrote:
> 
> Greetings everyone.  I have to convert some old files which were
> written on a vax and have these line-feed characters which translate
> on UNIX into ^M.  I would like to be able to s/^M/ / or s/\^M/ /  for
> these annoying things, but it appears no go.  (Like \n, \t, etc., ^M is
> acting like a single character...for instance vi treats it as a single
> char.
> 
>        Help much appreciated for how to tell Perl this is a charater
> I want removed!  Thanks.

It's in the FAQs.

s/\cM/ /g;

HTH

-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


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

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

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