[19426] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1621 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 27 00:05:36 2001

Date: Sun, 26 Aug 2001 21:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <998885107-v10-i1621@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 26 Aug 2001     Volume: 10 Number: 1621

Today's topics:
    Re:  Re: Self-Searchable Perl documention - Extremely U 194.203.212.8 [demerphq@hotmail.com]
    Re: Avoiding symbolic references. <goldbb2@earthlink.net>
    Re: download.cgi, MS Ex & PDF <goldbb2@earthlink.net>
    Re: encrypting passwords <goldbb2@earthlink.net>
    Re: fwd: Sex or perl? <bs@bs-linux.com>
    Re: Need Perl module or regexp to slurp specific XML re (Yves Orton)
    Re: net::aim help <W_i_l_l@me.com>
    Re: one character at a time <goldbb2@earthlink.net>
        Perl 101 Question <ibroemer@home.com>
    Re: Perl 101 Question <davidhilseenews@yahoo.com>
    Re: perl comments <goldbb2@earthlink.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 27 Aug 2001 02:19:49 GMT
From: 194.203.212.8 [demerphq@hotmail.com]
Subject: Re:  Re: Self-Searchable Perl documention - Extremely Useful!
Message-Id: <97ii7.1342$3x.4948@news.bc.tac.net>

> demerphq@hotmail.com (Yves Orton) wrote in message news:<74f348f7.0108250743.2631f2e1@posting.google.com>...
> > dkcombs@panix.com (David Combs) wrote in message news:<9ll790$fvi$2@news.panix.com>...
> > > In article <74f348f7.0108120702.662a6771@posting.google.com>,
> > > Yves Orton <demerphq@hotmail.com> wrote:
> > > >...
> > > >Incidentally, I stayed up all night enhancing your activestate search
> > > >engine (found a couple of minor gliitches, but who cares).  Check your
> > > >mails for a copy of my mods.
> 
> Thanks very much Yves. You fixed a dumb bug due to a
> last minute "optimisation". I like the weighting too.
> 
> Your new version is posted at:
> 
> http://www.openpsp.org/source/util/pertoc2.pl
> 
> and is now the version pointed to by the openpsp site
> 
> john
> 
> http://www.openpsp.org

Cool.  Glad you like it. 

A minor point though..  When I posted it to you I was a bit concerned that I had left unfinished work so I gave it a run.  Small problem.  The backup/save mechanism (which at first I liked) needs to be a bit smarter. It used the .save file and wiped out everything that I had installed since (ppm updates the perltoc.html). (It needs to be rerun after every ppm as well.) Ive put this together, but i havent tested it that much, at least it doesnt crash right away :-)

At the very beginning (under your copyright):
# Changes by Yves Orton <demerphq@hotmail.com> 2001

use File::Copy;
use File::stat;
use strict;

(my $file = $^X) =~ s/bin\\Perl.exe/html\\perltoc/;

#for 1 arg opens...
our $SAVE = "$file.save";
our $ORIG = "$file.html";

my $st_backup = stat($SAVE);
my $st_orig   = stat($ORIG);

if ( !$st_orig || $st_orig->mtime>$st_backup->mtime) {
	warn "Backing up $ORIG to $SAVE";
	copy ($ORIG,$SAVE);
}
warn "Patching $ORIG";
my $html;
{
	local $/=undef;  #SLURP.....
	open ORIG or die "Couldnt read $ORIG:$!"; 
	$html=<ORIG>;
	close ORIG;
}

-------------------------------------------------------------
And then at the extreme bottom of the script
-------------------------------------------------------------
warn "\n$script\n";
$html =~ s!(</html>|$)!$script\n$1!;
$ORIG=">".$ORIG;
open ORIG or die "Couldnt write to $ORIG:$!";
print ORIG $html;
close ORIG;
$SAVE=">>".$SAVE;
open SAVE or die "Couldnt touch $SAVE:$!";
print SAVE " "; #touched for the very first time....
close SAVE;
__END__
Anyway, ttyl,
yves










==================================
Poster's IP address: 194.203.212.8
Posted via http://nodevice.com
Linux Programmer's Site


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

Date: Sun, 26 Aug 2001 22:31:09 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Avoiding symbolic references.
Message-Id: <3B89B0ED.EE3DA820@earthlink.net>

Ilya Martynov wrote:
> 
> BG> I have in a module a for loop which creates a number of
> BG> subroutines from  a closure.  Normally, one would do something
> BG> like:
> 
> BG> while( my ($name,$args) = each %whatever ) {
> BG>     no strict 'refs';
> BG>     *{"Package::$name"} = sub { .... };
> BG> }
> 
> BG> I'm trying to replace this with something like:
> BG> while( my ($name,$args) = each %whatever ) {
> BG>     $Package::{$name} = sub { .... };
> BG> }
> 
> BG> Which *should* do what I want, but doesn't seem to work.
> 
> Strange. It should work. At least on my home computer following
> script works under Perl 5.6.1:
> 
>     use strict;
>     use warnings;
> 
>     $main::{test} = sub { print "test\n" };
> 
>     test();
> 
> It does prints 'test' without any errors;

Testing within main works ok.  Testing in other modules seems not to.

Here's the code:
BEGIN {
	$EulersConstant::{$_} = \&{$Math::BigInt::{$_}}
		for( qw(badd bmul bpow) );
	$EulersConstant::{$_} = \&{$Math::BigFloat::{$_}}
		for( qw(fadd fmul fdiv fround) );
}

If I precede the BEGIN block with
use subs qw(badd bmul bpow fadd fmul fdiv fround);
, it works ok, but otherwise it doesn't... and I don't *want* to have to
do use subs...  It *should* work just as it is.

The reason I'm doing this of course is because I've got _old_ versions
of BigInt and BigFloat, and I don't want to use their OO interfaces, and
I don't want to use the fully qualified versions of those sub's names
everywhere I use them.

I suppose it doesn't matter much, anyway.  Having seen the amount of
time it takes to calculate successive significant bits of euler's
number, I've given up on calculating it to the log2(256!) significant
bits I need to do what I want.  It's far easier and faster to download
it off of a website.

-- 
I'm not a programmer but I play one on TV...


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

Date: Sun, 26 Aug 2001 23:09:24 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: download.cgi, MS Ex & PDF
Message-Id: <3B89B9E4.2B7B6927@earthlink.net>

steve edmonds wrote:

> I am trying to use a download perl script to force pdf's to the
> browser to as to control distribution on apache servers.

Do you mean that you want clicking on the link [or submit] to result in
the file being saved instead of viewed?  Or do you not care, as long as
they get it?

> print "Location: $fileid\n\n";

This should work fine.  What kind of errors do you get?
[snip]
>    print("Content-Length: $size\n");

You should avoid printing out the size until the file is opened, and
then get the size from (-s filehandle), so you can be sure it's correct.

>    print("Content-Description: Larry\'s File Downloader\n\n\n");

You don't need to backslash the single quote within double quotes.
Also, you should end the headers with *two*, not three, newlines.
The first two here signals the end of headers, and the third one ends up
as the first character of the contents.

So:
   print("Content-Description: Larry's File Downloader\n\n");
[snip]
>    select STDOUT;
>    $| = 1;

STDOUT is selected by default.  You don't need to select it yourself.
I know $| controls whether autoflush is on for the currently selected
filehandle, but I'm not sure if setting it causes data which has already
been buffered to be flushed... does anyone know?

Also important, I would suggest that you turn binmode on for STDOUT --
otherwise, on some systems, your data can get mangled when sending to a
browser.

[snip]
>    while ($len = sysread fin, $buf, $blksize) {
>       if (!defined $len) {
>          next if $! =~ /^Interrupted/;
>          die "$0: System read error: $!\n";
>       }

If sysread returns undef, it will break out of the loop.

How do you expect the contents of the if statement to ever be called?

Change your loop to:
   do {
      my $len = sysread ....
      if( !defined $len ) {
         next if $!{EINTR};
         ....
      }
      last if !$len;
      ....
   } while( 1 );

Oh, to get the %! hash available, 'use Errno' somewhere in your program.
Checking if $!{EINTR} is true, or if $! == EINTR (which is a constant
that Errno.pm will export on request), is more portable than checking
the string value of $!.

>       while ($len) {
>          $written = syswrite STDOUT, $buf, $len, $offset;
>          if (!defined ($written)) {
>             die "$0: System write error: $!\n";
>          }
>          $len -= $written;
>          $offset += $written;
>       }

Is there any particular reason not to simply do:

   print $buff
      or die "$0: System write error: $!\n";



-- 
I'm not a programmer but I play one on TV...


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

Date: Sun, 26 Aug 2001 22:05:06 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: encrypting passwords
Message-Id: <3B89AAD2.C09750DE@earthlink.net>

Abigail wrote:
> 
> AJ (jerseycat10@yahoo.com) wrote on MMCMVI September MCMXCIII in
> <URL:news:7eddc058.0108151328.29ac8787@posting.google.com>:
> || Hello, right now, I have a perl logon/logoff system on my site.
> || However, all the data files I use (.passwd, .email, etc), are set
> || with lax security permissions to satisfy perl.  I am wondering if
> || there are any encryption techniques widely available to combat this
> || problem.
> 
> No. And that has nothing to do with Perl but with encryption in
> general. If your decryption algorithm is known (and it is in your
> case, it's your Perl source), the one and only thing that keeps your
> data secret is the key. And from your question, I sense that having a
> person supply the key in one way or the other (type it in,
> certificate, smart card) isn't an option. Which would mean your Perl
> program needs to be able to read the key from some resource, like a
> file. And that file cannot be encrypted. But then, there's no
> additional security in encrypting the data files if the key still can
> be gotten as easily.

Since there's no *encryption* solution, you might consider a solution
which depends on your OS and filesystem permissions.

Use suidperl and write your data files with permissions such that only
use [not user nobody] can read.  Obviously this isn't a portable
solution, as only *nix even has suid, and it can be unsafe [if your
program had a security hole, it just got lots bigger], but it can
[probably] be made to work.

-- 
I'm not a programmer but I play one on TV...


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

Date: Sun, 26 Aug 2001 20:17:27 -0700
From: "Brian A. Stumm" <bs@bs-linux.com>
Subject: Re: fwd: Sex or perl?
Message-Id: <Pine.LNX.4.21.0108262009150.3683-100000@bdslppp62.spkn.uswest.net>

On Mon, 27 Aug 2001, Trull wrote:

> 
> ----- Original Message -----
> From: "None" <pohanl@aol.com>
> Newsgroups: comp.lang.perl.misc
> Sent: Sunday, August 26, 2001 4:48 AM
> Subject: Sex or Perl? Which is better?
> 
> 
> > In the beginning there was sex.  Then came Perl.
> > Which is better?  Before getting into this very
> > important question, history must be explained.
> >
> > In the United States, the most unique ideal held is
> > the concept of profit and capitalism.  This type of
> > system advocated the cheaper and better to replace
> > current products.  However, when profit is primary,
> > and cheaper and better is secondary.  In order for
> > a company to make the most profit in capitalism,
> > the course taken is usually to make a product that is
> > cheaper and better to outsell current products.  When
> > that happens, it owns more and more market until it
> > becomes a monopoly.  After it is a monopoly, then
> > it can dictate the price (inflate it) so that it makes
> > more profit.  In the mean time, it will try to destroy
> > companies that might release products cheaper or better.
> > In the process of becoming a monopoly, it can do many things
> > to reach that goal.  It can release a product way underpriced
> > (sold at a loss) so that it destroys competitors who do not have
> > enough capital to stay in the long term to compete and will die out
> > due to
> > lack of money.  It can hire away all the talented people in a
> > competitor (so they do not have smarts to compete).  It can
> > buy them out (so they do not exist anymore).  It can use group
> > pressure to force it out of the marketplace (force companies the
> > competitor depends on to dump them, and then support companies the
> > company is in competition with).
> >
> > However, the main goal of a company is to own the market and stay
> > there.  This is why many companies dump their products in the
> > marketplace.
> > The primary goal is to become a monopoly.  Afterwards, they can set
> > the price to any value they want.  But in order to dump, the company
> > must have enough capital to survive.
> >
> > This is how the system in the United States work.  People either try
> > to come up with a cheaper and better product so that it starts eating
> > up marketshare, with the eventual goal of becoming a monopoly.
> >
> > There are some inherent weaknesses in this system however.  Because
> > humans live in it.  A human becomes better and better until they reach
> > mid-age.  Then they become worse and worse as they age.  Mental and
> > physical abilities become less and less.  Also, humans are the
> > monopoly
> > in the living.  They basically command the world, and they are
> > multiplying
> > more and more.  The system the humans created to survive is becoming
> > more
> > and more dependent on capitalism.  But capitalism does not take care
> > of
> > humans in the long run.  When a human is aging, capitalism dictates
> > that
> > they get replaced by cheaper and better (younger and smarter).  And
> > there
> > are more and more humans being born everyday.  Soon there will be more
> > and
> > more people who cannot survive in this system.  (the aging, the very
> > young,
> > the handicapped, the unemployed etc).  This is why medicare,
> > unemployment benefits, homeless shelters, social security, etc were
> > created in the first place. To support the other half of the
> > population who cannot survive in
> > capitalist society.
> >
> > Because of the strive for products that are cheaper and better, there
> > comes
> > a time when sometimes a product becomes free and better.  In this case
> > something strange happens.  The people who used to depend on the
> > previous
> > incarnation of the product that was not free become displaced.  They
> > no longer
> > serve a purpose, and thus cannot survive in a capitalist society.
> > This is what is happening with open source software and linux and
> > perl, etc.
> > They basically created a market that was free (the cheapest).  But it
> > is not better yet.  If it was, then Microsoft would be in trouble.
> > Microsoft went after the monopoly route.  They are trying to model
> > themselves
> > like Procter and Gamble.  Basically becoming a monopoly in all the
> > products
> > they sell.  (which makes for the hiring of important people from
> > Procter
> > and Gamble a few years back).  As Microsoft was busy going after this
> > route,
> > Linux and Perl, and Java, and open source created went after the
> > Cheapest
> > route.  Soon there was a clash.  The cheapest versus the monopoly.  To
> > survive Microsoft must be better, else capitalism dictates cheapest
> > and better
> > will displace them.  In the mean time, something is happening... the
> > humans
> > are becoming displaced.  Because software is becoming free, there are
> > less
> > and less people who can survive as programmers.  They can't sell
> > products
> > when it is free.  This goes against the capitalist model of profit.
> > More in line with socialist and communist route.  But the socialist
> > and
> > communist route requires a supporting system to take care of business
> > so that the service can be provided free (like free housing and
> > guaranteed
> > work, the system is the government).  But there is no supporting
> > system
> > in free software.  The only indirect supporting system are big
> > companies
> > who use it, but as the market becomes more flooded with free stuff,
> > they
> > can only support and shrinking subset of software people.  The
> > programmers
> > and software engineers are becoming like the aged and handicapped in
> > capitalist society.  As more people start using free software, there
> > becomes less people who can survive to make more free software.  They
> > must take up jobs not directly in this market to support themselves,
> > so
> > they can create more free software.  This is a dilema that is facing
> > open source and free software movements...  They care destroying their
> > ability to survive because less and less can make profit and live in
> > capitalist society as software people.  As Microsoft gobbles up the
> > rest of the market and becomes a monopoly, the free software movement
> > is gobbling up the profits that could have been, but now is not
> > (because
> > it is free).  Software like webservers, browsers, languages,
> > compilers,
> > operating systems are free.  Otherwise, Microsoft owns them.  This
> > is directly beneficial to Microsoft because there are no competitors
> > who
> > can survive now (no company can survive selling free stuff, and not
> > many
> > have deep pockets to compete against Microsoft).  This is a serious
> > dilema.
> > Before, the software people could survive because there was an
> > indirect
> > system who supported them (the venture capitals who invested in them
> > who
> > did not require profit from their work).  But now that the bubble
> > burst,
> > there is now a big displacement of people who cannot survive because
> > the
> > only two routes are competing against a monopoly, or creating free
> > software
> > that does not allow them to survive because they cannot make a profit.
> >
> > Now this comes to the question, how is capitalism dealing with others
> > who
> > were affected previously by the same situation?  Well, social security
> > was created to support old people.  Disability was created to support
> > people who are disabled.  Homeless shelters and others were created
> > to help them out.  Unemployment benefits were created to temporary
> > take
> > care of the unemployed.  But isn't this socialism and communism?  Yes.
> > Capitalism cannot survive without a supporting safety net because not
> > all
> > the people can survive in this system of profit and cheaper and
> > better.
> > A human can not be treated like a product.  When they grow old, you
> > don't
> > replace them or kill them.  They are still around living and surviving
> > in
> > society.  Handicapped people cannot be scrapped or killed either. Etc
> > Etc.
> >
> > Free software is also anti-capitalism.  They totally go against
> > profit.
> > They are free.  Free software is like socialism and communism.  But
> > for
> > them to survive, some system must be put in place to take care of
> > people
> > who create them.  And currently there are less and less companies that
> > can support them.  Larry Wall ended up working for the book publisher
> > that publishes the book on Perl (a book company).  Linus Travold ended
> > up in a company that created chips (a hardware company).  Note that
> > each is in a company that does not directly make a profit on the
> > product
> > that they created (only indirectly).  Because Perl is free, Larry Wall
> > can't sell perl.  So he must find an indirect way to survive.  Just
> > like
> > Linus cannot sell Linux, so he must find an indirect way to survive in
> > the market too (the hardware company that sell computers using his
> > creation).  People who create free software cannot live off of their
> > work.
> > Only indirectly.
> >
> > Now this comes to the point of politics.  How is Sun surviving by
> > creating
> > Java?  Sun survives selling hardware.  Sun is trying
> > to be the monopoly in hardware, while Microsoft is trying to be the
> > monopoly
> > on software.  If Sun can create enough free software, then they can
> > still survive by selling hardware.  (hardware can never be free
> > because
> > they take up resources like metal, chips, etc).  So while Sun buys up
> > StarOffice and gives it out free.  Creates Java and gives it out free.
> > Sun is basically using the dumping technique (sell products below the
> > cost,
> > in this case free) to destroy Microsoft.  The Free Software Foundation
> > and Linux are helping along.  But in the mean time, this is creating
> > a unique socialist and communistic situation in for the software
> > people.
> > Especially when the dot.com's of the world are now dying out and
> > leaving
> > a lot of software people dangling.
> >
> > Which gets us into more politics.  Now that the market is divided up
> > between free (hardware profit) software and not free (software profit)
> > software.  And this is wreaking havoc on a lot of people.
> > Then the government steps in.  Declares Microsoft a monopoly and
> > looking
> > for ways to change the situation.  Then a lot of confusion happened
> > and
> > is now still being sorted out.  Bill Clinton and the democrats were
> > the
> > ones that were in power when action was taken.  The Department of
> > Justice
> > that brought the suit was basically chosen by them.  Also, the
> > democrats
> > are the ones that more likely supported the minorities (the blacks,
> > asians, etc).  Then you heard that Bill Gates starts a 1 Billion
> > foundation
> > to support blacks in the middle of the DOJ monopoly suit.  This was
> > done
> > to appease the lawsuits coming up by blacks that Microsoft was not
> > hiring blacks.  Recently you also heard on the news that Bill Clinton
> > very much supported blacks.  But why is race involved with this whole
> > thing?
> > Because George Bush and the republicans came to power because of the
> > NRA
> > and the bombing of the FBI.  And how the FBI is now being investigated
> > for the missing procedure steps involved in the killing in the
> > Davidian
> > Branch incident.  So now you have a republican party led by Bush that
> > is supporting whites, versus the democratic party that supports
> > minorities
> > and Jews.  (Al Gore had a Jewish vice presidential running mate).
> > Jews
> > are also more likely to support minorities (asians, blacks etc).
> > Because
> > of the holocaust, they don't like people who may be "genocided" so
> > they
> > seem to support minorities.  Which gets us to the unique situation...
> > Because Jews are anti-nazi, and is supported by democrats.  And NRA
> > and Bush and republicans are representative of whites and sometimes
> > Nazi,
> > this is also wreaking havoc on global politics.  Because during Nazi
> > era,
> > Japan, Germany, and Italy were allies.  Japan killed a lot of asians
> > that were not-Japanese (like Chinese, etc).  This is why the Japanese
> > prime minister visited the Japanese war shrine lately.  As the United
> > States is being led by pro-white and pro-NRA anti-Jewish and
> > anti-minority
> > they are getting Nazi era politics back (Japan becoming more military
> > and against other asian nations).  Note the unique timing of Bush's
> > trip
> > to Europe recently after the execution of person who bombed the FBI
> > building.
> > Europe is against killing of any human regardless of crime and often
> > lead
> > protest against them.  So Bush and the republicans can be saying that
> > they
> > supported their cause... that he didn't want the bomber to be
> > executed.  Bush,
> > being from Texas, a usually pro-white state, seems to be leading the
> > republicans
> > to represent whites and against minorities.  So now that the lines
> > have
> > been drawn, between Bush, republicans, white, nazi, wartime Japan,
> > against Bill Clinton, democrates, Jews, Chinese and blacks... how is
> > that
> > affecting the world today?  A lot.  It is causing a lot of unique
> > situations
> > to happen.  In the world of politics, sometimes the technique is to
> > get
> > enemies to fight each other, and get your hands clean.  This is most
> > likely
> > why Bush recently sent a high level black representative to China to
> > give
> > bad news instead of going himself.  This is why Connie Chung (she was
> > banned during democratic era because she somehow ended up representing
> > whites,
> > being sometimes protrayed as being a sell-out to asians by marrying
> > white)
> > is now back.  But how does this whole thing relate to the topic at
> > hand?
> > Well, Microsoft, because of their wrangling conflict with Japan (they
> > sold a competing XBox that got Sony and other Japanese software makers
> > aligned
> > against it), and also because of Gates donating 1 billion to blacks
> > and
> > the recent alliance with chinese companies (the major component of the
> > Xbox
> > is a very powerful graphics chip that is run by a company run by a
> > Chinese).
> > This is why Computer Associates International is now having its
> > Chairman (Wang a
> > Chinese) being attacked by a Wryly (a white from Texas) who wants him
> > removed from the company.  It seems the political climate introduced
> > by Bush and
> > the republicans are anti-Microsoft anti-Chinese anti-Jews, and
> > pro-white,
> > pro-NRA, pro-wartime japan.  White democrats now seem to represent
> > pro-Microsoft
> > pro-Chinese, pro-Jews and pro-minorities.
> >
> > Which gets us to the question, why?  Well, because of genes.  It is
> > natural
> > for an organism to want to be with a like-kind.  When a pack of
> > animals
> > are together, they are usually the same type and make-up.  Introducing
> > a different type causes stress and lessens harmony.  There seem to be
> > genes that are built in that supports like-kindedness.  It may have
> > been
> > left in to promote survival in the past.  When whites saw more and
> > more
> > minorities they panic'ed.  The same in Japan and China and other
> > countries.
> > When you introduce other races in a usually dominant-race society,
> > stress
> > results especially if the numbers are increased.  The natural grouping
> > get
> > interrupted.  So what you are seeing in the political arena is a
> > backlash
> > against minorities by whites.  But is it all just about this gene?
> > Well,
> > no.  It is also about survival. Because humans need to survive and
> > they
> > want to survive in a harmonious environment and one that they will fit
> > in...
> >
> > Capitalism and its stress on profit is a system that has unique
> > properties.
> > When you hold more cash and capital, you gain more power and survival
> > ability.
> > This is why sometimes the Republicans represent the rich and the
> > Democrats
> > represent the poor.  When the democrats are in power, a lot of
> > spending by
> > the government is done so that a majority of the poor get jobs.  They
> > get
> > more power.  Sometimes this increase and injection of money lessens
> > the
> > amount of power that the rich have.  This increase also help out
> > minorities.
> > So this is why when Bush and the Republicans came to power, usually
> > there are
> > a lot of layoffs.  This puts power back to the rich.  As people are
> > dependent
> > on money to survive, when you cut the amount of funding to the people,
> > you
> > lessen the amount of money they have.  Which results in more power to
> > the
> > rich and less to the poor.  Which is why democrats are usually the
> > ones
> > who initiate safty-nets like Social Security and Medicare, etc.  But
> > this
> > brings up the question... what about the Tax cuts.  Well, the tax cuts
> > are usually geared towards the rich.  The rich WANT tax cuts.
> > Also, spending is usually reduced, so there is less money floating out
> > there.
> > This consolidation of money and power back to the rich is simply a
> > response
> > to the increase in the amount of power given to the poor.  This is why
> > the United States was so against Communism and Socialism.  This
> > changed
> > the power structure.  Instead of money as a power structure, and the
> > allocation
> > of money for power, communism and socialism put dependence of
> > surviability
> > on the government, not on money and this took power away from the
> > rich.
> > But a pure capitalistic society can't function because of the problem
> > that
> > people are not products.  They age and can't simply get replaced or
> > scrapped.  Social security, disability, medicare and other's purpose
> > was put in place because of this.  But as the internet and the
> > computer industry is feeling the impact of the free software and the
> > war with politics and money is happening
> > around the world, and a lot of people start waking up to what is
> > happening,
> > the software industry is going along, stuck in the middle of it all.
> >
> > Which comes to the last question... what does this whole post have to
> > do
> > with sex?  Well, which is better?  Sex or Perl?
> 
> 
> 
I found this to be a very interesting read, however the author has one
major flaw in this essay. The author mistakenly associated "free
software" with "no charge" software. The ideals of the Free Software
Foundation, Open Source and the GPL do not dictate providing software at
no charge. Rather it pertains to the free exchange of source code.

Linus Torvalds *did* profit from the operating system he created.

The Open Source Software movement provides a venue for little known
programmers (newcomers) to make a name for themselves in the
industry. Thus many of these newcomers release their code for "No
Charge". Even though they do not profit directly it may lead to a good
job, or investors/backers who want to form a company based on the talents
or ideas of the programmer.

But to answer the question, Sex is better. Eventually Perl will be
outdated and obsolete. Sex ensures that their will be future programmers
creating newer, better software...

 -- 
                                                       a8888b.
Brian A. Stumm                                        d888888b.
bs@bs-linux.com                                       8P"YP"Y88
http://www.bs-linux.com                               8|o||o|88
The Choice of a Gnu Generation                        8'    .88
                                                      8`._.' Y8.
              #                                      d/      `8b.
####         ###                                   .dP   .     Y8b.
 ##           #                                   d8:'   "   `::88b.
 ##       ###   ### ###   ###   ###  ###   ###   d8"           `Y88b
 ##      #  ##   ###   ##  ##    ##   ##   ##   :8P     '       :888
 ##     #   ##   ##    ##  ##    ##     ###      8a.    :      _a88P
 ##        ###   ##    ##  ##    ##     ###    ._/"Yaa_ :    .| 88P|
 ##     # ###    ##    ##  ##    ##    ## ##   \    YP"      `| 8P  `.
 ##    ## ### #  ##    ##  ###  ###   ##   ##  /     \._____.d|    .'
#########  ###  ####  ####   ### ### ###   ### `--..__)888888P`._.'




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

Date: 26 Aug 2001 19:26:52 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Need Perl module or regexp to slurp specific XML records
Message-Id: <74f348f7.0108261826.d239314@posting.google.com>

Dan Sheppard <dans@chiark.greenend.org.uk> wrote in message news:<H5i*RYK4o@news.chiark.greenend.org.uk>...
> M.L. <mel2000@hotmaildot.com> wrote:
> >Given the following fixed XML records format:
> This is /so/ XSLT. You can use XSLT to reduce the database to the
> records you want and then do a slurp in with a simple perl program.

Ohhh.  Pain.  :-) I think id probably stick with the regex than try
learning xslt on the fly....

> Is there some XSLT jiggery-pokery available for perl? (don't ask me,
> I'm a C man whien it comes to XML

Well, you could invoke sabalot from Perl....

Does that count?

Yves


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

Date: Mon, 27 Aug 2001 03:40:29 GMT
From: W i l l <W_i_l_l@me.com>
Subject: Re: net::aim help
Message-Id: <89gjot4vcdsci2r58nffan7j1ra1tk0t4i@4ax.com>

The module did come with documentation and a demo of what can be done
with it, however I couldn't do much with it either.

On Sat, 25 Aug 2001 01:06:57 GMT, Ryan <hockeyvb8@hotmail.com> wrote:

>... i just installed the net::aim module but i have never coded in
>perl before. Does any one have pre-made bot scripts to help me out?
>thanks for the help!
>
>hockeyvb8@hotmail.com



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

Date: Sun, 26 Aug 2001 23:47:37 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: one character at a time
Message-Id: <3B89C2D9.9D65A526@earthlink.net>

Yves Orton wrote:
> 
[snip]
> #!perl
> use strict;
> use warnings;
> use Benchmark 'cmpthese';
> 
> for (qw(One Two Three)) {
>     print "\nRun $_:\n";
>     Time(100_000);
> }

Not that it matters much, but I prefer to ask Benchmark to repeat each one for some number of seconds rather than some number of times...

That is, Time(-10); instead of Time(100_000);

> 
> sub Time {
>   my $count=shift;
>   cmpthese ($count,
>   {
>    'substr' =>sub  {
>                     my $string = "my little 0 string";
>                     my @output;
>                     push @output,substr ($string, 0, 1, "")
>                          while length($string);
>                    },

You should have two substr versions, the second being:
	push @output, substr( $string, $i, 1 )
		for( 0 .. length( $string )-1 );

>    'regexp' =>sub{
>                     my $string = "my little 0 string";
>                     my @output;
>                     push @output,$1
>                          while ($string=~/(.)/gs );
>                 },

You should have two versions of regexp, the second one being:
	@output = $string =~ /(.)/gs

Also, if . in the regex were replaced with [\x00-\xFF] it might go a bit faster, though I'm not sure.

>    'unpack' =>sub{
>                     my $string = "my little 0 string";
>                     my @output;
>                     push @output,$_
>                          foreach (unpack ("C*", $string));
>                 },

You should have a second unpack version, with
	@output = unpack("C*", $string);

Also, you didn't do the split solution:
	@output = split //, $string;

>   } );
>  }
> __END__
> 
> Run One:
> Benchmark: timing 100000 iterations of regexp, substr, unpack...
>     regexp:  8 wallclock secs ( 7.65 usr +  0.00 sys =  7.65 CPU) @
> 13070.19/s (n=100000)
>     substr:  4 wallclock secs ( 4.25 usr +  0.00 sys =  4.25 CPU) @
> 23546.03/s (n=100000)
>     unpack:  4 wallclock secs ( 3.22 usr +  0.00 sys =  3.22 CPU) @
> 31007.75/s (n=100000)
>           Rate regexp substr unpack
> regexp 13070/s     --   -44%   -58%
> substr 23546/s    80%     --   -24%
> unpack 31008/s   137%    32%     --
> 
> Run Two:
> Benchmark: timing 100000 iterations of regexp, substr, unpack...
>     regexp:  8 wallclock secs ( 7.54 usr +  0.00 sys =  7.54 CPU) @
> 13260.84/s (n=100000)
>     substr:  4 wallclock secs ( 4.22 usr +  0.00 sys =  4.22 CPU) @
> 23713.54/s (n=100000)
>     unpack:  2 wallclock secs ( 3.23 usr +  0.00 sys =  3.23 CPU) @
> 31007.75/s (n=100000)
>           Rate regexp substr unpack
> regexp 13261/s     --   -44%   -57%
> substr 23714/s    79%     --   -24%
> unpack 31008/s   134%    31%     --
> 
> Run Three:
> Benchmark: timing 100000 iterations of regexp, substr, unpack...
>     regexp:  8 wallclock secs ( 7.60 usr +  0.00 sys =  7.60 CPU) @ 13156.16/s (n=100000)
>     substr:  5 wallclock secs ( 4.23 usr +  0.00 sys =  4.23 CPU) @ 23612.75/s (n=100000)
>     unpack:  3 wallclock secs ( 3.21 usr +  0.00 sys =  3.21 CPU) @ 31104.20/s (n=100000)
>           Rate regexp substr unpack
> regexp 13156/s     --   -44%   -58%
> substr 23613/s    79%     --   -24%
> unpack 31104/s   136%    32%     --

-- 
I'm not a programmer but I play one on TV...


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

Date: Mon, 27 Aug 2001 02:51:52 GMT
From: Jimmy <ibroemer@home.com>
Subject: Perl 101 Question
Message-Id: <3B89B609.F3820B82@home.com>

Hi all... It's been a few years since I've written, Perl.  And if ever
the expression "Use it or loose it" applies, it's in programming!

I'm trying to solve what should be a pretty simple problem.  If you can
help, please read on.

I have a couple of hundred text files that are not formatted very well.
Here's an example:

~~~ Begin file


                                 MARY HAD A LITTLE LAMB

                                 Mary had a little lamb,
                                 her fleece was white as snow.
                                 And everywhere that Mary went,
                                 The Lamb was sure to go.

                                 The End.



~~~End file

I would like to run a script that will parse these files, and create the
following type of format in a new directory:

~~~ Begin file
 MARY HAD A LITTLE LAMB

Mary had a little lamb,
her fleece was white as snow.
And everywhere that Mary went,
The Lamb was sure to go.

The End.
~~~End file

So basically, removing unnessecary white spaces and blank lines that
precede and follow the text.  One more thing, the blank lines could very
well have spaces in them, too.

If anybody could show me a simple, easy script that I could run to
produce this desired output, I would be most greatful.

Thanks very much.

Jimmy



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

Date: Mon, 27 Aug 2001 04:01:41 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: Perl 101 Question
Message-Id: <FCji7.21950$hT4.6553630@news1.rdc1.md.home.com>

"Jimmy" <ibroemer@home.com> wrote in message
news:3B89B609.F3820B82@home.com...
> Hi all... It's been a few years since I've written, Perl.  And if ever
> the expression "Use it or loose it" applies, it's in programming!
>
> I'm trying to solve what should be a pretty simple problem.  If you can
> help, please read on.
>
> I have a couple of hundred text files that are not formatted very well.
> Here's an example:
>
> ~~~ Begin file
>
>
>                                  MARY HAD A LITTLE LAMB
>
>                                  Mary had a little lamb,
>                                  her fleece was white as snow.
>                                  And everywhere that Mary went,
>                                  The Lamb was sure to go.
>
>                                  The End.
>
>
>
> ~~~End file
>
> I would like to run a script that will parse these files, and create the
> following type of format in a new directory:
>
> ~~~ Begin file
>  MARY HAD A LITTLE LAMB
>
> Mary had a little lamb,
> her fleece was white as snow.
> And everywhere that Mary went,
> The Lamb was sure to go.
>
> The End.
> ~~~End file
>
> So basically, removing unnessecary white spaces and blank lines that
> precede and follow the text.  One more thing, the blank lines could very
> well have spaces in them, too.
>
> If anybody could show me a simple, easy script that I could run to
> produce this desired output, I would be most greatful.
>
> Thanks very much.
>
> Jimmy
>

Well, the basic idea, as I picture it, is this:

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

my $text;
{ local ($/) = undef;   $text = <DATA>; }

$text =~ s/^\s+//;

$text =~ s/\s+$//;

$text =~ s/^\s+?(?=($|\S))//mg;

print $text;

__DATA__


                                 MARY HAD A LITTLE LAMB

                                 Mary had a little lamb,
                                 her fleece was white as snow.
                                 And everywhere that Mary went,
                                 The Lamb was sure to go.

                                 The End.


The rest should just be a matter of reading the files.

--
David Hilsee




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

Date: Sun, 26 Aug 2001 23:38:46 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: perl comments
Message-Id: <3B89C0C6.EB4623F2@earthlink.net>

Malcolm Dew-Jones wrote:
> 
> David Combs (dkcombs@panix.com) wrote:
> : In article <3b796b7f@news.victoria.tc.ca>,
> : Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:
> : >
> : >
> : >One useful area is after an __END__ .  Everything after this line
> : >is ignored.
> : >
> : >I often put programming notes there, such as examples of things to
> : >be parsed, or requirement notes I can read while programming, or
> : >bits of half finished code I think I might want to use, or
> : >examples, etc. etc. etc. like a scratch pad area.
> : >
> 
> : OK.  Now, suppose for test purposes you're also
> : using __DATA__.
> 
> I don't claim this is always useful, but especially during initial
> development I have found it to be useful often enough to count as a
> useful trick to remember.
> 
> No one says you need to use it if you don't like it.
> 
> It's also easy to kludge in both an __END__ and a data, just add a
> snippet something like (from memory, this e.g. not tested, in my
> experience the DATA handle points to the __END__, but the tag names
> can be changed to what ever works)
> 
>         #!perl
> 
>         { 1 while ( <DATA> !~ m/^__DATA__$/ ) ; } # skip some of DATA
> 
>         -perl-program-goes-here-
> 
>         __END__
>         programing notes go here, examples of data to be parsed etc,
>         old code saved as examples and for cut and paste when editing
> 
>         __DATA__
>         real data
> 
> (kludgey but useful for the ad-hoc style tools that are never really
> finished)


This is just my opinion, but it makes more sense to me to put the
__DATA__ token *before* the __END__ token than vice versa.

This way, the DATA handle will initially point to __DATA__, and then you
want to read from DATA until you reach the __END__.  Logical, ne?

-- 
I'm not a programmer but I play one on TV...


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.announce, send your article to
clpa@perl.com.

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

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 1621
***************************************


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