[8832] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2449 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 28 22:04:25 1998

Date: Tue, 28 Apr 98 19:00:28 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 28 Apr 1998     Volume: 8 Number: 2449

Today's topics:
    Re: a way to remove files? <tchrist@mox.perl.com>
    Re: ANNOUNCE: Perl Builder IDE Now Available <grinch@whoville.com>
    Re: ANNOUNCE: Perl Builder IDE Now Available <rootbeer@teleport.com>
    Re: Child in separate window?  How? (Jason Gloudon)
    Re: Defending Perl <tchrist@mox.perl.com>
    Re: Help needed with gostscript (Martien Verbruggen)
    Re: Help Sending MIME attachment (brian d foy)
    Re: Help: carriage return errors <sowmaster@juicepigs.com>
    Re: How to read command line literally? (Gurusamy Sarathy)
    Re: How to read command line literally? (Jason Gloudon)
    Re: How to read command line literally? (Martien Verbruggen)
    Re: How to read command line literally? <tchrist@mox.perl.com>
    Re: How to read command line literally? <tchrist@mox.perl.com>
    Re: Initializing hash with null array: which is best? (brian d foy)
    Re: Initializing hash with null array: which is best? <zenin@archive.rhps.org>
        makemake, makedepend, etc... kin@c-cube.com
    Re: Matts Script Archive-WWWBoard-FrontPage-Suddenly No <grinch@whoville.com>
    Re: Permutations in hashes make Perl hurt (Gurusamy Sarathy)
    Re: Permutations in hashes make Perl hurt (Ilya Zakharevich)
    Re: QRe: == vs. eq (Jason Gloudon)
    Re: Question about Pattern Matching <danboo@negia.net>
    Re: rename funciton (was: Re: Dummie question) <rootbeer@teleport.com>
    Re: Submit <grinch@whoville.com>
    Re: Submit <grinch@whoville.com>
    Re: Syntax to make my hit counter work? <grinch@whoville.com>
    Re: uninitiated value warning... why? (Jason Gloudon)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 29 Apr 1998 01:33:28 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: a way to remove files?
Message-Id: <6i6018$puv$4@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, shane michael harwood <sharwood@cs.uiowa.edu> writes:
:is there a way from within a perl script to remove files?

I wish I knew why no one ever reads the perlfunc manpage.

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


    "A journey of a thousand miles continues with the second step." --Larry Wall


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

Date: Tue, 28 Apr 1998 20:59:33 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: ANNOUNCE: Perl Builder IDE Now Available
Message-Id: <6i5t40$4is@fridge.shore.net>

Craig Berry wrote in message <6i5q4s$ku1$2@marina.cinenet.net>...

>Does it handle all flavors of string quoting?

Just the easy cases. :-(

>For that matter, how well does it do pulling out comments?  Will it parse
>
>  $foo =~ s#wah#woo#ig;  # Fix the wahs
>
>correctly?

Nope. It marks a comment starting with the first # it sees on a line.
Although, in this case, knowing how the editor works, you could probably
work around this easily by just using a different delimiter.

Like I mentioned, though, my favorite feature is the ability to write editor
macros in Perl. It uses whatever installation you have, either ActiveState
or GS, and they tell me that you can use whatever modules you need, and/or
use system() to call external programs.

I haven't tried using modules in scripts yet, but if it works as advertised,
I can think of a dozen different ways to use it offhand. If the networking
modules work, you could use it to test & debug CGI scripts locally, and then
run a macro to FTP any changed files to the server. If Tk works... :-)

If they price this reasonably, it will probably be a good seller for them.
At any rate, the current version is a free beta and a small download, so
there's no risk in checking it out. I hope they don't pull a stunt like
ActiveState did with their debugger, though, and cripple it with a lame
license and heavy pricetag.

-grinch


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

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





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

Date: Wed, 29 Apr 1998 01:19:27 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: ANNOUNCE: Perl Builder IDE Now Available
Message-Id: <Pine.GSO.3.96.980428181822.3378D-100000@user2.teleport.com>

On 28 Apr 1998, Ilya Zakharevich wrote:

> > Of course, there's no way to always get the colors correct unless you have
> > an error-proof way of parsing Perl - which no one has yet invented. :-)
> 
> Hmm, did you check CPerl lately?  

Not me, personally. But people who use it tell me that it's easily
confused by quote marks within patterns. Have you fixed that bug?

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 29 Apr 1998 01:17:52 GMT
From: jgloudon@hyssop.bbn.com.bbn.com (Jason Gloudon)
Subject: Re: Child in separate window?  How?
Message-Id: <slrn6kcvsh.lhf.jgloudon@hyssop.bbn.com>

k y n n <NOSPAMkEynOn@panix.comNOSPAM> wrote:
>Does anyone know how to fork out a child process with its own separate
>X window, so that keyboard input will go to the parent or the child
>depending on which window has the focus?

fork() 
then
exec "xterm -e 'command'"

--
Jason Gloudon


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

Date: 29 Apr 1998 01:26:21 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Defending Perl
Message-Id: <6i5vjt$puv$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, abigail@fnx.com writes:
:- For some reason, it thinks putting man pages in 2 different 
:  places is a feature.

That one really steams me up.

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


    "It's okay to be wrong temporarily." --Larry Wall


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

Date: 29 Apr 1998 00:56:57 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Help needed with gostscript
Message-Id: <6i5tsp$lh4$8@comdyn.comdyn.com.au>

[Why did you post this to comp.lang.perl.modules? Followup set]

In article <6i4d3b$a5e$1@news.huji.ac.il>,
	evgenya@vafla.cs.huji.ac.il (Evgenya Borisenko) writes:
> Hi,
> 
> I need help on how to embed perl's variables into gostscript files so
> they'd appear like normal lines when i print this files.

I am not entirely sure what you're asking... 

[You do realise that Ghostscript just processes PostScript files,
right?]

Are you:

- creating PostScript files, and need to know how to print the
  contents of perl variables?

  # open the output, using something like PSF as a file handle
  $var = "something goes here";
  print PSF "This is \$var: $var\n";

- editing PostScript files, and need to replace parts of it in perl?

  See the open(), close() and print builtins.

  # perldoc -f print
  # perldoc -f open

  See the perlop documentation, look for I/O operators.

  read the faq, specifically part 5

  # perldoc perlfaq
  # perldoc perlfaq5

- doing anything else?

  Post some code. Let us see what you're trying to do. Help us out, so
  we can help you.

  Post to comp.lang.perl.misc next time.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Tue, 28 Apr 1998 21:11:54 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Help Sending MIME attachment
Message-Id: <comdog-ya02408000R2804982111540001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6i5p9d$ktp$1@hirame.wwa.com>, aadlpsw@wwa.com (Samuel G. Williams) posted:

>THE QUESTION:  What codes need to be added to a stock text file to cause
>it to be interpreted as a MIME attachment and can these codes be easily
>embedded within an email message and run through a normal unix mail
>program.  

you can use the various Perl Mail:: and MIME:: modules, but if you have
specific questions about MIME itself you may have better luck in a 
newsgroup devoted to the subject.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: Tue, 28 Apr 1998 21:54:38 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: Phil <phillipu@home.net>
Subject: Re: Help: carriage return errors
Message-Id: <3546885E.7492@juicepigs.com>

Phil wrote:
> 
> Hi:
> 
> I recently installed a shopping cart script. I checked the syntax from the
> command line and got an aoky.
> 
> When I tried to execute the script in the shell, it ran about half way
> through and gave me this error:

What are your definitions for command line and shell?
 
> "Illegal chracter \015
> (carriage return) at ./Library/Web_store.setup.frames.javascript 
> line 4
>
> Then it tells me "Maybe you didn't strip carriage returns after a network
> transfer.

Did you strip carriage returns after a network transfer?
Your error line mentions javascript, perhaps it is the javascript
causing the error?

> Well, I uploaded the file in ASCII mode. I've tried everything.

Have you checked perldiag to see what it says about this error?
Have you checked the FAQs?
Did you get documentation with the script?
Have you tried asking the guy that wrote the script how to fix it?

> Have you run into this before?

Nope and I don't plan to in the near future.

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


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

Date: 29 Apr 1998 01:25:23 GMT
From: gsar@engin.umich.edu (Gurusamy Sarathy)
Subject: Re: How to read command line literally?
Message-Id: <6i5vi3$njv@srvr1.engin.umich.edu>

  [ mailed and posted ]

In article <6i5o31$l6s$3@comdyn.comdyn.com.au>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>(Also: note that the GS port of perl is not the 'standard
>distribution'. It behaves very much like it, but it's patched here and
>there.

Hunh?  Can I ask how you arrived at that conclusion?  The perl in
bindist04 was built from pristine 5.004_02 sources (no less, no more)
and the README says so.  There are some "third-party" modules that
needed patching, for which you'll find the patches in there also.

No information is better than misinformation, y'know. :-)

>       And that port also can be configured to do globbing
>automatically)

True.

 - Sarathy.
   gsar@umich.edu



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

Date: Wed, 29 Apr 1998 01:33:14 GMT
From: jgloudon@hyssop.bbn.com.bbn.com (Jason Gloudon)
Subject: Re: How to read command line literally?
Message-Id: <slrn6kd0pb.lhf.jgloudon@hyssop.bbn.com>

Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
 .
 .
>Command line is the most important element of IPC, and the fact that
>it is unreachable is one of the few stupidities of the *nixish
>paradigm.

Everything has its plusses and minuses. Consistent behaviour is the plus of
having one's shell do globbing. Having to remember which program did or didn't
do globbing becomes very tedious. How often did I wished dir *.txt worked the
same way as more *.txt ? That aside, if file globbing is a nuisance, you can
bypass the shell or use a shell that doesn't do globbing (though i don't know of
one). You are not forced to use the shell for IPC in any way.

--
Jason Gloudon


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

Date: 29 Apr 1998 01:02:29 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How to read command line literally?
Message-Id: <6i5u75$lh4$10@comdyn.comdyn.com.au>

In article <6i5siu$2lm$1@mathserv.mps.ohio-state.edu>,
	ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> [A complimentary Cc of this posting was sent to Martien Verbruggen
> <mgjv@comdyn.com.au>],
> who wrote in article <6i5o31$l6s$3@comdyn.comdyn.com.au>:
> 
>> how it should be. Problem here is that DOSish systems come with a
>> braindead shell.
> 
> In some respect DOSish shells are braindead indeed.  But not in this
> one: the fact that DOSish shells do not mangle the command line is the
> great advantage - comparing the braindead *nixish behaviour.

You're right. The 'braindead' adjective was entirely subjective. I
guess it all depends on what you're really used to. I have become so
used to automatic expansion, that I take it for granted, as well as
using quotes to prevent it. Which is better, is arguable, and better
left to another time :)

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: 29 Apr 1998 01:29:42 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to read command line literally?
Message-Id: <6i5vq6$puv$3@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
:But if it wants, it may examine the command line and find what user
:wanted, so there is no braindead backslashitis and quotitis for
:something like
:	  find . -name *.blah

Oh, good, so now I have to keep track of which command do or do
not quote or glob.  No fricking thank you.  I didn't like CP/M
then, and I don't like it now.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    Q. Why is this so clumsy?
    A. The trick is to use Perl's strengths rather than its weaknesses.
            --Larry Wall in <8225@jpl-devvax.JPL.NASA.GOV>


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

Date: 29 Apr 1998 01:28:54 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to read command line literally?
Message-Id: <6i5vom$puv$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
:one: the fact that DOSish shells do not mangle the command line is the
:great advantage - comparing the braindead *nixish behaviour.

Pure bull.  Globbing should be in the shell, not the application.
This is one of the great lessons that Unix has taught us.
Next thing you know you'll be telling me you want canonical mode
in the application not the line driver.

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

    pos += screamnext[pos]  /* does this goof up anywhere? */
        --Larry Wall in util.c from the perl source code


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

Date: Tue, 28 Apr 1998 21:10:20 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Initializing hash with null array: which is best?
Message-Id: <comdog-ya02408000R2804982110200001@news.panix.com>
Keywords: from just another new york perl hacker

In article <Es5EwK.7y5@unx.sas.com>, sherman@unx.sas.com (Chris Sherman) posted:

>I want to initialize a complex data structure element with a 
>null array.  

>$fred->{"thing"} = [()];
>@{$fred->{"thing"}} = ();

i kinda like

   $fred->{"thing"} = [];

but salt to taste:

   #!/usr/bin/perl
   
   $hash{'[]'}    = [];
   $hash{'[()]'}  = [()];
   @{$hash{'()'}} = ();
   
   foreach my $method (keys %hash)
      {
      print "$method: ", ref $hash{$method}, ", index = ",
         $#{$hash{$method}}, "\n";
      }
      
   __END__
   
   []: ARRAY, index = -1
   (): ARRAY, index = -1
   [()]: ARRAY, index = -1

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: 29 Apr 1998 01:12:01 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Initializing hash with null array: which is best?
Message-Id: <893812751.840437@thrush.omix.com>

Chris Sherman <sherman@unx.sas.com> wrote:
: Are the following two lines the same?

	Yes.

: Do they get the job done as I expect?

	Yes.

: And which is best in terms of good programming practice?
: $fred->{"thing"} = [()];
: @{$fred->{"thing"}} = ();

	I like the first one, with a cavent:

	$fred->{thing} = [];  # no need for the (), but they don't hurt

: (I want element "thing" of the anonymous hash pointed to by $fred to contain
: a ref to a null array which I'm about to fill).

	Yep.

: Also, before I really thought about it, I put down:
: $fred->{thing} = ();
: Of course this didn't work as I expected.  In fact, if you do a "if
: defined..."  on it, it returns false.  Perl, however, liked it (with
: warnings on), so what did it really try to do?

	It would try to assign the last value of the list () to
	$fred->{thing}, but since there is none it gets assigned undef.
	If you had said:

	$fred->{thing} = ('foo', 'bar', 'cat', 'dog');

	$fred->{thing} would have equaled 'dog'.  I'm not sure where this
	is documented, and I for one don't think it makes any sense
	considering that "('foo', 'bar', 'cat', 'dog')" is a list (albeit
	a list constant) that is being evaluated in scalar context so it
	really should return 4, not 'dog'.  It gets even odder when:

	($fred->{thing}) = ('foo', 'bar', 'cat', 'dog');

	sets $fred->{thing} to equal 'foo'...even if you call scalar() on
	the thing to try and force it:

	$fred->{thing} = scalar (('foo', 'bar', 'cat', 'dog'));

	Hmm, maybe I should call it a bug and submit it already...

: My guess:  Nothing.  :-)  I mean, you can't assign an array itself to
: a hash element, right?  (...only the ref to one).

	Yep.

: Thanx for any help...  (And pointers to perlfaq's welcome.  I tore up on 
: perlfaq4 and didn't find anything relavent.  Could be wrong, though.)

	Probably better with the man pages for this one.  In particular,
	perlref, perldsc, and perllol.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: 28 Apr 1998 18:08:13 -0700
From: kin@c-cube.com
Subject: makemake, makedepend, etc...
Message-Id: <6i5uht$8d3@co-op.newsguy.com>

Are there such tools or similar written in perl available?

I'm interested in building a simple make replacement tool where
given some include path and source (C++) directories, the tool automatically
compiles the needed binaries.

I'm mainly interested in using this tool on NT.

-kin


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

Date: Tue, 28 Apr 1998 21:41:25 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: Matts Script Archive-WWWBoard-FrontPage-Suddenly Not Working
Message-Id: <6i5vig$7cs@fridge.shore.net>

Bob Confer wrote in message <6i5mvc$drs$1@news1.i1.net>...

>I have been running the wwwboard script from Matt's Script Archive for
>sometime now through my ISP on a Unix server.

Good Idea.

>Anyway, I recently purchased FrontPage and decided to
>start using it to publish my web pages.

Bad Idea.

>I've since transferred all of my files to the new server and everything
>appeared to be working correctly, but I was mistaken.

Why aren't I surprised?

In general, if you're using FrontPage, you can expect it to randomly stomp
all over your site and do pretty much what it darn well pleases to files
that don't belong to it.

Your best bet, aside from getting rid of FP altogether, is to use the
discussion form 'bot that comes with it. That'll be a lot easier than
convincing it to work with the rest of the world.

It's much more likely to be a problem with FrontPage than with the scripts.
When any working system breaks down, you look to see what changed to cause
the problem. The biggest change to your site, and therefore most likely
cause of the problem, was the addition of FP to the picture.

-grinch

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

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





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

Date: 29 Apr 1998 01:51:31 GMT
From: gsar@engin.umich.edu (Gurusamy Sarathy)
Subject: Re: Permutations in hashes make Perl hurt
Message-Id: <6i6133$p6d@srvr1.engin.umich.edu>

  [ mailed and posted ]

In article <6i3qq2$k58@cello.hpl.hp.com>,
Tom Rokicki <rokicki@cello.hpl.hp.com> wrote:
>If the keys of a hash are permutations of a string (or, if the length
>of the string plus the sum of the characters in the string is a
>constant across the keys of a hash) then Perl essentially uses a
>single linked list (only one bucket is filled) as the attached code
>shows; run it and watch Perl go quadratic!

Indeed, and I've known of a related problem for over two years.  Repeated
strings (of the form "foofoo", "foofoofoofoo" etc.) make perl's hashes
behave pathalogically.  Watch how long this takes, and observe the final
byte of the list of hashnums to explain behavior.

  #!/usr/bin/perl -l
  # repeating strings (powers of two) are inhibiting hsplit() from ever
  # happening
  $f = "aaa"; for (1..10000) { $f++; $h{$f x 2} = $_; } print scalar(%h);
  undef %h;
  $f = "aaa"; for (1..10000) { $f++; $h{$f x 4} = $_; } print scalar(%h);
  undef %h;
  $f = "aaa"; for (1..10000) { $f++; $h{$f x 8} = $_; } print scalar(%h);
  undef %h;
  
  sub perlhash {
    my $hash = 0;
    for (split //, shift) {
      $hash = (($hash << 5) + $hash);
      $hash += ord($_);
    }
    return $hash;
  }
  
  $f = "aa"; for (1..20) { $f++; printf "%08x\n", perlhash($f); }
  $f = "aa"; for (1..20) { $f++; printf "%08x\n", perlhash($f x 2); }
  $f = "aa"; for (1..20) { $f++; printf "%08x\n", perlhash($f x 3); }
  $f = "aa"; for (1..20) { $f++; printf "%08x\n", perlhash($f x 4); }
  $f = "aa"; for (1..20) { $f++; printf "%08x\n", perlhash($f x 8); }

I'd say we ought to be a little smarter about growing buckets when
the number of entries gets abnormally high wrt to number of buckets.

The "Dragon Book" has a hashpjw() function that they said behaves well
for most cases.  I wonder how much performance we'd loose with that
for the common cases.

 - Sarathy.
   gsar@umich.edu



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

Date: 29 Apr 1998 01:56:17 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Permutations in hashes make Perl hurt
Message-Id: <6i61c1$c1m$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Mark-Jason Dominus
<mjd@op.net>],
who wrote in article <6i5tu4$1nu$1@monet.op.net>:
> 33 is fast because it has two set bits.  Any number with two set bits
> has bad behavior for permutations like that Tom showed.

> 37 would still show poor behavior for permutations, but the behavior
> would be better than 33.  Every 4th bucket would get populated instead
> of every 8th bucket.  For good behavior on permutations, the number
> you want to pick has the form 4N+3.  Such numbers appear below in the
> `best' column:

Wrong.  Multiplicative group mod 8 is not cyclic, it has 4 elements
but any element squared is 1.  Thus any odd residue mod 8 which *is
notn 1* gives the same performance.

> But the other tradeoff is tmie to compute the value.  Mutliplying by
> 33 is fast, as is multiplication by any number of the form 2**N+1 or
> 2**N-1.
> 
> Time to multiply by:
> 	3, 5, 7, 9, 15, 17, 31, 33:  2 instructions
> 
> 	11, 13, 19, 21, 23, 25, 27:  4 instructions
> 	29, 35, 37, 39, 41, 45:	     4 instructions
> 
> 	43:			     6 instructions
> 
> This is based on looking at the output of gcc -O6 -S on a mumble
> mumble processor; it is likely that these results would hold for any
> processor, because the optimizations are just what you expect:
> X*3 becomes (X<<1)+X, and X*39 becomes (((X<<2)+X)<<3)-X

I would thing that contemporary processor multiply in one instruction,
do not they?

Ilya


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

Date: Wed, 29 Apr 1998 01:22:38 GMT
From: jgloudon@hyssop.bbn.com.bbn.com (Jason Gloudon)
Subject: Re: QRe: == vs. eq
Message-Id: <slrn6kd05f.lhf.jgloudon@hyssop.bbn.com>

Greg Bacon <gbacon@cs.uah.edu> wrote:
>Greg
>-- 
>open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
>f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
>d2ac158c84c4ece4d22d1000118a8d5491000000
>EOF

You should use Compress::Zlib. :).

--
Jason Gloudon


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

Date: Tue, 28 Apr 1998 19:05:00 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Question about Pattern Matching
Message-Id: <3546609C.5535FC7@negia.net>

Sanjay Joshi wrote:
> 
> Hi,
>         I have an access log file with entries similar to:
> 
> usr47-dialup50.mix2.boston.mci.net - - [24/Apr/1998:14:18:28 -0500] "GET
> /~joshi/view.gif HTTP/1.0" 304 -
> 
> What I want to do is extract the date, in this case, 24. I want to know
> about 2 methods:
> 
> 1. Extract the date from the '[' to the '/'
> 2. Any other.
> 
> My way is below, I think it is pretty clumsy. Can anyone help?
> 
>                 if ($input =~ /\[[0-9]*\//) {
>                         $date =$&;
>                         $date =~/[0-9]+/;
>                         $date =$&;
>                         $mainday{$date} +=1;
>                 }

i assume that this is going on inside some sort of loop which iterates
over the lines of the log file. and also that it is working.

     $input =~ /\[(\d+)/ && $mainday{$1}++;

my changes/preferences:

  1. avoid use of $& as it slows down regex performance. instead use
     capturing parens and the captured string in $1.

  2. replace [0-9] with \d for readability.

  3. replace * with + to require at least one digit after the '['.

  4. get rid of trailing '/' since it confuses the appearance and isn't
     a digit anyway.

  5. change if BLOCK to boolean short-circuit.

  6. change += 1 to autoincrement.

hope this helps,

-- 
Dan Boorstein   home: danboo@negia.net  work: danboo@y-dna.com

 "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
                         - Cosmic AC


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

Date: Wed, 29 Apr 1998 01:33:43 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Abigail <abigail@fnx.com>
Subject: Re: rename funciton (was: Re: Dummie question)
Message-Id: <Pine.GSO.3.96.980428182514.3378E-100000@user2.teleport.com>

On 28 Apr 1998, Abigail wrote:

> Tom Phoenix (rootbeer@teleport.com) wrote on MDCCI September MCMXCIII in
> <URL: news:Pine.GSO.3.96.980428130928.15049m-100000@user2.teleport.com>:
> ++ On 28 Apr 1998, Abigail wrote:
> ++ 
> ++ > Tom Phoenix (rootbeer@teleport.com) wrote on MDCCI September MCMXCIII in
> ++ > <URL: news:Pine.GSO.3.96.980428101400.15049J-100000@user2.teleport.com>:
> ++ 
> ++ Was that a Tuesday? :-)
> 
> Did you post that on a Tuesday?

It happens that I did. But I didn't post it on 1701 September 1993, by any
stretch of the imagination.

> ++ > ++ On Mon, 27 Apr 1998, yary h. wrote:
> ++ > ++ 
> ++ > ++ > It always bothered me that Perl comes with "rename", but not "copy".
> ++ > ++ 
> ++ > ++ Give us a system call which does "copy", and we'll make a Perl built-in
> ++ > ++ which does so. :-)
> ++ 
> ++ > Could you point out the "grep" system call from me?
> ++ 
> ++ No, I couldn't. But you knew that, and were merely being sarcastic,
> ++ weren't you?
> 
> 
> Yes, I was merely pointing out that the reply "it isn't there because
> there's no system call" doesn't make much sense in Perl.

True, but irrelevant: That wasn't what I said. I was pointing out that
there is a rename call, so implementing rename is straightforward. There
isn't a copy system call; if you give us a system call which does that,
we'll easily make a Perl built-in that does so. The reverse, of course,
needn't hold (we could make a built-in even without a system call), but I
never said anything about that.

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 28 Apr 1998 21:49:12 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: Submit
Message-Id: <6i6012$7sr@fridge.shore.net>

Tom Phoenix wrote in message ...

>On Tue, 28 Apr 1998, Mikey Vaughan wrote:
>
>> Does somebody have a routine that allows the submit button to be
>> executed only once??
>
>Yes. You have the user install a browser which crashes upon clicking the
>submit button. :-)

Did someone finally get Netscape 5.0 to compile, then? ;-)


-grinch

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

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





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

Date: Tue, 28 Apr 1998 21:52:30 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: Submit
Message-Id: <6i6078$7ts@fridge.shore.net>

Mikey Vaughan wrote in message <354579F9.17E5@in.net>...

>Does somebody have a routine that allows the submit button to be
>executed only once??

Just say something like "If you click submit more than once I'll rip your
arm off and beat you with it." on your page. That will be just as effective
as anything you'll write in Perl.

:-)

-grinch

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

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





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

Date: Tue, 28 Apr 1998 21:55:17 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: Syntax to make my hit counter work?
Message-Id: <6i60cg$85e@fridge.shore.net>

Iain Gatt wrote in message <3544B7D2.41C6@strath.ac.uk>...

>        I'd appreaciate any help on how to get the hit counter
>operational.

wc -l /path/to/your/log/file

-grinch

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

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





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

Date: Wed, 29 Apr 1998 01:09:06 GMT
From: jgloudon@hyssop.bbn.com.bbn.com (Jason Gloudon)
Subject: Re: uninitiated value warning... why?
Message-Id: <slrn6kcvc3.lhf.jgloudon@hyssop.bbn.com>

Agent Hall <hallm4@cortez.sss.rpi.edu> wrote:
 .
>while(($h,$p) = split(/,,/,<FILE>) {
                                   ) missing here
> chomp($p); # is there a way to do this in the while statement?
 .
You could, but you'd have to force it.
 .
>I get a warning of an unintialized variable on the 

You get this when your lines don't split into at least 2 elements, as $p gets
set to undef.  A more perlish way of doing what you wanted would be:

while(<FILE>){
  chomp;
  ($h,$p) = split /,,/ , $_ , 2;
  if ( defined $h && defined $p){

  }
}

--
Jason Gloudon


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

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

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