[10376] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3969 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 14 01:07:25 1998

Date: Tue, 13 Oct 98 22:00:22 -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, 13 Oct 1998     Volume: 8 Number: 3969

Today's topics:
    Re: Are there any "perl.newbie" group or forum? (David Adler)
    Re: Better ways to do this? <jdf@pobox.com>
        Compressing and Uncompressing <rbank@csf.edu>
    Re: Compressing and Uncompressing (Martien Verbruggen)
    Re: Compressing and Uncompressing <eashton@bbnplanet.com>
    Re: Creating an unreadable perl executable <sugalskd@netserve.ous.edu>
    Re: encryption (Ronald J Kimball)
    Re: environment variables and persistency <dlhawley@user2.teleport.com>
    Re: exit code... (Mark-Jason Dominus)
    Re: exit code... <rick.delaney@shaw.wave.ca>
    Re: file modification <rbank@csf.edu>
    Re: Graphic Date (Billy Jacobs)
    Re: Graphic Date (brian d foy)
    Re: Install Fails - so does my attempt to get on newgro <jwb@tamu.edu>
    Re: Jiggers! It's Larry Lee.Lindley@bigfoot.com
    Re: Keeping a running list of the top n values retrieve (Sam Holden)
    Re: London.pm - Changed URL (David Adler)
    Re: London.pm - Changed URL <eashton@bbnplanet.com>
    Re: Need IP Address Sort Subroutine <garry@america.net>
    Re: Newbie needs help transposing two words in a file (Ronald J Kimball)
    Re: Perl Cookbook - is this the best perl book? (Michael J Gebis)
    Re: Perl Cookbook - is this the best perl book? (Sean McAfee)
    Re: Perl freezes when using special characters in HTML (Sam Holden)
    Re: Perl object - why does this fail? <dlhawley@user2.teleport.com>
    Re: prograMing: CompleteIndexSet <rick.delaney@shaw.wave.ca>
    Re: Proper Names and Mc etc. <Russell_Schulz@locutus.ofB.ORG>
        Sorry <rbank@csf.edu>
    Re: Sorry <eashton@bbnplanet.com>
    Re: TAB completion - how? <tpot@acsys.anu.edu.au>
        Variable From Forms <leotl@yahoo.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 14 Oct 1998 03:38:47 GMT
From: dha@panix.com (David Adler)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <7016c7$204@news1.panix.com>

On Tue, 13 Oct 1998 13:06:58 +0100, Joergen W. Lang
<jwl@_munged_worldmusic.de> wrote:

>David Adler <dha@panix.com> wrote:
>
>> On Sun, 11 Oct 1998 11:31:26 -0500, I R A Aggie
>> <fl_aggie@thepentagon.com> wrote:
>> 
>> >the Camel (Programming Perl), the Ram (Perl Cookbook) and the Owl 
>> >(Mastering Regular Expressions) books on my computer desk. Oh, and
>> >the Rommel Papers, for a little light reading. I guess you could call
>> >that the Tank Book... :)
>> 
>> For heaven's sake, don't give O'Reilly any ideas!  :-)
>> 
>> Dave, waiting for the Brannock Device book...
>
>mind you ! there's _germans_ reading this thread ;-))

Oh, my!  Why didn't you say something earlier???  ;)

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
The Inferno video is really in colour.


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

Date: 14 Oct 1998 04:28:23 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: Stacy Doss <stacy.doss@amd.com>
Subject: Re: Better ways to do this?
Message-Id: <m3vhlnnago.fsf@joshua.panix.com>

The best help I can give you is to lead you to the standard Benchmark
module, which will give you quantitative reasons to prefer one
algorithm over another.

   $ perldoc Benchmark

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Tue, 13 Oct 1998 21:23:12 -0700
From: "Robin Bank" <rbank@csf.edu>
Subject: Compressing and Uncompressing
Message-Id: <7015rb$slm$8@santaclara.santafe.edu>

IS there any way to use perl to decompress and compress .tar, .zip, .tar.gz
files....etc???

Thanks a lot,

Robin
******|
------| rbank@csf.edu
******|



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

Date: Wed, 14 Oct 1998 03:49:17 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Compressing and Uncompressing
Message-Id: <1bVU1.18$cu3.115006@nsw.nnrp.telstra.net>

In article <7015rb$slm$8@santaclara.santafe.edu>,
	"Robin Bank" <rbank@csf.edu> writes:
> IS there any way to use perl to decompress and compress .tar, .zip, .tar.gz
> files....etc???

You can call external programs, open pipes to them if necessary.

If you want modules to do the work, you should check out the modules
list on CPAN:

http://www.perl.com/CPAN/modules/00modlist.long.html

In this case, Section 17 might help. Compress::Zlib and Archive::Tar
seem to provide access to tar and gzipped files. Dunno if there's
anything out there for zipped files. I always just call the zip
program if I need to do any of that.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.       | enough features yet.
NSW, Australia                      | 


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

Date: Wed, 14 Oct 1998 04:26:07 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Compressing and Uncompressing
Message-Id: <3624255F.6B8DD35@bbnplanet.com>

Robin Bank wrote:

> IS there any way to use perl to decompress and compress .tar, .zip, .tar.gz
> files....etc???

Of course, have you read the FAQ?

e.

After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia.  - U. Eco -


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

Date: 14 Oct 1998 04:39:08 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: Creating an unreadable perl executable
Message-Id: <7019tc$6mc$1@news.NERO.NET>

Tom Phoenix <rootbeer@teleport.com> wrote:
: On Tue, 13 Oct 1998, brian d foy wrote:

:> >How do I make an unreadable perl executable, (even with root
:> >permissions) ? Is there some perl conversion program ?
:> 
:>    chmod 111 file.pl

: Or you could use zero for the mode, to get about the same effect. :-)

: I've never seen a system in which scripts (as opposed to binaries) could
: be (usefully) executable without being readable. That is to say, the perl
: binary still needs to be able to read the source in order to execute it.

: Is there a system on which this is useful?

Hmmm. I could see this being useful on VMS--you install the perl
executable with suitable privileges (SYSPRV or BYPASS come to mind) so it
has access to the script, and from there can decide whether it ought to
execute the thing.

It'd require a bit of extra hackage to the VMS bits of the core, since
right now it's not supported, (and if someone did go so far as to
install perl with privs, it wouldn't do any good, since the startup
code turns off any extra image privs to be safe, since we don't know
what to do with them) but I could see it being useful.

Actually, now that I think about this, it could be quite useful. Need to
turn on tainting too, I expect. And only leave the privs on long enough to
actually open the script, and only if it's not STDIN. Might be an
interesting precursor to running scripts with extra privs. Probably
require an inner-mode PERL_ROOT and PERLSHR, too.

Something interesting to think of in my spare (yeah, right!) time, I
guess.

					Dan


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

Date: Tue, 13 Oct 1998 22:48:59 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: encryption
Message-Id: <1dguz7u.1xvwu5l16u2l4gN@bos-ip-2-209.ziplink.net>

Joergen W. Lang <jwl@_munged_worldmusic.de> wrote:

> #!/usr/bin/perl -w
> 
> $salt   = "FO";
> $string = "something longer than eight chars";
> $length = length $string;
> 
> for ($i = 0; $i < $length; &check)
> {
>     $substring = substr $string, $i, 8; 
>     $temp = crypt $substring, $salt;
>     push @crypted, $temp;
> }
> 
> $all = join "", @crypted;
> print $all;
> 
> sub check
> {
>     if ($i < $length) { $i += 8; }
>     else { $i += $length % 8; }
> }

The check subroutine is unnecessary.  If $i isn't less than $length, the
for loop is going to terminate anyway.

This gives the same result:

#!/usr/bin/perl -w

$salt   = "FO";
$string = "something longer than eight chars";
$length = length $string;

for ($i = 0; $i < $length; $i += 8)
{
    $substring = substr $string, $i, 8; 
    $temp = crypt $substring, $salt;
    push @crypted, $temp;
}

$all = join "", @crypted;
print $all;
__END__


-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Wed, 14 Oct 1998 04:36:14 GMT
From: "David L. Hawley" <dlhawley@user2.teleport.com>
Subject: Re: environment variables and persistency
Message-Id: <2TVU1.25$es1.6260@news.teleport.com>

Amity Warren <awarren@inprise.com> wrote:
: This is a multi-part message in MIME format.
: --------------BE90C2F4B75268675C8E62FF
: Content-Type: text/plain; charset=us-ascii
: Content-Transfer-Encoding: 7bit

: Hello,

: I would like to set an environment variable when running my Perl program
: under Windows 98, and have that environment variable remain 
: set even after the Perl program has finished running.

: Below is a small program which appears to set the MyEnvVar while 
: the script is running, however after it exits, MyEnvVar is gone.


: $ENV{"MyEnvVar"} = "MySetting";

: open (SETFILE, ">settings_file") || 
: 	die "cannot open settings_file: $!";

: foreach $key (sort keys %ENV) {
: 	print SETFILE "$key=$ENV{$key}\n";
: }


This is exactly what one would expect under UNIX, and I suspect under DOS
as well.  The environment variables are set in the context of the current
program and would be inherited by spawned programs, but once the current
program terminates, the context is gone.  Maybe you can set the
environment in a .bat file?



-- 
David L. Hawley       D.L. Hawley and Associates    1(503)274-2242
Software Engineer                            dlhawley@teleport.com 


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

Date: 13 Oct 1998 21:38:50 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: exit code...
Message-Id: <700vba$4fd$1@monet.op.net>

In article <700si4$nv7$1@agate.berkeley.edu>,
Alan Su <alsu@soda.CSUA.Berkeley.EDU> wrote:
>basically, the exit codes are being scaled by a factor of 256.  now i
>know i'm doing something stupid, but what is it?  thanks!


Nothing stupid.  The status you get from `wait' isn't just the exit
code.  It's a 16-bit quantity, laid out like this:

	15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
	| Exit code           |CD|Signal number       |

The exit code is in bits 8-15.  Bit 7 is set if the process dumped
core when it exited, and bits 0-6 contain the signal number of the
signal that killed the process; 0 if it wasn't killed by a signal.
(Signals are sent with the `kill' function.)

That means that to get the exit code; you need to use something like this:

	$exit_code = $? >> 8;

A complete analysis of the exit status might look like this:

	$exit_code = ($? & 0xff00) >> 8;
	$core_dump = ($? & 0x0080);
	$signal_no = ($? & 0x007f);

	if ($signal_no) {
	  print "Process killed by signal $signal_no";
	  print $core_dump ? " (core dumped)\n" : "\n";
	} else {
	  print "Process exited with status $exit_code\n";
	}



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

Date: Wed, 14 Oct 1998 02:13:20 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: exit code...
Message-Id: <36240A57.1F6E75F6@shaw.wave.ca>

[posted & mailed]

Alan Su wrote:
> 
> i'm confused about the argument to exit.

[snip code and results]

> basically, the exit codes are being scaled by a factor of 256.  now i
> know i'm doing something stupid, but what is it?  thanks!

Not looking up $? in the docs, of course.  This would tell you it's
expected to behave that way.

perldoc perlvar

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Tue, 13 Oct 1998 21:12:41 -0700
From: "Robin Bank" <rbank@csf.edu>
Subject: Re: file modification
Message-Id: <7015r8$slm$7@santaclara.santafe.edu>

I would say that the best way to do this is to make a new file with the
changes you want made and then copy it over to your new one...

LAter,
Robin
******|
------| rbank@csf.edu
******|


----------
In article <36238284.AABB74FF@tinet.ie>, Edouard Ouin
<Edouard.Ouin@tinet.ie> wrote:


>hi,
>
>I need to known what's the simplest way to modify the content of  file,
>ie modify a line, delete a line.
>
>Thank's
>
>Ted
>


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

Date: Wed, 14 Oct 1998 02:19:18 GMT
From: nomail@netscape.com (Billy Jacobs)
Subject: Re: Graphic Date
Message-Id: <3624098e.1430096@news.nassaulibrary.org>

On Tue, 13 Oct 1998 16:33:00 GMT, Tom Phoenix <rootbeer@teleport.com>
wrote:

>> I am looking for a simple script 
>
>If you're wishing merely to _find_ (as opposed to write) programs,
>-- 
>Tom Phoenix       Perl Training and Hacking       Esperanto
>Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>

I have searched through almost every page I could find through yahoo,
to no avail.  I have found plenty of scripts which will show the date,
but in text format.  I have been playing around with an existing perl
script (text formatted date), and it seems simple enough.  However,
converting it so that it loads graphics is a little bit more complex
for me, since I really don't know perl.  Thats why I was wondering if
anyone either knew of an existing script, or could maybe spend a few
minutes helping me out.  Either way, I would be more than grateful!  

Billy



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

Date: Tue, 13 Oct 1998 23:07:04 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Graphic Date
Message-Id: <comdog-ya02408000R1310982307040001@news.panix.com>
Keywords: from just another new york perl hacker

In article <3624098e.1430096@news.nassaulibrary.org>, nomail@netscape.com (Billy Jacobs) posted:

>On Tue, 13 Oct 1998 16:33:00 GMT, Tom Phoenix <rootbeer@teleport.com>
>wrote:
>
>>> I am looking for a simple script 
>>
>>If you're wishing merely to _find_ (as opposed to write) programs,

>I have searched through almost every page I could find through yahoo,
>to no avail.  I have found plenty of scripts which will show the date,
>but in text format.  I have been playing around with an existing perl
>script (text formatted date), and it seems simple enough.  However,
>converting it so that it loads graphics is a little bit more complex
>for me, since I really don't know perl.  Thats why I was wondering if
>anyone either knew of an existing script, or could maybe spend a few
>minutes helping me out.

find a graphical hit counter.  modify it to return the value of
localtime rather than the hit count.

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 needs volunteers! <URL:http://www.pm.org/to-do.html>


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

Date: 14 Oct 1998 01:20:28 GMT
From: Jeffrey William Baker <jwb@tamu.edu>
Subject: Re: Install Fails - so does my attempt to get on newgroup
Message-Id: <700u8s$5j1$1@news.tamu.edu>

In article <36242064.74F6@erols.com>,
Dennis Cook  <denniscook@erols.com> wrote:
>1) Third attemp to enter newsgroup - if someone knows why my messages
>disappear, please email me: denniscook@erols.com
>
>2) I'm trying to install perl on winnt 4.0 that I downloaded from:
>ftp.activeware.com/Perl-Win32/ntperl/perl5.001m/CurrentBuild/110-i86
>The download went ok, the unzip went ok - I did it in directory
>c:\program files\perl5.  I started a command prompt window, cd to that
>directory, and type 'install'.  Stops immediately with error msg:
>"Can't locate NT.ph in @INC (didyou run h2ph?) at install.bat line 35."
>
>The file NT.ph is there, and I don't know what h2ph is.  Any help much
>appreciated...

You are trying to install a stone age product.  Perl 5.001 is ancient,
as is activeware build 110.  Go to their homepage and download a
version that isn't a rotting carcass.

Jeffrey


-- 
Jeffrey William Baker 
jwb@tamu.edu


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

Date: Wed, 14 Oct 1998 03:10:39 GMT
From: Lee.Lindley@bigfoot.com
Subject: Re: Jiggers! It's Larry
Message-Id: <7014nf$kgm$1@nnrp1.dejanews.com>

In article <3622FB9B.5E86DBFD@mkt2mkt.com>,
  madame philosophe <mp@mkt2mkt.com> wrote:
> Hi,
>
> FYI
>
> Rumor has it that Larry Wall is featured at the Salon Site
> http://www.salonmagazine.com
>
> I also happened to see another interview of Larry at a new web development
> site called
> http://www.devhead.com
> I just glossed over it... I'll read it later tonight.
> It's a ZDNet site, however the interview was somewhat technical (read NOT
FLUFFY)
> and he gives some good insights for the future of Perl and what's coming with
5.005
>
> pause...pause
>
> But then all of you probably know this already!!!
>
> ------
>
> madame philosophe

I saw the Salon article and thought it was general and interesting
enough for less than technical readers; thus I sent it to a local
manager who had recently heard, and commented on some fluff on
tcl vs. perl.

I could not find the "devhead" article you mentioned.  I looked around
and found nothing, then tried a search on "larry wall" and found only
references for articles in September.  Were you referring to those?

--
// Lee.Lindley@Bigfoot.com
// Be nice.  It isn't that hard to do and it
// makes people happy.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 14 Oct 1998 01:20:38 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Keeping a running list of the top n values retrieved
Message-Id: <slrn727v35.t1s.sholden@pgrad.cs.usyd.edu.au>

On 13 Oct 1998 02:07:27 GMT, Abigail <abigail@fnx.com> wrote:
>Sam Holden (sholden@pgrad.cs.usyd.edu.au) wrote on MDCCCLXIX September
>MCMXCIII in <URL:news:slrn7256g4.7tg.sholden@pgrad.cs.usyd.edu.au>:
>++ On 12 Oct 1998 17:16:55 GMT, Abigail <abigail@fnx.com> wrote:
>++ 
>++ I still can't see the constant being significant. If it is I can just impleme
>++ my own insert sub that does O(m) swaps in the same way as a heap does O(log m
>
>*You* made the constant significant by comparing 2 methods, plugging in
>some values for n, m, and finding a dimensionless ratio.

I realise this isn't a wise thing to do... However, since in the original
post the value of m was small (20 if I recall correctly), and both
algorithms could be implemented with the same method (comparing two
elements in an array and swapping them if they are in the wrong order)
with the only difference being the better algorithm was O(log m) and the
brain-dead one O(m). I would maintain the constants are very similar
indeed.


>
>++ >If you knew what I said, then why do you still question it?
>++ 
>++ Because I wasn't sure if this particular way of constructing a heap would hav
>++ special properties and thus left it open for someone to mention any. There 
>++ aren't any, however, since that would give a comparison sort algorithm of les
>++ than O( n log n) which is a little impossible...
>
>
>Which is what I said.

Except that when I asked the question I had only advanced as far as the
first sentence in my thoughts, and thus hadn't considered the obvious
implication of sorting time. Your response made me see the obvious
second sentence.

-- 
Sam

comments on data are usually much more helpful than on algorithms
	--Rob Pike


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

Date: 14 Oct 1998 03:36:02 GMT
From: dha@panix.com (David Adler)
Subject: Re: London.pm - Changed URL
Message-Id: <701672$204@news1.panix.com>

On Tue, 13 Oct 1998 23:07:29 GMT, Elaine -HappyFunBall- Ashton
<eashton@bbnplanet.com> wrote:

>brian d foy wrote:
>
>> i was under the impression that you got the "free beer" at any Perl
>> Monger event for the donation ;)
>
>A monger? Buy me a beer? You funny! 

Hey, I would have bought you a beer last time you were in nyc, but I
felt that I should not contribute to you running aground in the wilds
of Jersey... :-)

>What do I get for an Ultra? :) 

Try us!  :-)

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Free Randal Schwartz!  <http://www.rahul.net/jeffrey/ovs/>
(ok, maybe not free, but competitively priced!)


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

Date: Wed, 14 Oct 1998 04:20:29 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: London.pm - Changed URL
Message-Id: <3624240D.E9819081@bbnplanet.com>

David Adler wrote:

> Hey, I would have bought you a beer last time you were in nyc, but I
> felt that I should not contribute to you running aground in the wilds
> of Jersey... :-)

Er, Philly is in Pennsylvania the last I checked darling :).

> Try us!  :-)

Quod erat demonstrondem. :) 

e.

After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia.  - U. Eco -


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

Date: Wed, 14 Oct 1998 03:01:21 GMT
From: "Garry T. Williams" <garry@america.net>
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <36241459.D0CB328B@america.net>

Joe Williams wrote:
> 
> I still don't think I'm interpreting correctly the binary structure produced
> by pack with C4 used on IP octets, as in: pack("C4",199,77,210,67) .
> 
> I thought this would produce the binary equivalent of the IP address, but it
> doesn't seem to. If it did, the bintodec function below should convert the
> structure to the decimal equivalent of the binary address, which by my
> calculations is 3,343,766,083, and that doesn't happen.
>
> The reason is, I think, that the string with the IP octets, 199 77 210 67 is
> being packed as ASCII characters, not as the binary equivalent of the
> decimal numbers 199, etc.
> 
> All this must seem obvious to programs who are used to the pack function,
> but I'm still looking for the light switch here!
> 
> What is the easiest way to take a look at the packed structure in binary?

Here's a code snippet that prints it in dotted quad, hexidecimal, and
decimal: 

	#!/opt/perl/bin/perl -w
	use strict;
	use Math::BigInt;

	my  $addr  = "199.77.210.67";
	my  $iaddr = pack("C4", split(/\./, $addr));
	my  $i     = new Math::BigInt(0);

	$i = 199*256**3 + 77*256**2 + 210*256 + 67;

	print "\$addr  = $addr\n";
	print "\$iaddr = ", unpack("H*", $iaddr), "\n";
	print "\$i     = $i\n";

I ran this on: 

	$ uname -a
	SunOS atl1 5.5.1 Generic_103640-18 sun4u sparc SUNW,Ultra-2
	$ perl -v

	This is perl, version 5.004_04 built for sun4-solaris

	Copyright 1987-1997, Larry Wall

	Perl may be copied only under the terms of either the Artistic License
or the
	GNU General Public License, which may be found in the Perl 5.0 source
kit.

and it produced the following output: 

	$ ./z
	$addr  = 199.77.210.67
	$iaddr = c74dd243
	$i     = 3343766083
	$

I used the BigInt module because the IP address *could* overflow an
integer on a machine that represents an integer in four byte words. 
Indeed, your example is above the maximum positive integer on such
machines (since it's an IP address above 127.255.255.255).  

I believe that the hex value reveals the binary data precisely.  It's
just a four byte string that, if interpreted as an unsigned integer, is
equal to the decimal representation above.  

(I couldn't understand what bintodec was doing, so I thought this may
help to elucidate.)  

-Garry Williams
 
> It looks like pack with the C4 template is the standard way Perl uses to
> convert IP octets into something manageable, and as I mentioned earlier, the
> sort char sort works fine on it. I just don't understand why, certainly in
> part because I don't understand the binary structure that
> (pack("C4",199,77,210,67) is producing.
> 
> # Ain't working:
> print bintodec(pack("C4",199,77,210,67),"\n");
> 
> sub bintodec { unpack("N", pack("B32", substr("0" x 32 . shift, -32) ) ); }

<snip>


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

Date: Tue, 13 Oct 1998 22:49:02 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Newbie needs help transposing two words in a file
Message-Id: <1dguzv5.1uufwuy1lvefqhN@bos-ip-2-209.ziplink.net>

Michael Mongeau <michael_mongeau@stratus.com> wrote:

> while (<F>) {
>  ($last,$first,$company) = /SMTP:(\w+)\.(\w+)@(.+)/;
>  print "SMTP:$first.$last\@$company\n";
> }

>From the original poster's description of the problem, it seems clear
that lines *contain* the SMTP... string as part of the line, not that
they consist of the SMTP... string as the entire line.  So this solution
is a good start, but it doesn't quite fit what the original poster needs
to do.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 14 Oct 1998 00:53:58 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <700sn6$r66@mozo.cc.purdue.edu>

lr@hpl.hp.com (Larry Rosler) writes:

}[Posted to comp.lang.perl.misc and a copy mailed.]

}In article <700km0$7p214@mercury.adc.com> on 13 Oct 1998 22:36:48 GMT, 
}Brand Hilton <bhilton@tsg.adc.com> says...
}...
}> FWIW, the grep uses slightly less CPU if you don't put brackets around
}> the regex.

}Why would anyone prefer the BLOCK form of grep or map to the EXPR form, 
}if the EXPR form would do the job?

For the same reasons I prefer to write:
  if (x==7) { foo(); }
over:
  if (x==7) foo();
in C.  Then again, in C, it's purely a style issue.

Of course, I didn't realize there was a performance difference in perl
until now, which probably indicates that it's never been worthwhile for
me to care about the difference.  This also seems sort of like an
implementation detail that could change someday.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Wed, 14 Oct 1998 02:44:23 GMT
From: mcafee@battlezone.rs.itd.umich.edu (Sean McAfee)
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <beUU1.1642$fS.4920016@news.itd.umich.edu>

In article <700km0$7p214@mercury.adc.com>,
Brand Hilton <bhilton@tsg.adc.com> wrote:
>In article <7009hp$8oq$2@client3.news.psi.net>,
>Abigail <abigail@fnx.com> wrote:
>>@array = grep {! (expression matching item to be removed)} @array;

>  use Benchmark;
>  timethese(1000, {
>    'splice' => sub {
>                     @array = (1..10000); 
>                     for ($index = $#array; $index >= $[; $index--) {
>                       if ($array[$index] =~ /22/) {
>                         splice @array, $index, 1;
>                       }
>                     }
>                    },
>    'grep'   => sub {@array = (1..10000); @array = grep {!/22/} @array;}
>  })
>Benchmark: timing 1000 iterations of grep, splice...
>      grep: 605 secs (569.51 usr  0.14 sys = 569.65 cpu)
>    splice: 426 secs (413.87 usr  0.02 sys = 413.89 cpu)

A large chunk of either routine's time is being spent constructing the huge
array every time through.  I've added two more variants that use a
preexisting array, then put back what's removed when done:

use Benchmark;

@array2 = (1..10000);
  timethese(100, {
    'splice' => sub {
                     @array = (1..10000); 
                     for ($index = $#array; $index >= $[; $index--) {
                       if ($array[$index] =~ /22/) {
                         splice @array, $index, 1;
                       }
                     }
                    },
    'grep'   => sub {@array = (1..10000); @array = grep {!/22/} @array;},
    'splice2' => sub {
                     for ($index = $#array2; $index >= $[; $index--) {
                       if ($array2[$index] =~ /22/) {
                         splice @array2, $index, 1;
                       }
                     }
                     splice(@array2, 22, 0, "22");
                    },
    'grep2'   => sub { @array2 = grep {!/22/} @array2;
        splice(@array2, 22, 0, "22"); }
  })

Benchmark: timing 100 iterations of grep, grep2, splice, splice2...
      grep: 30 wallclock secs (29.74 usr +  0.02 sys = 29.76 CPU)
     grep2: 16 wallclock secs (16.13 usr +  0.00 sys = 16.13 CPU)
    splice: 20 wallclock secs (20.02 usr +  0.00 sys = 20.02 CPU)
   splice2:  5 wallclock secs ( 4.76 usr +  0.00 sys =  4.76 CPU)

Dramatic!

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: 14 Oct 1998 01:47:40 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl freezes when using special characters in HTML
Message-Id: <slrn7280lr.t1s.sholden@pgrad.cs.usyd.edu.au>

On Tue, 13 Oct 1998 07:26:27 GMT, Ruud Limbeck <ruud.limbeck@tip.nl> wrote:
>On 12 Oct 1998 23:53:06 GMT, sholden@pgrad.cs.usyd.edu.au (Sam Holden)
>wrote:
>
>>Why don't you try running the program at the command line and seeing what goes
>>wrong???
>
>As I mentioned earlier. The program is running very fine if there is
>no %-sign in the html-code in the browser window. As soon as I press
>the submit-button this html-form has to be read in into perl.
>Depending on wether there is a %-sign in the code or not, perl
>freezes. If I change the %-sign into something else, it works.
>
>PS: I use a 'post'-command in the form. Not a 'get'.

Perl does not see what is in the HTML that submits the form to the cgi script,
it only sees the values of the fields in the forms (and all the other crap that
gets passed along, but not the text of the web page).

So I assume you mean the % is in the field values that perl sees... in which
case why not run the script at the command line, setting the appropriate
environment variables before hand and piping in the appropriate input...

Alternatively use CGI.pm even if just for debugging at the command-line.


-- 
Sam

Even if you aren't in doubt, consider the mental welfare of the person
who has to maintain the code after you, and who will probably put parens
in the wrong place.	--Larry Wall


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

Date: Wed, 14 Oct 1998 04:25:30 GMT
From: "David L. Hawley" <dlhawley@user2.teleport.com>
Subject: Re: Perl object - why does this fail?
Message-Id: <_IVU1.14$es1.6260@news.teleport.com>

Mark-Jason Dominus <mjd@op.net> wrote:
: In article <sMPU1.1281$lU3.787165@news.teleport.com>,
: David L. Hawley <dlhawley@user1.teleport.com> wrote:
: >#! /usr/local/bin/perl
: >
: >#What is going on here?  As written, I get the "strict" error:
: >#  Global symbol "ISA" requires explicit package name at t1 line 32.

: 1. I guess you don't know what `strict' is for.  You must read the
:    manual, or else you must stop using `strict' until you do read the
:    manual.  Either one will do.  To get the manual, use the command
:    `perldoc strict'. 

I do understand what strict is for, I just didn't understand why this
example which looked to me like that in perltoot fails.  The comment on
@ISA being on package scope also confused ths issue.

: 2. When you say `use strict', you are saying to the Perl compiler ``If
:    I write any global variables, I will say explictly what package
:    they are in.''  You didn't do that with @ISA.  That is what it
:    means when it says

Again the perltoot example does not show this when it uses strict - ah I
see, it does not use strict in any @ISA example.

: >#  Global symbol "ISA" requires explicit package name at t1 line 32.

:    You must replace this:

: 	@ISA = qw(bb);

:    with this:

: 	@dd::ISA = qw(bb);

:    to avoid a strict failure.  That `dd::' says that you want to
:    modify the @ISA from package dd.  Then strict knows that you meant
:    the global dd::ISA variable on purpose, and not some other variable
:    by accident.

This makes sense and I tried this, but not the BEGIN line below.

: 3. Lines in your program are executed in order.  The call `new dd' is
:    in line 15.  Later, on line 35, at the very end of the program, you
:    initialize @ISA.  Until you do that, it is empty.  When you call
:    `new dd', Perl doesn't know that you want dd to inherit from bb,
:    because @dd::ISA is empty.  There is no dd::new, and you have not
:    defined any inheritance for it.  Perl says:

: >#  Can't locate object method "new" via package "dd" at t1 line 15.

:    One way to solve this:  Move

: 	@dd::ISA = qw(bb);

:    up to the top of the program so that it happens first.  Another
:    way:  Leave it where it is, and change it to  this:

: 	BEGIN { @dd::ISA = qw(bb) }

OK, if I'd put my main at the bottom I would have never discovered this...

:    The most normal way:  Put the `dd' package into its own file,
:    `dd.pm', and, in the main file, say

: 	use dd;

:    which executes all of dd.pm at once.

I tried making 3 files before posting - but didn't try the @dd:: prefix in
the file (or removing the strict).

: 4. 
: >#    if I dup bb:new in dd, it can't find f()

:    Same problem as #3.  Now there is a dd::new, but when you ask it
:    for $dd->f, it looks for a function named `f'  in package dd.
:    There isn't one.  You want it to find the one in bb, but you have
:    not told it yet that dd should inherit from bb.

This was obvious - I guess I should have just limited the question to
getting @ISA to work.

: 5. Until you understand better how this works, why don't you consider
:    naming your packages `Parent' and `Child'?  It can't be helpful to
:    try to think about bb and dd.

bb came from b which is short for base, likewise dd started as derived....

Maybe perltoot and the next generation of Programming Perl should mention
the need to /(option of) prefix ISA with the package name.  It would also
help to have a reminder comment that the @ISA assignment needs to be
executed, not just compiled.


thanks a lot,
Dave


-- 
David L. Hawley       D.L. Hawley and Associates    1(503)274-2242
Software Engineer                            dlhawley@teleport.com 


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

Date: Wed, 14 Oct 1998 03:27:35 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: prograMing: CompleteIndexSet
Message-Id: <36241BC1.9237D3B3@shaw.wave.ca>

[posted & mailed]

Xah wrote:
> 
> The algorithm used for CompleteIndexSet is from Rick Delaney
> <rick.delaney@shaw.wave.ca>. Thanks Rick.

You're welcome.

> 
> I was going to write a version that avoids generating existing
> indexes, but Rick's solution is good enough that I decided to use it. 
> My planned algorithm will use MinimumIndexSet to prune the argument 
> first, then use this minimum index set to generate the complete index 
> set, where as soon as a single index is detected existing, that index 
> would be immediately dropped from the generating process. This 
> algorithm would have a better time complexity, but is probably not 
> worthy unless the input is huge with lots of different branches...
> 

I think you should look at CompleteIndexSet again. It already stops
generating indexes when it detects that they already exist.

> sub CompleteIndexSet ($) {
>  my @indexList = @{$_[0]};
> 
>  my %indexListHash;
>  foreach my $elem (@indexList) {$indexListHash{"@{$elem}"} = $elem;};
> 
>     foreach my $ref_index (@indexList) {
>         my @index = @{$ref_index};
>  LOOP1: while (@index) {
>    if ($index[-1]-- == 0) {pop(@index);};
>    if (exists $indexListHash{"@index"}) {last LOOP1;};
     ^^^^^^^^^^                            ^^^^     

>    $indexListHash{"@index"} = [@index];
>   };
>  };
>  return [values %indexListHash];
> };
> 

Granted, it does generate one index to test, but it stops before then
cascading down to [].  And this generation is so trivial that it is
really just another (better) way of doing your inferableIndex test
[snipped].

Also, I don't see a lot of value in pruning the original list down to
the MinimumIndexSet.  You will then just have to recreate those elements
again.  There are probably certain sets where this makes more sense, but
you should really examine how common they are and whether the overhead
of MinimumIndexSet is worth it.

Anyway, glad I could help.

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Tue, 13 Oct 1998 23:29:19 -0400
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: Proper Names and Mc etc.
Message-Id: <19981013.232919.3Z7.rnr.w164w@locutus.ofB.ORG>

mjd@op.net (Mark-Jason Dominus) writes:

> Look in the phone book for a minute, and you'll see that you're going
> to lose.  If you have MACDONALD, there is no way to tell whether it
> should be MacDonald or Macdonald.

but you can be sure it isn't MACDONALD; either of those is better.

> The last straw: Richard A Delarso spells his name with one capital,
> but his son, Richard A DeLarso Jr., uses two.

I'm willing to bet a small amount of money that that's a phone book
error, not how they want their names spelled.  (not both of them, anyway.)

> There isn't one.  Give up.

but there is a good approximation.  if your data is CASE SMASHED already,
you might as well use it.
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: Tue, 13 Oct 1998 21:09:20 -0700
From: "Robin Bank" <rbank@csf.edu>
Subject: Sorry
Message-Id: <7015r4$slm$6@santaclara.santafe.edu>

Hey all... Sorry about my last posts.  I'll think of questions that aren't
so stupid and won't ask to be e-mailed answers in the future....

Later,
Robin
******|
------| rbank@csf.edu
******|



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

Date: Wed, 14 Oct 1998 04:25:09 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Sorry
Message-Id: <36242525.747F7EC8@bbnplanet.com>

Robin Bank wrote:
> 
> Hey all... Sorry about my last posts.  I'll think of questions that aren't
> so stupid and won't ask to be e-mailed answers in the future....

No question is stupid per se, but in this group one must do their
homework first. Also when you specifically request to be emailed certain
parties pop a vein, including myself. Join us or don't. Immolate or
don't. 

The only stupid question is one that has been asked a billion times and
has been answered equally as many times. If you have an interesting
question, wild horses won't keep the usuals from answering in
completeness, even if you ask for clarification.

e.

After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia.  - U. Eco -


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

Date: 14 Oct 1998 12:32:50 +1000
From: Tim Potter <tpot@acsys.anu.edu.au>
Subject: Re: TAB completion - how?
Message-Id: <6yg1crna99.fsf@acronym.anu.edu.au>

Alexander Farber <eedalf@eed.ericsson.se> writes:

> how do you implement the file name completion (with TAB)?
> I suspect it is usually done using the Term::Completion,
> but its documentation (perldoc on it) is really scarce
> and I have no clue how to do it. I have also searched
> the Dejanews for "Term::Completion perl" - with no success.

I can't seem to find Term::Completion on the CPAN I am looking at!
Where did you get it?

For filename and other completion I usually use the Term::Readline
module and install GNU readline.


Tim.

> Thanks in advance!
> Alex


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

Date: Wed, 14 Oct 1998 00:13:40 -0400
From: John <leotl@yahoo.com>
Subject: Variable From Forms
Message-Id: <362424E5.6CF63272@yahoo.com>

Man oh man is this a busy newsgroup.

I've spent over two days trying to find this out, on dozens of websites,
at the library, and I even bought 2 more books on Perl but nothing I do
is leading me any closer to the answer!

I want to take the content somebody enters into a text box and make it
the contents of a variable so that I can use the variable in a Perl
program to put into another page.

In other words, I'm trying to make a program that asks a few questions,
and then uses the answers of those questions as the content of a webpage
that the program will automatically generate and save to disk.

If anybody knows how to do this, or where I can find examples and
resources about this - PLEASE let me know!

Thanks alot, I would be eternally grateful.



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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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