HDTenEightyP/NetNews huggingface dataset:
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: fast way to get number of elements in an assoc array?
Date: 31 Aug 92 17:38:56 GMT
Organization: NetLabs, Inc.

In article <1992Aug29.011345.24106@lsil.com> aspin@lsil.com writes:
: I wrote a program to try various ways of doing this,
: including the one above, and get several different results.
: Can anyone explain this to me?

: while (<IN>) {
:     $words{$_} = $nlines++;
: }

Note that this sets the first entry in %words to have a value of 0.  After
the loop this turns out to be the 14th entry (in iterator order).

: &try('$n = keys(%words)');
: &try('$n = 0; while (each %words) { $n++; }');

Note that this evaluates each() in a scalar context, so it returns just
the value.  The 14th time it does this, it gets a 0, so your while
loop exits before the iterator is done.  Next time you'll start from
the 15th entry, and since there are 84 entries left on the iterator,
that's what you'll get for a count.

Larry
Newsgroups: comp.lang.perl
From: lezz@merlin.dev.cdx.mot.com (Lezz Giles)
Subject: Re: C cross referencer (was Re: locsym)
Reply-To: lezz@merlin.dev.cdx.mot.com (Lezz Giles)
Organization: Motorola Codex, Canton, MA
Date: Thu, 27 Aug 1992 22:18:09 GMT

In article <22274@venera.isi.edu>, rod@isi.edu (Rodney Doyle Van Meter III) writes:
|>Certainly a marvelously useful tool; I was doing it literally
|>yesterday. If only I'd been caught on netnews :-).
|>
|>The next tool I'm looking for is a C cross referencer that will
|>handle ANSI syntax.  Perl is the obvious choice for writing
|>such a tool; has anyone done it?  I invested about two hours
|>in an extremely primitive one myself, but I don't want to
|>reinvent the wheel if somebody has designed and written one
|>already.
|>
|>It needs to be fairly robust in the case of incomplete code;
|>I like to use it as I'm writing. cxref supplied w/ SunOS
|>barfs on my ragged code, and can't handle ANSI.
|>
|>Pointers to a freely available one in any language are okay,
|>though Perl is the obvious choice.

I'm also interested in such a tool.

Lezz Giles
Newsgroups: comp.lang.perl
From: fabbott@athena.mit.edu (Freeland K Abbott III)
Subject: Help: SCO_3 aliasing?!
Organization: Massachusetts Institute of Technology
Distribution: comp
Date: Tue, 25 Aug 1992 22:24:13 GMT


I'm attempting to compile perl 4.019---no, I'm attempting to use it;
it compiled just fine.  I took hints for i386 and sco_3, and used
perl's malloc; the rest was taken from the hints, including "undef"
for $i_varargs.  Without perl's malloc, lots of tests failed; with it,
only lib/big test 61 fails.  But I can't find a better result, using
SCO 3.2 rev4.0....

However, I did find one particularly interesting behavior: here's the
code:

	local(*x,*y);
	$x = 3;
	print("x=$x, y=$y\n");
	$y = 4;
	print("x=$x, y=$y\n");
	$x[0] = "hi";
	$y[0] = "bye";
	print ("$x[0]\n");

produces this output:
	x=3, y=3
	x=4, y=4
	bye

Huh?!  Somehow x and y are aliased to be identical...

Anyway, what I need is a Clue.  This is straight 4.019, which we have
working on lots of other machines: it's not perl, it's something in
the configuration with which I compiled.  I'm startled that with such
a basic problem so many of the tests pass... also, we've got a (much
more complicated) program which, left to run for a while, causes a
kernel panic: we need to figure these out, and I've already tried all
the easy permutations in Configure.

Incidentally, if we declare variables in separate local statements
(i.e. local(*x); local(*y)... rather nasty in the case of
local(..)=@_;), we get "correct" (non-aliased) results.  The complex
case still dies, but not in a kernel panic (at least not from just one
run)... I'm still looking for that one, but need help with the simple
case first.
--
Freeland K. Abbott              fabbott@athena.mit.edu
104 Madison Ave.                now working for Cambridge Technology Group
Arlington, MA 02174             "And I thought 14-hr days would be over now"
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: help!
Date: 3 Sep 92 18:30:31 GMT
Organization: NetLabs, Inc.

In article <ASHERMAN.92Sep2112319@laser.fmrco.com> asherman@fmrco.COM writes:
: ${$a} is not valid in perl (or at least, it does something that you
: are not expecting). 

Though, oddly enough, his example probably WILL work in Perl 5.  I take
that as confirmation I'm headed the right direction...

Larry
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: system & exec questions
Date: 25 Aug 92 22:52:37 GMT
Organization: NetLabs, Inc.

In article <1992Aug20.234826.28608@csus.edu> eburk@sfsuvax1.sfsu.edu (Eli Burk) writes:
: I am having some difficulty understanding how to use perl
: system & exec functions. As an example if I have @list
: and I want to send this out to my system (unix) what is
: the best wa? As an example I want to use unix "pr"
: the following is from memory - but it shows the basic idea...
: csh script fragment (cal 9 1992; cal 10 1992) | pr -t -2
: How do I acomplish the same thing in perl? If I pass the 
: "cal"s to @list how can I then pipe @list to "pr"?

That is a bit underspecified, but try something like this:

    open(INPUT, "cal 9 1992; cal 10 1992|");
    open(OUTPUT, "| pr -t -2");
    @list = <INPUT>;
    print OUTPUT @list;
    close INPUT;
    close OUTPUT;

Larry
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: Perl language formatting conventions?
Date: 25 Aug 92 21:48:00 GMT
Distribution: comp
Organization: NetLabs, Inc.

In article <DAVE.92Aug25141544@pipi.iis.u-tokyo.ac.jp> dave@pipi.iis.u-tokyo.ac.jp (David Wuertele) writes:
: What do youse all think?

That's a religious issue.

There's only one sure-fire way to be happy.  Do what you know is right,
and don't expect everyone to like it.

Larry
From: dsb@world.std.com (David Boyce)
Newsgroups: comp.lang.perl
Subject: Re: help with if ( ! $a =~ /##/ ) PLEASE!!!
Date: 28 Aug 92 01:03:31 GMT
Distribution: usa
Organization: The World Public Access UNIX, Brookline, MA

In article <ericw.714945775@bach> ericw@bach.amd.com (Eric Wedaa) writes:
>I am having a h!@# of a time getting this code fragment to 
>work:
>
>if ( ! $a =~ /#/ ){
>	some_random_bit_of_perl;
>}
>
>It never does anything!  What I want it to do is if $a does not 
>have "#" in it, then it should do "some_random_bit_of_perl;"
>
>What fundamental thing am I missing?

    Precedence rules. Put parens around the conditional:

if ( ! ($a =~ /#/)){

>Silly question of the day...  (And I know that 15 minutes
>after I post this, and it goes out through the ether, I'll
>probably figure it out myself.) 

    And 15 minutes after that the net will be deluged with answers.
-- 
David Boyce	dsb@world.std.com	617-576-1540
Newsgroups: comp.lang.perl
From: rackow@skeeve.mcs.anl.gov (Gene Rackow)
Subject: Dictionaries for the Camel Password program
Organization: Argonne National Laboratory, Chicago, Illinois
Date: Thu, 3 Sep 1992 01:50:43 GMT

Are the extra dictionaries that the passwd file uses available anywhere?
I already have web and web2, but am interested in the "badwords" and
the "badpats" files.  I already have a bunch of dictionaries from various
sites, but any others would be appreciated.

-_Gene


   Gene Rackow                    email: rackow@mcs.anl.gov
   Math & Computer Science        voice: 708-252-7126
   Argonne National Lab           FAX:   708-252-5986
   9700 S. Cass Ave. / Argonne, IL  60439

Newsgroups: comp.lang.perl
From: weingart@inf.ethz.ch (Tobias Weingartner)
Subject: split !!
Followup-To: weingart@inf.ethz.ch
Keywords: split, GRRR
Reply-To: weingart@inf.ethz.ch
Organization: ETH - Switzerland
Date: Sun, 30 Aug 1992 17:22:31 GMT


Hello, I have run into a little trouble here.
I have a database, made up like the following:

field:field:etc:etc:etc

Well, the split operation (a la split(/:/, $foobar)) works
quite nicely on this.  The trouble comes from the users here.

What if the use types in a : for part of his neato reply?
You guessed it! Ka-Boom.

I thought that I could do something like this:

print "Enter response: ";
chop(@line[0] = <STDIN>);
@line[0] =~ s/:/\\:/;

...

$data = join(':', @line);
print FILE $data.'\n';

...

Then to read it in:

chop($data = <FILE>);
@line = split(/[^\\]:/, $data);


This splits the lines appropriately, but there is a
character chopped off.

What I am looking for, is something like in lex:

[^\\]/:	{split();}

Where the split will only be done if the perceading
character is not a \.

Any ideas?

--Toby.
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: SEGV in perl
Date: 27 Aug 92 00:40:12 GMT
Organization: NetLabs, Inc.

In article <1992Aug25.185319.2532@bnlux1.bnl.gov> gc@bnl.gov writes:
: Why do beginners (like me) always cause trouble?
: 
: The following perl script causes perl to core dump with a SEGV on a Sun
: running SunOS 4.1:
: 
: #!/bin/sh --  # wish i were perl
: # set -vx
: eval 'exec perl -d -S $0 ${1+"$@"}'
: 	if $running_under_some_useless_shell;
: while (($key,$value) = each %ENV){
: 	print "$key";
: 	if ($key =~ /WAVE_.*/){
: 		delete $ENV{$key};
: 		print " deleted";
: 	};
: 	print "\n";
: };
: print "\nRecapitulating\n";
: while (($key,$value) = each %ENV){
: 	print "$key\n";
: }
: 
: And "perl -v" says:
: 
: This is perl, version 4.0
:  
: $RCSfile: perl.c,v $$Revision: 4.0.1.6 $$Date: 91/11/11 16:38:45 $
: Patch level: 19
:  
: Can anyone enlighten me?

Yeah, the each() iterator is stoopid, and doesn't handle deleting
the current element right.  Don't do that (yet).

Larry
From: merlyn@romulus.reed.edu (Randal L. Schwartz)
Newsgroups: comp.lang.perl
Subject: Re: Ordering indices based on their values
Date: 27 Aug 92 17:28:51 GMT
Article-I.D.: romulus.MERLYN.92Aug27102846
Distribution: comp.lang.perl
Organization: Reed College

In article <1992Aug27.151949.10917@genrad.com> jpn@genrad.com (John P. Nelson) writes:

   #!/usr/local/perl

   # makeindex subroutine builds and returns a sorted index array.
   # argument is a numeric array passed by reference.  To create
   # an index for a string array, use "cmp" instead of "<=>"
   sub makeindex {
       local(*arr) = @_;
       local(@i) = (0 .. $#arr);

       sort { $arr[$b] <=> $arr[$a] } @i;
   }

The @i array is unnecessary.  Just do:

	sort { $arr[$b] <=> $arr[$a] } $[ .. $#arr;

(Use $[ for less "Surprise!" factor)

print +(split(//,",rekcah lreP rehtona tsuJ"))[sort {$b<=>$a} 0..24]
--
Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
merlyn@reed.edu (guest account) merlyn@ora.com (better for permanent record)
cute quote: "Welcome to Portland, Oregon -- home of the California Raisins!"
From: ellozy@farber.harvard.edu (Mohamed Ellozy)
Newsgroups: comp.lang.perl
Subject: Perl for statisticians
Date: 4 Sep 1992 14:59:48 GMT
Organization: Dana-Farber Cancer Institute
Distribution: world
NNTP-Posting-Host: farber.harvard.edu
Originator: ellozy@farber

I will be giving a talk to statisticians about useful UNIX tools they
should be aware of, and want to say quite a bit about perl.  I have a
paper by Douglas Bates on Data manipulation in perl which gives a few
nice examples, but I could use some more.

Notes, scripts, ideas all gratefully accepted!

Thanks.

Mohamed
From: merlyn@ora.com (Randal L. Schwartz)
Newsgroups: comp.lang.perl
Subject: Re: Camel Book for 5.xxx hardback?
Date: 31 Aug 92 16:59:09 GMT
Article-I.D.: romulus.MERLYN.92Aug31095906
	<1992Aug31.140129.18987@msuinfo.cl.msu.edu>
Organization: Stonehenge Consulting Services; Portland, Oregon, USA

In article <1992Aug31.140129.18987@msuinfo.cl.msu.edu> jpd@discovery.msu.edu (Joe P. DeCello) writes:
   But, It would last longer, and be easier to use, if it had some
   kind of spiral bound, so us newbies wouldn't have to break down
   the binding for the book to stay open while we canabalize an
   example from it.

I believe that a few of the copies that I autographed at the local
store recently had "new stay-flat binding!" emblazened across the
spine.  I'll check to see that this is the case.  If it is, your
request has *already* been handled.  How's that for service?

print "Just another Perl [book] hacker,"
--
Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
merlyn@reed.edu (guest account) merlyn@ora.com (better for permanent record)
cute quote: "Welcome to Portland, Oregon -- home of the California Raisins!"
Newsgroups: comp.lang.perl
From: tal@Warren.MENTORG.COM (Tom Limoncelli)
Subject: How fast is... (was Re: randomize.c)
Organization: Mentor Graphics -- IC Group
Date: Wed, 2 Sep 1992 13:50:55 GMT

In <1992Sep1.210332.26149@netlabs.com> lwall@netlabs.com (Larry Wall) writes:

>      ......                      Subscripting, however, happens
>constantly, so we optimize for that.

Are associative arrays optimized?  For example, many times I do:

if ( $foo{$thing} ne $frob ) {
	$foo{$thing} += $fratz;
}

Is there a one-entry cache or does it traverse the hash tables twice?

Tom
-- 
Tom Limoncelli -- tal@warren.mentorg.com (work) -- tal@plts.uucp (play)
"Oh! I thought it was one of those useless demos of everything that
    a GUI builder could do." -Anonymous person watching demo of
         Solaris 2.0's graphical tool for managing NIS+
Newsgroups: comp.lang.perl,alt.security
From: dsg@blackbird.mitre.org (David S. Goldberg)
Subject: P-COPS
Organization: The Mitre Corp., Bedford, MA.
Date: Wed, 26 Aug 1992 19:17:26 GMT


I've been running the Shell version of COPS for some time now and want
to check out the perl version.  However, I seem to be running into
some "Malformed cmd links" errors.  I think I've narrowed it down to
the "run" subroutine in the main cops program.  Can anyone tell me
what causes this error?  I'm not sure it's got anything to do with the
reason cops ends up hanging, but I'm seeing them alot.

If it matters: perl 4.035, cops 1.04, IRIX 3.3.3

Any help/advice appreciated.

Thanks,

--
Dave Goldberg                      UNIX Systems Programmer/Administrator
Post: The Mitre Corporation MS B020 202 Burlington Rd. Bedford, MA 01730
Phone: 617-271-2460
Domain: dsg@mbunix.mitre.org  UUCP: {your neighborhood}!linus!mbunix!dsg
From: jpd@discovery.msu.edu (Joe P. DeCello)
Newsgroups: comp.lang.perl
Subject: Re: Camel Book for 5.xxx hardback?
Date: 31 Aug 92 14:01:29 GMT
Reply-To: jpd@discovery.msu.edu
Organization: Michigan State University


It seams reasonable that a hardcopy wouldn't be worth it, since
a paperback would last as long as the version of perl it's for.

But, It would last longer, and be easier to use, if it had some
kind of spiral bound, so us newbies wouldn't have to break down
the binding for the book to stay open while we canabalize an
example from it.

JUST my own personal $.02
---
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Joseph P. DeCello III                      e-mail:  jpd@cad.msu.edu
Michigan State University                      ph:  (517) 353-3027 
Specialized Computing Support Services              10am - 5pm EST
From: @prism.cs.orst.edu
Newsgroups: comp.lang.perl
Subject: Re: Camel Book for 5.xxx hardback?
Date: 31 Aug 92 21:31:32 GMT
Article-I.D.: CS.1992Aug31.213132.23853
Organization: Oregon State University, Computer Science Dept

In <1992Aug29.162151.1847@meiko.com> mike@meiko.com (Mike Stok) writes:

>If there's going to be a new Camel Book for the new Perl, will it ever
>be available as a hardback?  [...]

  On a semi-related note, one of the things that most bugs me about the
Camel Book is it's references to things in "Chapter n", while the pages
don't have chapter numbers on them!  This means I have to go back to
the table of contents to see where that chapter is (yeah, so maybe it's
my fault for not memorizing 90% of the book yet.. :-).  In future
versions, consider either putting the Chapter number somewhere on the
page, or use the texinfo style of "Chapter 4, page 151" which would save
non-JAPHers lots of time.
  Thanks,
--
Dana Jacobsen                              print "A Unique Perl Hacker";
jacobsd@cs.orst.edu
jacobsd@solar.cor2.epa.gov              (What qualifies one to be JAPH?)
Newsgroups: comp.lang.perl
From: asherman@laser.fmrco.com (Aaron Sherman)
Subject: Re: how to get passwd
Organization: I-Kinetics, 19 Bishop-Allen Dr., Cambridge, MA
	<1992Sep3.184343.12651@netlabs.com>
Distribution: usa
Date: Fri, 4 Sep 1992 18:05:21 GMT


>>>>> lwall@netlabs.com (Larry Wall) said:

lwall> How many times a month are you going to be doing this?  1928347 times?
lwall> 100 times?  3 times?

I don't understand what this has to do with it. Are you saying that
efficiency is not important because you don't have to do it very often
(fair enough in many cases) or that what I wrote was less efficient
than calling tail (see below)?

lwall> How 'bout:
lwall>     $uid = (split(/:/, `tail -1 /etc/passwd`))[2];

I would add a 0 to the result to force it to be a number. $uid eq ''
can cause some things to choke (unless you use $uid as a number later
on anyway).

lwall> Yes, you've got a Swiss Army Chainsaw.  It's not required, even in the
lwall> Swiss Army, that you open your marmelade [sic] with it.

I'll admit that this is a much simpler way of doing things (perhaps
faster, depends on how tail does things. I seem to remember that tail
reads the whole file), but I was replying to a question that
specifically asked how to do it in perl, so I wasn't thinking along
those lines at all. (This seems sort of like trying to explain why I
would use EMACS to Richard Stallman...)

As to my posting, though... I'm convinced (only by my gut) that the
way that I used seek to find the last line is not the fastest or most
efficient way to find the last line. My main goal was to NOT read
through the whole file, but I think that my algorithm for finding the
last line (seek -100 from EOF, then read all 100 chars, then seek back
200, etc) was less efficient than it could be. How do you "read a file
backwards"? That was what I wanted, but I didn't want to call seek
between each getc.

What's faster (and/or smaller and/or more efficient) than this:

	$\="\n";
	open(F,'</etc/passwd') || die("Cannot open /etc/passwd: $!\n");
	
	if (seek(F,-100,2))
	{
	    do
	    {
		$i=0;
		while(defined($c=getc(F)) && $c ne "\n")
		{
		    last unless ($i++ < 100);
		}
	    } while($c ne "\n" && seek(F,-200,1));
	}
	    
	seek(F,0,0) if (tell < 100);
	$last = $_ while(<F>);
	print((split(/:/,$last))[2]+0);



			-AJS

--
--------
Disclaimer: I am solely responsible for the content of this message.
The views expressed here may not be the views of I-Kinetics, Fidelity,
any of the Fidelity-owned corporations or my mother.
From: rray@lookout.it.uswc.uswest.com (Randy J. Ray)
Newsgroups: comp.lang.perl
Subject: Re: Using $*, but pattern doesn't match
Date: 27 Aug 92 16:29:56 GMT
Organization: US WEST Communications, Inc. -- Denver, CO

In article <121@eiffel.eiffel.com>, ram@eiffel.com (Raphael Manfredi) writes:
> Quoting tchrist@convex.COM (Tom Christiansen) from comp.lang.perl:
> >From the keyboard of ram@eiffel.com (Raphael Manfredi):
> >:You have to use [.\n] if you want to match anything.
> >
> >Sorry, [] is a nonmagical zone, so your dot is a literal.
> >Often we use [^\0] to mean (just about) anything.
> 
> Hmm... I meant (.|\n) obviously :-)
> 

Well, about an hour or so after posting, it dawned on me that . would not match
\n whether $* was set to 1 or not. Since what I was trying to extract was the
argument list from a local(...) = @_; declaration, I used the pattern:

([\w\d\s\*\@\$%,]*)

which will only match if the material inside is relatively close to a legal
argument list. This, combined with surrounding logic, allow me to report errors
if they pop up.

Perl still looks like line-noise to me. But it's GOOD line noise...

Randy
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Randy J. Ray -- U S WEST IT/CSD         rray@{lookout,uswat}.it.uswc.uswest.com
I'd rather talk religion with Charles Manson than discuss ethics with Congress.
     -me                                                   Phone: (303)595-2852
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Newsgroups: comp.lang.perl
From: ejk@ux2.cso.uiuc.edu (Ed Kubaitis - CCSO)
Subject: Re: 4.035 bug or feature...why does this run?
Organization: University of Illinois - Urbana
Date: Thu, 27 Aug 1992 18:07:15 GMT

stantz@sierra.corp.sgi.com (Mark Stantz) writes:
  |...
  |foreach $item (@s2) {
  |  push(@u, $item) unless (grep(($_ eq $item), @s1))		# Huh?
  |}
  |...
  |	Why does this program run when there is no ';' at the end of 
  |the line indicated with the comment?  Apparently it works fine under 4.035, 
  |but doesn't run under 4.019 or earlier versions.  I would have expected the 
  |'doesn't run' behavior in 4.035 as well.
  |
  |	What's the story behind this?

Feature. From "perl 4.0 patch #20":

   ENHANCEMENTS
-->Subject: relaxed requirement for semicolon at the end of a block
   Subject: scalar keys %array now counts keys for you
   Subject: added ... as variant on ..
   Subject: get*by* routines now return something useful in a scalar context
   Subject: form feed for formats is now specifiable via $^L
   Subject: PERLLIB now supports multiple directories
   Subject: paragraph mode now skips extra newlines automatically

----------------------------------
Ed Kubaitis (ejk@ux2.cso.uiuc.edu)
Computing & Communications Services Office - University of Illinois, Urbana
Newsgroups: comp.lang.perl
From: dhami@cs.ubc.ca (Mandeep S Dhami)
Subject: Re: nuther perl-idiom question..
Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
Date: Wed, 2 Sep 92 00:17:59 GMT

Tom Christiansen <tchrist@convex.COM> writes:
>
>In Perl, one often writes:
>
>    $x = $foo || "default";
>

As long as you can be assured that $foo is not the string "0"!
Try -
  $x="0";print '$y is ', $y=$x||"1",".\n";
or even 
  $x="0".""; ... # To force $x to be a string

$y is 1.


Hence I always use $x=defined($foo)?$foo:$bar;

Mandeep.
--
__________________________________________________________________
"I'm very brave generally," he went on in a low voice:
"only to-day I happen to have a headache."
                                      -- Lewis Carroll
From: merlyn@ora.com (Randal L. Schwartz)
Newsgroups: comp.lang.perl
Subject: Re: how to get passwd
Date: 4 Sep 92 19:04:02 GMT
Article-I.D.: romulus.MERLYN.92Sep4120357
	<1992Sep3.184343.12651@netlabs.com>
	<ASHERMAN.92Sep4130521@laser.fmrco.com>
Distribution: usa
Organization: Stonehenge Consulting Services; Portland, Oregon, USA

In article <ASHERMAN.92Sep4130521@laser.fmrco.com> asherman@laser.fmrco.com (Aaron Sherman) writes:
   What's faster (and/or smaller and/or more efficient) than this:

	   $\="\n";
	   open(F,'</etc/passwd') || die("Cannot open /etc/passwd: $!\n");

	   if (seek(F,-100,2))
	   {
	       do
	       {
		   $i=0;
		   while(defined($c=getc(F)) && $c ne "\n")
		   {
		       last unless ($i++ < 100);
		   }
	       } while($c ne "\n" && seek(F,-200,1));
	   }

	   seek(F,0,0) if (tell < 100);
	   $last = $_ while(<F>);
	   print((split(/:/,$last))[2]+0);


Argh. "getc"??  That's *easy* to beat!

open(F,"/etc/passwd") || die "Better not log out!";
$try = 512;
{
	seek(F,-$try,2);
	$last = $this = "";
	<F>; # skip to next newline
	$last = $this while $this = <F>; # read until we see eof
	last if $last; # good run
	$try += 512; # bigger bite backward
	redo; #once more
}
print ((split(/:/,$last))[2]); # why add zero?  foo!

"Just another Perl hacker,";seek(DATA,1,0);read(DATA,$_,25);print;__END__
--
Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
merlyn@reed.edu (guest account) merlyn@ora.com (better for permanent record)
cute quote: "Welcome to Portland, Oregon -- home of the California Raisins!"