[8291] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1908 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 16 18:11:04 1998

Date: Mon, 16 Feb 98 15:00:27 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 16 Feb 1998     Volume: 8 Number: 1908

Today's topics:
    Re: A Pubilc Apology. <*@qz.to>
    Re: A Pubilc Apology. (Michael Schuerig)
    Re: A Pubilc Apology. (Leslie Mikesell)
        Can't use string ("") as a subroutine ref while "strict <webmaster@fccj.cc.fl.us>
        Can't use string ("") as a subroutine ref while "strict <webmaster@fccj.cc.fl.us>
    Re: Can't use string ("") as a subroutine ref while "st <Paul.Makepeace@POBox.com>
    Re: Courtesy Emails (was Re: A Pubilc Apology.) (Michael Schuerig)
    Re: FAQless Forays (was: Code Example Needed) <danboo@negia.net>
    Re: FAQless Forays (was: Code Example Needed) <tchrist@mox.perl.com>
    Re: File Permission/Ownership <agr30@uni-koeln.de>
        Hostname doesn't work on Linux <chris@ixlabs.com>
    Re: inet_ntoa <tchrist@mox.perl.com>
    Re: Perl and fast (big) file parsing <c.evans@clear.net.nz>
        pgp-lib.pl (David)
        Regex & locales. (Abigail)
    Re: RFC about "Matt's Script Archive" <tchrist@mox.perl.com>
    Re: RFC about "Matt's Script Archive" <merlyn@stonehenge.com>
        Running DOS commands in PERL script??? <jtorr@math.arizona.edu>
        Sorting Strings With Delimited Characters - Advice Soug (Tony K. Olsen)
    Re: sucess stories? <tchrist@mox.perl.com>
    Re: The Young Man and the Beach (Nathan V. Patwardhan)
    Re: The Young Man and the Beach (Nathan V. Patwardhan)
    Re: The Young Man and the Beach (Nathan V. Patwardhan)
    Re: Why is Tom Christiansen so rude? <lovegod@earthling.net>
    Re: Year 2000 Compliance: Lawyers, Liars, and Perl <Barticus@worldnet.att.spam.net>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 16 Feb 1998 04:31:27 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: A Pubilc Apology.
Message-Id: <qz$9802152318@qz.little-neck.ny.us>

Leslie Mikesell <les@MCS.COM> wrote:
> I know how to track followups after finding the parent article,
> but how do you make trn notice that there is a new article
> and the parent is 'yours'?

I autoselect anything with one of my message IDs in the References:
header. To get this to work right, I hacked Pnews to generate the
message IDs for me.

There are other ways to do it, but this seems to be the fastest.

Elijah
------
having trn memorize the message IDs of all your posts being the slowest


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

Date: Sun, 15 Feb 1998 23:31:09 +0100
From: schuerig@acm.org (Michael Schuerig)
Subject: Re: A Pubilc Apology.
Message-Id: <1d4ic89.2vegun192ypviN@rhrz-ts2-p4.rhrz.uni-bonn.de>

Lloyd Zusman <ljz@asfast.com> wrote:

> Furthermore, I have found during my 11+ years on the net that less
> than 5% of the people to whom I've sent "courtesy emails" have ever
> complained to me about this, or expressed any discomfort about this at
> all.  I number you among the small percentage of people to whom I will
> be careful not to send such emails.

I don't respond to "courtesy emails" at all. I ignore them even if I'm
offended. There are three cases:

1) The sender for some reason doesn't expect me to read the answer in
the group. Lacking positive evidence I consider this inappropriate.

2) Unless I've explicitly asked for a (possibly quicker) email response,
I don't want to sidetrack the public discussion.

3) The sender isn't being curteous at all. Rather he or she is trying to
tell me what an idiot I am -- and want's to stick their opinion right
into my face. There's no arguing with this kind of people.


Michael

-- 
Michael Schuerig
mailto:schuerig@acm.org
http://www.uni-bonn.de/~uzs90z/


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

Date: 15 Feb 1998 16:36:37 -0600
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: A Pubilc Apology.
Message-Id: <6c7qll$cfj$1@Mars.mcs.net>

In article <p5vhuhd0cg.fsf@baynetworks.com>,
Paul D. Smith <psmith@baynetworks.com> wrote:

>Anyway, I'm sure you're polite enough to _always_, _always_ note in your
>email that the response was both emailed and posted.  Not doing that is
>_always_ rude, IMO, even if the person explicitly asked to be emailed.

The problem is that the way to send a copy by email in rn/trn is to
stick the email address in the CC: header and the news posting and
email copy are thus identical.  So you have to annoy the rest of the
world with an extraneous comment or the email recipient by omitting
it.  Could Larry Wall have made a mistake in the design of rn?

  Les Mikesell
     les@mcs.com


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

Date: Mon, 16 Feb 1998 01:11:25 GMT
From: Bill Jones <webmaster@fccj.cc.fl.us>
Subject: Can't use string ("") as a subroutine ref while "strict refs" in use
Message-Id: <34E7912F.A8CC3EAE@fccj.cc.fl.us>

I thought about what various respondents said I should do; it did not
work either, so
I rearranged the code to see if it was attributed to how I was writing
it.

I came up with this -
                if (substr($vFlag, 1, 5) eq 'ADMIN') {
                        $vSub = \&Admin;
# [...]
                } elsif (substr($vFlag, 1, 6) eq 'USENET') {
                        $vSub = \&Usenet;
                } else {
                        # Perform data-biased subroutine...
                        &$vSub;
                }

But I still get this -
Can't use string ("") as a subroutine ref while "strict refs" in use at
        Filebase_Tabs.pl line 207, <prjCF> chunk 1 (#1)

    (F) Only hard references are allowed by "strict refs".  Symbolic
references
    are disallowed.  See perlref.

If I change -
                       &$vSub;
to -
                        print "$vSub\n";

I get -
CODE(0x257d28)  # Matches Admin area
CODE(0x257d28)
CODE(0x257d7c)   # Matches Reports area
CODE(0x257d7c)
CODE(0x257d7c)
CODE(0x257dd0)   # Matches Logs area
CODE(0x257dd0)
CODE(0x257e24)   # Matches Targets area
CODE(0x257e24)
CODE(0x257e24)
CODE(0x257e24)
CODE(0x257e24)
CODE(0x257e24)
CODE(0x257e24)
CODE(0x257e24)
CODE(0x257e78)   # Matches Usenet area
CODE(0x257e78)
CODE(0x257e78)

Each CODE basically matches the number of data input lines in each
area...
(The # Comments in CODE above were added by me during this post.)

Any ideas?

Thx,
Bill





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

Date: Sun, 15 Feb 1998 20:59:20 GMT
From: Bill Jones <webmaster@fccj.cc.fl.us>
Subject: Can't use string ("") as a subroutine ref while "strict refs" in use
Message-Id: <34E75619.DC93BAD4@fccj.cc.fl.us>

The following code -

                $vSub = 'Admin'   if (substr($vFlag, 1, 5) eq 'ADMIN');
                $vSub = 'Reports' if (substr($vFlag, 1, 7) eq
'REPORTS');
                $vSub = 'Logs'     if (substr($vFlag, 1, 4) eq 'LOGS');
                $vSub = 'Targets' if (substr($vFlag, 1, 7) eq
'TARGETS');
                $vSub = 'Usenet'  if (substr($vFlag, 1, 6) eq 'USENET');

                # Perform data-biased subroutine...
                &$vSub;


Gives the following error -

Can't use string ("") as a subroutine ref while "strict refs" in use at
        Filebase_Tabs.pl line 230, <prjCF> chunk 1 (#1)

    (F) Only hard references are allowed by "strict refs".  Symbolic
references
    are disallowed.  See perlref.

Uncaught exception from user code:
        Can't use string ("") as a subroutine ref while "strict refs" in
use at.
        main::readCF() called at Filebase_Tabs.pl line 108


I thought I can have the data truly drive the application by assigning
$vSub the subroutine it should call during execution.  It would allow
the program to process the data depending upon where it was in reading
the data file...

Am I just mis-reading the perlref pages -- I think what I want is
possible...

Any ideas?

Thx,
Bill



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

Date: Mon, 16 Feb 1998 21:18:17 -0000
From: "Paul Makepeace" <Paul.Makepeace@POBox.com>
Subject: Re: Can't use string ("") as a subroutine ref while "strict refs" in use
Message-Id: <887664292.20906.0.nnrp-07.9e98490c@news.demon.co.uk>

Bill Jones wrote in message <34E850FA.6B4DE23E@fccj.cc.fl.us>...
>Found answer for Case-Switching -
>
>How do I create a switch or case statement?

Judicious use of hashes means you don't have to ponder this problem too
much, at least IME. If I see more than two elsif's I get twitchy...

$^W = 1;
use strict refs;

sub Admin { print "Admin\n"; }
sub Logs { print "Logs\n"; }
sub Targets { print "Targets\n"; }
sub Usenet { print "Usenet\n"; }

# Here you're effectively 'declaring' which subroutines you're likely to
refer to later.
# The lowercase key gives a smattering of robustness; see later.

my %SubTable = (
 admin => \&Admin,
 logs => \&Logs,
 targets => \&Targets,
 usenet => \&Usenet,
);

# 'Switch'...

my $vSub = $SubTable{lc $vFlag};    # see?

 # Perform data-biased subroutine...

 &$vSub;

__END__

Of course, if making one of those SubTable's looks boring,

my @SubTable = qw(Admin Logs Targets Usenet);
my %SubTable;
@SubTable{map {lc $_} @SubTable} = map {\&$_} @SubTable;

It's not big and it's not clever but it does give you a level of job
security.

Cheers, Paul.

(I'm slightly surprised \&$_ got past strict refs...? [5.004_02/NT])




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

Date: Mon, 16 Feb 1998 08:07:19 +0100
From: schuerig@acm.org (Michael Schuerig)
Subject: Re: Courtesy Emails (was Re: A Pubilc Apology.)
Message-Id: <1d4j9ug.p4j35g1v3wf7kN@rhrz-isdn3-p57.rhrz.uni-bonn.de>

Jonathan Feinberg <jdf@pobox.com> wrote:

> schuerig@acm.org said...
> : 3) The sender isn't being curteous at all. Rather he or she is trying to
> : tell me what an idiot I am -- and want's to stick their opinion right
> : into my face. There's no arguing with this kind of people.
> 
> Do you mean to say that every piece of email you receive in response to a
> newsgroup question contains a personal insult? 

No, I didn't mean to say that and I did not say that. What you're
quoting is only one of the three very common cases of courtesy mail I've
received in the past.


> [This message was posted to c.s.p.m, and a copy was NOT sent to the cited
> author.]

And there was no need for it. I've found it here in the group without
any problem whatsoever. BTW, if I had sent you a copy of this reply how
would have felt?

Michael

-- 
Michael Schuerig
mailto:schuerig@acm.org
http://www.uni-bonn.de/~uzs90z/


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

Date: Sun, 15 Feb 1998 09:50:11 -0500
From: Dan Boorstein <danboo@negia.net>
Subject: Re: FAQless Forays (was: Code Example Needed)
Message-Id: <34E700A3.650E3C23@negia.net>

Evan Kirshenbaum wrote:
> 
> Dan Boorstein <danboo@negia.net> writes:
> 
> > isn't larry wall a linguist?  how did he become a programmer
> > (honestly, i am interested to know)?
> 
> Hey!  The two aren't necessarily mutually exclusive. :-) And if your
> specialization is formal language theory (as mine was; I don't know
> about Larry's), they can actually be quite similar, and skills picked
> up in one serve you in good stead in the other.
> 
> AB Linguistics, MS Computer Science, Stanford '87

agreed. i understand how interrelated programming and linguistics can be. i
myself have a great interest in etymology and the classics. i was just
curious to know if larry wall had ever violated tom's edict: that no one
shall try to program unless already a programmer.

seeing how my formal computer-related education never made it past a
highschool typing course, i have violated tom's wishes in a big way. my
college days were spent studying physiology, both undergrad and masters.
if tom thinks for one moment that i am going to give up my late blooming
passion for programming then he is sadly mistaken. though admittedly a
small sampling, i believe myself to have a greater "hacker" ethic than
any of the 6 degreed computer science majors i work with. i had to, to
get where i am. sure, i am still playing catch-up when it comes to
understanding the internals of computer function, but i am catching-up
and doing so quickly.

cheers,

--
danboo rstein


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

Date: 15 Feb 1998 16:07:13 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: FAQless Forays (was: Code Example Needed)
Message-Id: <6c73rh$mvn$1@csnews.cs.colorado.edu>

In comp.lang.perl.misc, bart.mediamind@tornado.be (Bart Lateur) writes:
:	my $a, $b;
:IT's a very silly example. But, countrary to what it looks like, it WILL
:compile, 

And elicit -w warnings.

:There you have it. I will ALWAYS use parens with local and my. I won't
:ever let this bite me again.

Then you get bitten by other things instead: the ones where list
context versus scalar context is a concern:

    my ($x) = @array;
    my  $x  = @array;

    my ($x) = <FH>;
    my  $x  = <FH>;

    my ($x) = reverse $a;
    my  $x  = reverse $a;

    my ($x) = $line =~ /this(.*?)here/;
    my  $x  = $line =~ /this(.*?)here/;

    my ($x) = grep /pat/, @array;
    my  $x  = grep /pat/, @array;

    my ($x) = userfunc($y);
    my  $x  = userfunc($y);

Just to name a few.  In short, you must learn the difference and be
ever mindful of it, lest madness ensue.

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

_doprnt(pat, args, &fakebuf); /* what a kludge */
    --Larry Wall, from util.c in the v5.0 perl distribution


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

Date: 16 Feb 1998 17:28:44 +0100
From: Martin Bialasinski <agr30@uni-koeln.de>
Subject: Re: File Permission/Ownership
Message-Id: <87k9avbjk3.fsf@haitech.internet-treff.de>

Matt Somers <msomers@hendco.com> writes:

> Whenever I try to create a file on the fly, it has an owner of
> nobody. 

A file a script creates is always owned by the euid the script runs as.

> How do I make it so that this file belongs to users
> and can be accessed and altered later in the program?

chown. But usually only root can do this. If you create the file, you can
also access and alter it.

So what was your question again?

Ciao,
	Martin


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

Date: Sat, 14 Feb 1998 20:56:05 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
To: Hanzo <hanzo@sni.net>
Subject: Hostname doesn't work on Linux
Message-Id: <34E67565.A92C25C4@ixlabs.com>

I remember not being able to use hostname() reliably on Linux at one
time, never found out why.

Works for me now though - the earliest Perl version I have installed is
5.003, and it works with that.

Does your hostname(1) work?
Try a pipe to that.

If you are running as CGI, you should be able to get the hostname
through $ENV{SERVER_NAME}.

-Chris

Hanzo wrote:
> 
> I wrote a perl script about a year ago that used UDP to query a server and
> read in some data. I recall writing it on Perl for Solaris, and testing on
> Irix and some other flavors of Unix.  When I brought the code home to my
> Linux box...it didn't work, puking on (I believe) either the send() or
> gethostbyname() function (actually, I'm pretty sure send() puked *because
> of* gethostbyname()).
> 
> Anyway, I managed to fix it.  That was a year ago, and the code is long
> since gone.
> 
> Now, a year later, I've tried to write a similar program.  Once again,
> using UDP, I'm trying to query a server and read in data.  And I've tested
> the script on Irix and Solaris.  Works like a charm.
> 
> Brought it home to my Linux box...what do you think happened? ;)
> 
> Here are the errors at the prompt:
> 
> ======
> 
> Useless use of gethostbyname in void context at
> /usr/lib/perl5/Sys/Hostname.pm l
> ine 42.
> Use of uninitialized value at ./q2query.pl line 29.
> Use of uninitialized value at ./q2query.pl line 48.
> Content-type: text/html
> 
> <html>
> ERROR: Send  at ./q2query.pl line 120.
> 
> ======
> 
> ...and here are the errors from the web server, when the script is run as a
> CGI:
> 
> ======
> 
> sh: /dev/null: Permission denied
> sh: /dev/null: Permission denied
> Can't exec "/com/host": No such file or directory at
> /usr/lib/perl5/Sys/Hostname
> .pm line 87.
> Cannot get host name of local machine at
> /usr/local/etc/httpd/apache/cgi-bin/q2q
> uery.pl line 42
> [Fri Feb 13 22:56:23 1998] access to
> /usr/local/etc/httpd/apache/cgi-bin/q2query
> .pl failed for 204.131.223.1, reason: Premature end of script headers
> 
> =======
> 
> Keep in mind that my networking (and DNS) are all working fine on the Linux
> box.
> Hopefully, those of you who are skilled with sockets can take a glimpse at
> this code and tell me what I need to tweak for a Linux platform.
> 
> --
> Shawn Holmes - Senior Project Manager
> Banished Entertainment - http://www.sni.net/banished
> 
> Code Begins Here:
> -----------------
> #!/usr/bin/perl -w
> 
> require 5.002;
> use strict;
> use Socket;
> use Sys::Hostname;
> 
> my ($input_host, $count, $rout, $rin, @output, $amount, $nogood,
>     $q2_response, $name, $value, %contents, @pairs, $pair, $buffer,
>     @newoutput, $newamount, @newline, $lineamount);
> 
> if ($ENV{'REQUEST_METHOD'} eq 'POST')
> {
>         read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>         @pairs = split(/&/, $buffer);
>         foreach $pair (@pairs)
>         {
>                 ($name, $value) = split(/=/,$pair);
>                 $value =~ tr/+/ /;
>                 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>                 $contents{$name} = $value;
>         }
> }
> 
> my $internet_address = gethostbyname(hostname());
> my $protocol         = getprotobyname('udp');
> my $port             = 0; #random port
> my $port_address     = sockaddr_in($port,$internet_address);
> my $a                = 0;
> my $b                = 0;
> my $q2_server        = inet_aton($contents{SERVER}) || die "ERROR: Unknown
> Host\n\n";
> my $q2_port          = sockaddr_in($contents{PORT},$q2_server);
> my $q2_msg           = sprintf ("\xFF\xFF\xFF\xFFstatus\0");
> my $q2_response      = "";
> 
> print "Content-type: text/html\n\n";
> print "<html>\n";
> 
> &Connect_and_query($q2_msg);
> if ($q2_response ne "")
> {
>     @output = split(/\\/,$q2_response);
>     $amount = @output;
>     $nogood = shift(@output);
>     print "<head><title>Results</title></head>\n";
>     print "<body bgcolor=\"000000\" text=\"00FF00\">\n";
>     print "<hr><br>\n";
>     print "<b>Server info settings:</b><p><font face=\"Courier New\"
> size=\"2\">\n";
>     print "<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\">\n";
>     while($output[$a] ne "hostname")
>         {
>         printf "<tr><td><font face=\"Courier New\"
> size=\"2\">%s</font></td>\n",$output[$a];
>         printf "<td><font face=\"Courier New\"
> size=\"2\">%s</font></td></tr>\n",$output[$a+1];
>         $a+=2;
>     }
> 
>     @newoutput = split(/\n/,$output[$a+1]);
>     $newamount = @newoutput;
> 
>     printf "<tr><td><font face=\"Courier New\"
> size=\"2\">%s</font></td>\n",$output[$a];
>     printf "<td><font face=\"Courier New\"
> size=\"2\">%s</font></td></tr>\n",$newoutput[$b];
>     print "</table>\n";
>     print "</font>\n";
> 
>     if ($newoutput[1])
>         {
>         print "<hr><table border=\"1\" cellpadding=\"4\"
> cellspacing=\"0\">\n";
>         print "<tr><td><b>Frags</b></td><td><b>Ping</b></td><td><b>Name of
> Player</b></td></tr>\n";
> 
>         while ($b < ($newamount - 1))
>                 {
>                         $b++;
>                         @newline = split(/ /,$newoutput[$b]);
>                         $lineamount = @newline;
>                         printf "<tr><td><font face=\"Courier New\"
> size=\"2\">%s</font></td><td><font face=\"Courier New\"
> size=\"2\">%s</font></td><td><font face=\"Courier New\"
> size=\"2\">%s</font></td></tr>\n",$newline[0],$newline[1],$newline[2];
>                 }
> 
>                 print "</table>\n";
>         } else {
>         print "<hr><br>\n";
>         print "<b><font size=\"3\">No Players Current On Server</b>\n";
>         }
> 
>     print "</font><br>\n";
>     print "</body></html>\n";
>     $count--;
> } else {
>     print "<head><title>WARNING</title></head>\n";
>     print "<body bgcolor=\"000000\" text=\"00FF00\">\n";
>     print "<hr><b>WARNING: Server not Responding!!!</b><p>\n";
>     print "<font face=\"Courier New\" size=\"2\">Check the IP address
> and/or port,<br>\n";
>         print "or verify that the server is up<br>\n";
>     print "</font><hr></body></html>\n";
> }
> 
> ### PROGRAM END ###
> 
> sub Connect_and_query
> {
>     $count++;
>     socket(SOCKET,PF_INET,SOCK_DGRAM,$protocol) || die "ERROR: Socket:
> $!\n\n";
>     bind(SOCKET,$port_address) || die "ERROR: Bind $!\n\n";
>     defined(send(SOCKET,$_[0],$port,$q2_port)) || die "ERROR: Send
> $q2_server: $!\n\n";
>     $rin = "";
>     vec($rin, fileno(SOCKET), 1) = 1;
>     while ($count && select($rout = $rin, undef, undef, 10.0))
>         {
>                 $q2_port = recv(SOCKET,$q2_response,2048,0) || die "ERROR: Recv $!\n\n";
>         }
> }


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

Date: 16 Feb 1998 02:00:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: inet_ntoa
Message-Id: <6c86j9$5n7$3@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, tkimball@siliconbeach.com writes:
:$test = inet_aton("157.22.208.5");
:"157.22.208.5" is the IP address of my ethernet card.
:When I run this code with no internet connection on any
:of my devices, the command blocks forever. It never
:returns. When I dial out on one of my modems,
:it works fine. 

Check pending connections: I'll bet it's a nameserver issue.
Yeah, I know it shouldn't be doing a DNS resolve on a number,
but, well, who knows what evil lurks in the hearts of the
Evil Empire's socket libraries?

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


sum to check equivalent files should use sum -a. --Andrew Hume


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

Date: 15 Feb 1998 17:40:12 +1300
From: Carey Evans <c.evans@clear.net.nz>
Subject: Re: Perl and fast (big) file parsing
Message-Id: <874t21wkes.fsf@psyche.evansnet>

Amine <cybersky@generation.net_no_spam> writes:

>  i am trying to parse every character of a big file by doing like this 
> 
>  while (!eof(MGRFILE))
>  {
>  seek(MGRFILE,$i,0); 

Get rid of this anyway.  It's probably making it 10 times slower, and
that's its only effect.

>  read(MGRFILE,$a,1);

This returns 0 at end of file, and undef on error.  You should test
for this before continuing.  Also, this loop will never terminate if
there's an error on the file.

>  $i++; 
>  }
> 
>  but this is taking very very long time for big files like 10+ Mo
>  how can i do it more quikly without rewriting it in C  ?
>  Note that i don't want to slurp it in memory this will take too much 
>  memory .

>From experience[1] I know that reading one byte at a time in C won't
give you great turn of speed either.  You need to read bigger blocks,
and treat each as if you'd read the whole thing into memory.

Just what are you doing with the characters?  That loop is basically a 
no-op.  Here's an example of counting the number of "." characters:

% ls -l mail.log.0
-rw-r-----   1 root     adm        789558 Feb 15 09:57 mail.log.0
% time perl -lwe 'my ($n,$a)=(0); while (($a = getc()) ne "") {
                  $n++ if $a eq "."}; print $n' < mail.log.0
15134
perl -le  < mail.log.0  5.81s user 0.01s system 98% cpu 5.932 total
                        ^^^^^
% time perl -lwe 'my ($n,$a)=(0); while (read(STDIN,$a,4096)) {
                  $n++ while($a =~ m/\./g)}; print $n' < mail.log.0
15134
perl -le  < mail.log.0  0.15s user 0.04s system 279% cpu 0.068 total
                        ^^^^^

And the second one could be written better, instead of iterating over
every single `.' in the input.  What speeds it up is that it does its
reads in 4K chunks, which is much faster than 1 byte chunks.

[1] A "competition" with my brother to combine two files in a creative
    fashion, as fast as possible.

-- 
	 Carey Evans  http://home.clear.net.nz/pages/c.evans/

	  GNU GPL: "The Source will be with you... always."


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

Date: Sat, 14 Feb 1998 16:48:08 GMT
From: davidu@electriciti.com (David)
Subject: pgp-lib.pl
Message-Id: <34e5ca8f.45440119@news.electriciti.com>

Does anyone know how to decrypt using pgp-lib after they have
encrypted something? I have only found a way to encrypt.  
-DavidU


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

Date: 15 Feb 1998 15:21:01 GMT
From: abigail@fnx.com (Abigail)
Subject: Regex & locales.
Message-Id: <6c714t$cvd$1@client2.news.psi.net>

In a regex, how does one match an uppercase letter in the current locale?



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


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

Date: 15 Feb 1998 16:09:05 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <6c73v1$mvn$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, bart.mediamind@tornado.be (Bart Lateur) writes:
:Isn't it just a bit remarkable that many Perl guru's on this newgroup
:just complain about the state of Matt's scripts, and nobody volunteers
:to make a better version?

Beach.  Beggars.  Finite Time.  Responsibility.  Chemists.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
"Espousing the eponymous /cgi-bin/perl.exe?FMH.pl execution model is like 
reading a suicide note -- three days too late."
	    --Tom Christiansen <tchrist@mox.perl.com>


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

Date: 15 Feb 1998 19:26:18 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <8cra542sl1.fsf@gadget.cscaper.com>

>>>>> "Bart" == Bart Lateur <bart.mediamind@tornado.be> writes:

Bart> Isn't it just a bit remarkable that many Perl guru's on this newgroup
Bart> just complain about the state of Matt's scripts, and nobody volunteers
Bart> to make a better version?

Please withdraw "nobody".

See http://www.stonehenge.com/merlyn/WebTechniques/

I spend a lot of time (albeit for hire, but thanks to the sweet deal I
cut with MFI, the results are also free) trying to raise the average
Perl-intelligence level of the web hackers out there.

And in an interesting way, I meant what the cover of that book quotes
me as saying...  the MSA programs should inspire you to write your OWN
programs.  Mostly because the MSA programs are merely a good first
draft from which to steal, but should not be used in their original
form. :-)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 197 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Mon, 16 Feb 1998 12:51:23 -0700
From: Jose Torres <jtorr@math.arizona.edu>
Subject: Running DOS commands in PERL script???
Message-Id: <34E898BB.769E@math.arizona.edu>

Im very new to perl for Windows NT, and although this is
probabbly easy, I cant find a way to implement DOS/NT command line
commands within a perl script, such as net use ,etc.

Is there any way to do this ????

Thanks in advance


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

Date: Sun, 15 Feb 1998 20:17:37 -0000
From: tkolsen@btinternet.com (Tony K. Olsen)
Subject: Sorting Strings With Delimited Characters - Advice Sought
Message-Id: <MPG.f515daa12a749ab989683@news.btinternet.com>

Hi Everyone,

	After having tried numerous things like cmp and <=> etc. I am 
looking for a little advice on a sort problem I am having with a 
delimited text file using two colons (::).

	Running perl, version 5.003_07 on Windows 98

Text file begins:

1::1997::
23::1998::
2::1998::
14::1998::
2::1997::
3::1998::

	When I sort the file with the code below I get:

14::1998::
1::1997::
23::1998::
2::1997::
2::1998::
3::1998::

	I understand why it is doing what it is doing (14 is < 1:) but not 
quite sure the best method for implementing without a lot of coding.

	What I want is:

1::1997::
2::1997::
2::1998::
3::1998::
14::1998::
23::1998::

	Any advice greatly appreciated.  Thanks in advance.  Cheers.

<code segment>

#!/perl/bin/perl -w

##################################

&do_sort;

##################################
sub do_sort
{

	$database = "e:\\pfe\\programs\\database\\serials.db";
	open(DATA, "<$database") || die "cannot open the ", $database, " 
file";

	chomp (@data = <DATA>);
	close DATA;

	@sortedlist = sort by_string @data;

	foreach $term (@sortedlist) {
   	print $term,"\n";
	}

}

##################################
sub by_string
{
	$a cmp $b;
}

-- 
       ___
      (_B_)__
     ~(@ @)~
+-oOOo-(_)-oOOo-------------------------------------------------+
| "I played before the greatest fans in baseball, the Boston    |
| fans, and I know what you're going to say about that: Old     |
| Teddy Ballgame loved those fans, all right." --- Ted Williams |
+----------------+----------------------------------------------+
| Tony K. Olsen  | URL:     http://www.btinternet.com/~tkolsen  |
| Cheltenham, UK | Email:   mailto:tkolsen@btinternet.com       |
+----------------+----------------------------------------------+


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

Date: 15 Feb 1998 16:40:54 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: sucess stories?
Message-Id: <6c75qm$p73$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, stvhoof@netvision.net.il writes:
:When I showed someone the chapter on Object-Oriented programming in the
:Camel Book, they said it looked too complicated and new developers would
:not be able to get the hang of it.  

See the perltoot manpage.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    double value;                /* or your money back! */
    short changed;               /* so triple your money back! */
            --Larry Wall in cons.c from the 4.0 perl source code


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

Date: 16 Feb 1998 20:33:27 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: The Young Man and the Beach
Message-Id: <6ca7qn$19h@fridge.shore.net>

Richard Bellavance (charlot@CAM.ORG) wrote:

: "posting to usenet" and "having an account on someone else's machine" are two
: different things.  (of course, you need an account to access Usenet...) 
: What I meant to say is that if you have an Internet account, you
: have the right to post a message to Usenet.  

No, you don't.  I've had many accounts over the years, and not one of
these accounts entitled me to "right to service" on Usenet or
*anywhere*.  Don't forget that even if you have your *own* newsserver,
you still need to get someone who will feed to you.

--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: 16 Feb 1998 20:28:02 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: The Young Man and the Beach
Message-Id: <6ca7gi$19h@fridge.shore.net>

Mark Kramer (c28f62@world.std.com) wrote:

: One of those bits of netiquette hapens to involve OS flaming.

Since the questions relate to a curious "OS", where things often don't
work correctly (but people still ask for support ... and lots of it),
I suspect that this is the heart of the problem in the OS Wars.


--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: 15 Feb 1998 18:22:52 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: The Young Man and the Beach
Message-Id: <6c7bps$9et@fridge.shore.net>

John Bollenbacher (jhb@cts.com) wrote:
: I think that long-time participants in internet and computing in general
: forget

This linewrap is atrocious.  It's giving me a spasm.  Quit it.  Sure,
you're one step better than a MIME posting, but only slightly.  ;-)

: Being inquisitive and a self-starter you post a question not even
: knowing 
: where your questions will go or if anyone will actually see them.

Self-starters wouldn't start on Usenet, me thinks.  I didn't discover
Usenet until I "moved on" from something else.  There's a story behind
that, but ... oh well, never mind.

Sure, there's a wonder about Usenet, but it's something that people
take for granted.

: Now return your thoughts to the present.  Doesn't it seem like having a
: canned

That's why there are the news.announce newsgroups.  Didn't you get
auto-subscribed to them the first time you started your newsreader?

--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: Thu, 12 Feb 1998 22:56:01 -0600
From: Rich Grise <lovegod@earthling.net>
Subject: Re: Why is Tom Christiansen so rude?
Message-Id: <34E3D261.744C@earthling.net>

Jonathan Stowe wrote:
> 
> In article <6bv95t$ira$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com
> says...
> 
> >For this, Ken invented grep.
> >
> 
> This probably is not why Bill G. "invented" the happless find though ;-{
> 
> /J\
I've heard, "There are two notable things that have come from Berkely in
this century. LSD and Unix. We do not believe this to be a coincidence."

;)




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

Date: Sun, 15 Feb 1998 21:21:06 -0800
From: RandallBart <Barticus@worldnet.att.spam.net>
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <6c8ieg$ale@bgtnsc02.worldnet.att.net>

John Porter wrote:
> 
> Bart Lateur wrote:

> > So: does "cal" know about his? Does it guess where you are, so that it
> > can take the appropriate correction? Of course not.
> > At least, I hope it won't even try.
> 
> Why not? That's what locales and timezones are for!
> 
Does cal correctly handle 1700-03-01 thru 1712-02-30 with a Swedish
locale?
-- 
I  |\   Randall Bart                      mailto:Barticus@usa.spam.net
L  |/   
o  |\        Barticus@worldnet.att.spam.net  Barticus@hotmail.spam.com
v  | \  1-818-985-3259                       Please reply without spam
e    |\ 
Y    |/ Panic in the Year Zero Zero:  http://members.aol.com/PanicYr00
o    |\ 29th Term Revealed (!?):
u    |/                 http://members.aol.com/PanicYr00/Sequence.html


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

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

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