[17325] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4747 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 28 00:05:33 2000

Date: Fri, 27 Oct 2000 21:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972705910-v9-i4747@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 27 Oct 2000     Volume: 9 Number: 4747

Today's topics:
    Re: #perl on EFnet (David Wall)
        Arggh... this should be easy but I can't do it... fallenang3l@my-deja.com
    Re: Arggh... this should be easy but I can't do it... (Tarael200)
    Re: Bitreverse an integer (Pete M. Wilson)
    Re: Bitreverse an integer <bart.lateur@skynet.be>
        code counter v1 released :-) (Tarael200)
        error using DBI, Dynaloader <pdmos23@geocities.com>
    Re: func (a) func !a! func ~a~ func a .... more? <mischief@velma.motion.net>
    Re: func (a) func !a! func ~a~ func a .... more? (Mark-Jason Dominus)
    Re: func (a) func !a! func ~a~ func a .... more? <bart.lateur@skynet.be>
    Re: giving , another name, like "and" for && (was: rena (Malcolm Dew-Jones)
    Re: giving , another name, like "and" for && (was: rena <ren.maddox@tivoli.com>
    Re: How can i find my ip? <lr@hpl.hp.com>
    Re: How to protect perl program from pirates? (Tarael200)
        How to speedup the following wish_was_a_newbie@db-networks.com
    Re: How to speedup the following <lr@hpl.hp.com>
    Re: Libraries <rcouto@NOSPAMwanadoo.es>
        newbie--Sorting pairs by value <pmosinsk@lmumail.lmu.edu>
    Re: newbie--Sorting pairs by value fallenang3l@my-deja.com
    Re: Packaging CPAN Modules With Application asimjalis@my-deja.com
    Re: Perl and Lotus Notes <bwalton@rochester.rr.com>
        Perl CGI <dvoon@my-deja.com>
    Re: Perl CGI (Prasanth A. Kumar)
    Re: Perl CGI <jeff@vpservices.com>
        Positions Available iam@thebeach.com
        problem of perldoc command <crud_alex@yahoo.com>
    Re: Problems compiling "libnet" under 5.6.0 <dean_j_pompilio@yahoo.com>
        redirecting output changes order? innocent_smith@my-deja.com
    Re: redirecting output changes order? <bwalton@rochester.rr.com>
        Running Perl as a scriptlet dottiebrooks@my-deja.com
    Re: Script doesn't display the correct date. Help. <nwsmith@bigfoot.com>
    Re: stat / inode question <elaine@chaos.wustl.edu>
    Re: stat / inode question (Mark-Jason Dominus)
    Re: the silly project of Dale's (Tarael200)
        This is a really NEAT perl switch <webqueen@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 27 Oct 2000 21:24:11 -0400
From: darkon@one.net (David Wall)
Subject: Re: #perl on EFnet
Message-Id: <8FDAD2FB1darkononenet@206.112.192.118>

wescott@conterra.com (Mike Wescott) wrote in 
<osbsw7huhv.fsf@eriadne.sc.rr.com>:

>It seems that #perl on EFnet has become "invite only". Why is that?
>Not that I was a very frequent lurker, but on occasion it could
>be instructive.

I was wondering about that, too, and for the same reason.  I don't drop in 
there very often either, but I did pick up some useful bits of information 
on occasion.  I'm glad you said something, as I was considering posting a 
question myself.

-- 
David Wall
darkon@one.net


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

Date: Sat, 28 Oct 2000 00:45:44 GMT
From: fallenang3l@my-deja.com
Subject: Arggh... this should be easy but I can't do it...
Message-Id: <8td7jo$kvp$1@nnrp1.deja.com>

I've been staring at Programming Perl 3rd Edition and I can't solve my
simple problem. Let's say I have two files, one.pl and two.pl. The
contents of one.pl are as follows:

-------------------------
#!/usr/local/bin/perl
require "two.pl";
print $variable_in_two;
-------------------------

The contents of two.pl are:

-------------------------
$variable_in_two = "I'm here.";
1;
-------------------------


This works great until I put "use strict" in one.pl:

-------------------------
#!/usr/local/bin/perl
use strict;
require "two.pl";
print $variable_in_two;
-------------------------

Now I get an error. I've tried using "our", and "my" on
$variable_in_two in two.pl but it didn't work. I know it has something
to do with packages and I've tried "package main" as a first line in
two.pl but I didn't work either. This is driving me crazy. Can anyone
help me?


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 28 Oct 2000 02:08:06 GMT
From: tarael200@aol.com (Tarael200)
Subject: Re: Arggh... this should be easy but I can't do it...
Message-Id: <20001027220806.04363.00001212@ng-cm1.aol.com>

See, your using $variable_in_two as a global variable. I think. :-) I'm kinda
new to perl myself, only been coding in it for a month or so.

Anyway use strict requires you to EXPLICITLY declare all variables you use in
your code that are of your own creation..

Therefore, you need to throw something like this into one.pl

use vars qw($variable_in_two);

 ... I put this after the use strict code, not sure if it's necessary, but
that's where I usually stick them. Anyway, I tested that and that works.

Cheers
Ryan




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

Date: Fri, 27 Oct 2000 22:31:28 GMT
From: wilsonpm@drop.gamewood.net (Pete M. Wilson)
Subject: Re: Bitreverse an integer
Message-Id: <39f9fcac.350930952@news.gamewood.net>

The principle is pretty straightforward:

You can reverse an arbitrary 1/2^n bits of a bit string by masking the
upper and lower halves, shifting appropriately and oring back
together. This reverses groups of bits in parallel.

So, use successive masks to reverse the upper and lower half of the
string, every quarter, every eigth, etc.

In C, it goes something like this:

unsigned long x; // 32 bit unsigned integer

x = ((x & 0xffff0000) >> 16)  |  ((x & 0x0000ffff) << 16);
x = ((x & 0xff00ff00) >> 8) | (( x & 0x00ff00ff) << 8);
x = ((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4);
x = ((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2);
x = ((x & 0xaaaaaaaa) >> 1) | (x & 0x55555555) << 1);

// x is now bit reversed!

So, in Perl, try this:
$x = (($x & 0xffff0000) >> 16) | (($x & 0x0000ffff) << 16); 

and so on for the remaining lines.

(Warning: this is from memory!)


Steffen Beyer <sb@muccpu1.muc.sdm.de> wrote:

>In article <8tcccf$933$1@lublin.zrz.tu-berlin.de>, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>
>> Sean McAfee has shown a crystal clear method: shift bits out
>> of the less significant end of the operand and shift them into the
>> less significant end of the result.  Hard to go wrong there.
>
>> Of course, looping over single bits doesn't seem to be particularly
>> fast. If we define its performance to be 1, Bart's methods perform
>> at 1.2 - 1.3.  (Benchmarks and code included below, if anyone is
>> interested.)
>
>> Using a lookup-table for byte-sized patterns speeds things up
>> a little. This works much like Sean's method, only you shift pre-
>> reversed bytes, not bits.  The unused bits on top of the highest
>> byte (if any) end up as the lowest bits in the reversed word.  So
>> the whole result must undergo a right shift by a quantity which
>> turns out to be 7 - (($size-1) % 8). This performs at 1.4.
>
>A method which works in O( log n ) without using a lookup table
>is shown at www.snippets.org - or was it comp.lang.c.[misc,moderated]?
>(If I'm not mistaken.)
>
>I can try to find it again if anybody's interested, I think I saved
>the algorithm somewhere.
>
>Regards,
>-- 
>    Steffen Beyer <sb@engelschall.com>
>    http://www.engelschall.com/u/sb/whoami/ (Who am I)
>    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
>    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)


Pete M. Wilson
Gamewood Data Systems Internet Service
wilsonpm@gamewood.net


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

Date: Sat, 28 Oct 2000 02:22:44 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Bitreverse an integer
Message-Id: <2vdkvs0olfsi458jg0pqsvve5ilib837ch@4ax.com>

Anno Siegel wrote:

>Your method 2 suffers from what I think is a bug in unpack:
>"unpack 'v', $str" returns an undefined value when $str is 0 or 1
>bytes long, so when the number of bits to invert is < 9, it fails.

Oops.

Here's one more:

	sub bitreverse ($$) {
	    my($n, $b) = @_;
	    if($b>32) {
	        require Carp;
	        Carp::croak("Too many bits for bitreverse()");
	    }
	    return (unpack 'N', pack 'B32', 
	      unpack 'b32', pack 'V', $n) >> (32-$b);
	}

-- 
	Bart.


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

Date: 27 Oct 2000 23:54:01 GMT
From: tarael200@aol.com (Tarael200)
Subject: code counter v1 released :-)
Message-Id: <20001027195401.19083.00001297@ng-mk1.aol.com>

Hey guys :-)

I wasn't entirely sure if this was the right newsgroup to post little releases
of perl code to, but here's my perl code counter :)

It skips comments and whitespace and concentrates on that which is important in
a source file - the code ! You run it in the form of "perl coc <code file>" or
"coc <code file>" if your on a unix machine and you chmod +x it...

When run it outputs the total number of lines, the number of comments, and the
number of lines which contain code..

Here's the code:
#!/usr/bin/perl
# Code Counter v1.0
# Counts total lines, lines with code, and number of comments in a program.
# coded by iless (tarael200@aol.com)

# v1.00 Notes:
# o Borrowed Tom Christiansen's code that gets the basename of a program.
# In this case, coc.
# o Stole Tom's coding style as well :-) It just looked so professional!

use strict;

# globals
use vars qw($me $version);

init();

if (scalar(@ARGV) < 1) {
        usage();
}

countcode();

######################### BEGIN SUBROUTINES #########################
sub init {
  ($me = $0) =~ s!.*/!!;                        # get basename 
  $| = 1;                                       # autoflush output

  $version = "v1.0";
}

#########################
sub usage {
        die <<EOF
usage: $me [file]
EOF
}

#########################
sub countcode {
  # $comments - number of comment lines
  # $totallines - total number of lines
  # $codelines - number of lines that are not whitespace or code
  my (@filetext, $poptext, $comments, $totallines, $codelines);

  open FILEN, "<$ARGV[0]" || die "Can't open file: $!";
  @filetext = <FILEN>;
  close FILEN;

  while (scalar @filetext) {
        $poptext = shift @filetext;
        $totallines++;

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

        if ($poptext =~ /^#/) {
                $comments++;
                next;
        }
        if ($poptext =~ /^$/) {
                next;
        } else {
                # It's some code!
                $codelines++;
        }
  }

# Output the data:
print "CodeCounter $version by iless (tarael200\@aol.com) \n";
print " Counted $totallines lines, $comments comments, and $codelines lines of
code.\n";
}
        
-------------------- end of code ---------------------

might have gotten word-wrapped a little bit. aol -is- quite disgusting in that
area.

-thanks
Ryan




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

Date: Sat, 28 Oct 2000 02:08:36 GMT
From: Pasquale <pdmos23@geocities.com>
Subject: error using DBI, Dynaloader
Message-Id: <39FA3604.14B88913@geocities.com>

I am getting the following error:
DynaLoader object version 1.03 does not match $DynaLoader::VERSION 1.04
at /dir/mydir/cgi-bin/DynaLoader.pm line 93.
BEGIN failed--compilation aborted at /dir/mydir/cgi-bin/DBI.pm line 149.

BEGIN failed--compilation aborted at exit.pl line 5.

I looked at all the lines mentioned above, mainly the DynaLoader
version, but I don't see what I can do.  Unless I manually change the
version from 1.04 to 1.03, but I don't think that would be right.  I
have included the lines of code from the list above.  I understand the
bottom two errors, hierarchy thing.  Why is it having a problem with
line 93 from the DynaLoader.pm??
I have all the most recent versions of modules, DBI.pm-1.14, CGI.pm-2.74
& DynaLoader-1.04.

snippet from my exit.pl script:
#!/usr/bin/perl -wT
use strict;
use lib "/dir/mydir/cgi-bin";
use CGI::Carp qw(fatalsToBrowser);
use DBI;   ### Line 5
use CGI qw(:standard);

line149 from DBI.pm:
use DynaLoader ();

line 93 & 94 from DynaLoader.pm:
boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) &&
                                !defined(&dl_load_file);

Thank,
Pasquale



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

Date: Fri, 27 Oct 2000 22:05:56 -0000
From: <mischief@velma.motion.net>
Subject: Re: func (a) func !a! func ~a~ func a .... more?
Message-Id: <svjv24ec4anp85@corp.supernews.com>

Dave Brondsema <brondsem@my-deja.com> wrote:
> In article <slrn8vjlpf.k9u.tadmc@magna.metronet.com>,
>   tadmc@metronet.com (Tad McClellan) wrote:
>> On Fri, 27 Oct 2000 18:58:58 GMT, Dave Brondsema <brondsem@my-
> deja.com> wrote:
>> >
>> >I know there are several characters that can be used to surround
>> >function paramaters:
>>
>> You "know" incorrectly then.

[snipped explanation by Mr. McClellan]

> ok, I tried some things and looked through some perl documentation and
> you're right.  What I really want to know is what can I use instead
> of / in a regexp.

> print qq(1);
> print qq~2~;
> print qq!3!;
> print qq/4/;

One of the great things about Perl regexes is that you can use lots
of things for delimeters. If they're paired:

print qq[hi];
print qq{hi};
print qq(hi);
print qq<hi>;

If it's somethin that's not paired, use the same thing twice:

print qq!hi!;
print qq~hi~;
print qq@hi@;
print qq#hi#;
print qq$hi$;
print qq%hi%;
print qq^hi^;
print qq&hi&;
print qq*hi*;
print qq-hi-;
print qq=hi=;
print qq+hi+;
print qq\hi\;
print qq|hi|;
print qq'hi';
print qq"hi";
print qq:hi:;
print qq;hi;; # particularly nasty...

 .... And so on. According to the docs (perldoc perlop),

               Any non-alphanumeric, non-whitespace delimiter may
               replace the slashes.  If single quotes are used,
               no interpretation is done on the replacement
               string (the /e modifier overrides this, however).
               Unlike Perl 4, Perl 5 treats backticks as normal
               delimiters; the replacement text is not evaluated
               as a command.  If the PATTERN is delimited by
               bracketing quotes, the REPLACEMENT has its own
               pair of quotes, which may or may not be bracketing
               quotes, e.g., s(foo)(bar) or s<foo>/bar/.  A /e
               will cause the replacement portion to be
               interpreted as a full-fledged Perl expression and
               eval()ed right then and there.  It is, however,
               syntax checked at compile-time.

I believe this explains it pretty well.

> --
> Dave Brondsema


> Sent via Deja.com http://www.deja.com/
> Before you buy.

-- 
Christopher E. Stith
mischief@motion.net


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

Date: Sat, 28 Oct 2000 01:30:57 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: func (a) func !a! func ~a~ func a .... more?
Message-Id: <39fa2c50.2da9$160@news.op.net>

In article <svjv24ec4anp85@corp.supernews.com>,
 <mischief@velma.motion.net> wrote:
>One of the great things about Perl regexes is that you can use lots
>of things for delimeters. 

True, although your examples were not regexes.  Regexes have m and s.

>If it's somethin that's not paired, use the same thing twice:

You can do this even if it >is< paired:

        $s = q]Put that thing down!];
        $s =~ s{Do what you want to me}}but leave the girl alone!\n};
        print if $s =~ m>What kind of insane monster would do such a thing?>;

Regrettable, but true.

Fortunately for the safety of Democracy, qq(...( doesn't work similarly.



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

Date: Sat, 28 Oct 2000 02:42:34 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: func (a) func !a! func ~a~ func a .... more?
Message-Id: <o3fkvs048oec61b7o888f2id1vn2ol2uk6@4ax.com>

<mischief@velma.motion.net> wrote:

>print qq;hi;; # particularly nasty...
>
>.... And so on. According to the docs (perldoc perlop),
>
>               Any non-alphanumeric, non-whitespace delimiter may
>               replace the slashes.

It's even broader than that. If you insert some whitespace between your
delemiter and the preceding word (token), you CAN use an alphanumerical
character as a delimiter, as in this Abigailism:

	print qq qxyzq;
-->
	xyz


-- 
	Bart.


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

Date: 27 Oct 2000 10:38:48 -0800
From: yf110@victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: giving , another name, like "and" for && (was: renaming local())
Message-Id: <39f9bda8@news.victoria.tc.ca>

Ren Maddox (ren.maddox@tivoli.com) wrote:
(snip)
: ... I had a thought.

: So it occurred to me that perhaps a word version of the comma operator
: could have precedence lower than list operators.  The first thing that
: came to mind was "then", which may be problematic because of its use
: in other languages.  But I'll use it for this discussion at least.
: So, it is just a comma operator with precedence lower than list
: operators.  I haven't considered how its precedence should compare to
: the other boolean word operators.

: With this, you get:

: print "Error: $error\n" then exit if defined $error;  # Bug fixed!

: Yeah!

: At first, I thought this was going to help another situation where the
: precedence of the comma operator is annoying, but unfortunately it
: just makes it break in the opposite way.  That is:

: print map "VALUE: $_, ", @array then "\n";

: The "then" protects "\n" from "map", but unfortunately, it protects it
: >From "print" as well... :(


If the 'then' could have a "dynamic" precedence then this would work.
low precedence in the list in which it "immediately" occurs, normal
precedence in any "higher up" lists.

'Then' would be identical to putting brackets around the list values seen
up to that point. 

E.g. the expression   1,2,3,4 then 5,6,7   would be identical to
(1,2,3,4),5,6,7

So in the above example

  print map "VALUE: $_, ", @array then "\n";

would be exactly equivalent to 

  print map ("VALUE: $_, ", @array ), "\n";

which does do what you want.


If desired, you could force higher levels of lists to end by multiple
uses of 'then'

  print map "VALUE: $_, ", @array then then "\n";  #(note 2 X then)
becomes
  print map ("VALUE: $_, ", @array ), then "\n";
which would become
  print (map ("VALUE: $_, ", @array ), ), "\n";

which behaves as in the original example. (this assumes the parsing
recognizes map() as a "list"). 

$0.02


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

Date: 27 Oct 2000 21:40:02 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: giving , another name, like "and" for && (was: renaming local())
Message-Id: <m3zojppu2l.fsf@dhcp11-177.support.tivoli.com>

yf110@victoria.tc.ca (Malcolm Dew-Jones) writes:

> If the 'then' could have a "dynamic" precedence then this would work.
> low precedence in the list in which it "immediately" occurs, normal
> precedence in any "higher up" lists.

I had thought about this, but figured it was too confusing.  Perhaps
it isn't...?

> If desired, you could force higher levels of lists to end by multiple
> uses of 'then'

OK, that's downright scary...  Off-hand, I cannot think of any other
binary operator (in Perl) that can be used twice in a row without an
intervening operand.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Fri, 27 Oct 2000 16:05:28 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How can i find my ip?
Message-Id: <MPG.1463aa11b0c8534198ae76@nntp.hpl.hp.com>

In article <39F9D286.C1C1EF5D@kloth.net> on Fri, 27 Oct 2000 19:07:50 
+0000, Ralf D. Kloth <ralf@kloth.net> says...
> Nathan Going wrote:
> > 
> > How do i discover my internet ip address?
> 
> From the CPAN-search DB (try it by yourself next time ...)
> http://theoryx5.uwinnipeg.ca/CPAN/cpan-search.html :
>     use Socket;
>     use Sys::Hostname;
>     my $host = hostname();
>     my $addr = inet_ntoa(scalar gethostbyname($host || 'localhost'));

Which is copied verbatim from perlfaq9: "How do I find out my 
hostname/domainname/IP address?"

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 28 Oct 2000 02:15:22 GMT
From: tarael200@aol.com (Tarael200)
Subject: Re: How to protect perl program from pirates?
Message-Id: <20001027221522.04363.00001214@ng-cm1.aol.com>

Use an encryption software package?


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

Date: Fri, 27 Oct 2000 23:10:31 GMT
From: wish_was_a_newbie@db-networks.com
Subject: How to speedup the following
Message-Id: <pk2kvs0bujva91damlmu018n3so8dskce3@4ax.com>

I try to output a file after remove lines that contains certain words.
It runs very slowly.

 ...

while (<FILTEROUT>) {
    chomp; 
    push(@spam, uc($_));
}

while(<INFILE>) {
    chomp;
    $ucrequest = uc($_);
    foreach $item(@spam) {
        if ($ucrequest =~ m/$item/){
            last;
        }
    }
    print OUTFILE $_  . "\n";;
}

 ...

Thanks


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

Date: Fri, 27 Oct 2000 16:32:59 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How to speedup the following
Message-Id: <MPG.1463b0874aaaf4ac98ae77@nntp.hpl.hp.com>

In article <pk2kvs0bujva91damlmu018n3so8dskce3@4ax.com> on Fri, 27 Oct 
2000 23:10:31 GMT, wish_was_a_newbie@db-networks.com 
<wish_was_a_newbie@db-networks.com> says...
> I try to output a file after remove lines that contains certain words.
> It runs very slowly.

And it doesn't even do what you want.  See below.

> ...
> 
> while (<FILTEROUT>) {
>     chomp; 
>     push(@spam, uc($_));
> }
> 
> while(<INFILE>) {
>     chomp;
>     $ucrequest = uc($_);
>     foreach $item(@spam) {
>         if ($ucrequest =~ m/$item/){
>             last;

This gets you out of the foreach loop, but the line gets printed anyway.  
You need to put a label on the 'last' and the 'while' to get back to the 
while loop without printing.

>         }
>     }
>     print OUTFILE $_  . "\n";;
> }

perlfaq6: "How do I efficiently match many regular expressions at once?"

But if you are seeking exact caseless matches rather than pattern 
matches, then read this FAQ:

prelfaq4: "How can I tell whether a list or array contains a certain 
element?"

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 28 Oct 2000 02:04:14 GMT
From: caligari <rcouto@NOSPAMwanadoo.es>
Subject: Re: Libraries
Message-Id: <ifckvscca0d7344mms7o5hntj987s4v30n@4ax.com>

On Sun, 15 Oct 2000 22:22:13 +0100, Geoff Soper
<g.soper@soundhouse.co.uk> wrote:

>I've just got to the stage where I'm thinking about libraries for the
>first time. I've moved some common subroutines into a file called
>gs_database.pl, the beginning of which is shown below:
>
>require 'gs_database.pl';

1. Rename gs_database.pl to gs_database.pm

2. Start gs_database.pm with "package gs_database;"

3. Start your script with "require gs_database;". If module is not in
your @INC paths, write before: "use lib '/only/path/to/module';"

I think this works O:-)




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

Date: Fri, 27 Oct 2000 17:47:14 -0700
From: Peter Mosinskis <pmosinsk@lmumail.lmu.edu>
Subject: newbie--Sorting pairs by value
Message-Id: <39FA2212.53EB39E8@lmumail.lmu.edu>

**** Post for FREE via your newsreader at post.usenet.com ****

Hi,

Say I have the following data in the form key,value:
	apple,10
       	banana,30
       	cake,20
       	drinks,20
       	eggs,50
This data is stored in an array and/or hash.
I want to sort the pairs ascending by the number value.
I tried reversing key/values in the hash, but then obviously you can't
have two hash keys of the same "name". I just can't picture the
necessary algorithm. Any suggestions?

Thanks a million,
Peter

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
                      http://www.usenet.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


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

Date: Sat, 28 Oct 2000 01:12:02 GMT
From: fallenang3l@my-deja.com
Subject: Re: newbie--Sorting pairs by value
Message-Id: <8td94v$m9b$1@nnrp1.deja.com>

In article <39FA2212.53EB39E8@lmumail.lmu.edu>,
  Peter Mosinskis <pmosinsk@lmumail.lmu.edu> wrote:
> **** Post for FREE via your newsreader at post.usenet.com ****
>
> Hi,
>
> Say I have the following data in the form key,value:
> 	apple,10
>        	banana,30
>        	cake,20
>        	drinks,20
>        	eggs,50
> This data is stored in an array and/or hash.
> I want to sort the pairs ascending by the number value.
> I tried reversing key/values in the hash, but then obviously you can't
> have two hash keys of the same "name". I just can't picture the
> necessary algorithm. Any suggestions?
>
> Thanks a million,
> Peter
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>  *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
>                       http://www.usenet.com
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>

Try this:
my %fruits = (
	banana => 30,
	cake   => 20,
	drinks => 50,
	eggs   => 50,
);
@sorted_fruits = sort by_value keys(%fruits);
sub by_value {
	($fruits{$a} <=> $fruits{$b}) || ($a cmp $b);
}

This will sort the pairs in ascending value order and if two values are
the same, it will sort the keys alphabetically.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 28 Oct 2000 02:36:15 GMT
From: asimjalis@my-deja.com
Subject: Re: Packaging CPAN Modules With Application
Message-Id: <8tde2v$pr4$1@nnrp1.deja.com>

I ended up writing a short bash script which seems to fulfill
my needs at the moment. Basically I wanted to build my perl/cgi
web site system from scratch on new Linux machines without
worrying about installing CPAN modules individually. Here is the
shell script for your perusal.

This utility only extract Perl .pm modules. It does not handle
modules that have xs parts or require C compilation. So only works
for pure Perl modules.

#!/bin/sh

# @author Asim Jalis
# @date   10/26/00
# @desc   Simple utility for mass extraction of (pure) Perl modules
from tgz files.
# @usage  Run with no args for usage info.

# check args

if test $# -ne 2 ; then echo "error: usage: $0 TGZDIR LIBDIR" ; exit
1 ; fi

# set up params

TGZDIR=$1
LIBDIR=$2
TMPDIR=./perlmod-install.tmp

# make sure LIBDIR is not . or ..

if test $LIBDIR = . -o $LIBDIR = .. ; then echo "error: LIBDIR cannot
be . or .." ; exit 1 ; fi

# clean up tmp directory

mkdir -p $TMPDIR ; rm -rf $TMPDIR ; mkdir -p $TMPDIR

# now unarchive perl module files

find $TGZDIR -type f -name '*gz' | xargs -iFFF tar xzf FFF -C $TMPDIR

# now copy *pm to lib

find $TMPDIR -regex '^.*/lib/[^/]*$' | xargs -iFFF cp -R -f FFF $LIBDIR

# finally clean out the mess

rm -rf $TMPDIR


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 28 Oct 2000 02:28:48 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Perl and Lotus Notes
Message-Id: <39FA39C9.E63A652@rochester.rr.com>

Lou Moran wrote:
 ...
> ---Has/is anyone using perl on Lotus Notes (Domino) right now?  Can it
> even be done (w/o exporting everything .csv and shoving it back into
> an .nsf)?
> 
> ---I know how nicely perl works with MySQL/DBI and Notes is for all
> intents and purposes a Databasing program, it seems likely.  I know
> the Web Server portion of Notes does support perl, but I was thinking
> more along the lines Notes DBs and mucking with their contents.
 ...
> lmoran@wtsg.com
 ...
Well, Lotus Notes is OLE-capable, so you could use Win32::OLE to access
it.  Good luck finding and deciphering the Lotus OLE documentation,
though.  Lotus Notes is not a database program in the sense that the
stuff that DBI interfaces with are databases, so DBI won't help with
Lotus Notes.
-- 
Bob Walton


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

Date: Sat, 28 Oct 2000 03:02:24 GMT
From: dVoon <dvoon@my-deja.com>
Subject: Perl CGI
Message-Id: <8tdfju$r0p$1@nnrp1.deja.com>

Hi all, I have 2 questions:

1) Consider the following code:

         #!/usr/bin/perl -w
           :
         my $text = param('t');
         $text = ($text =~ /\w+/)? $text: ''; # default to empty string.

The last line above generate "Use of uninitialized variable..." message
in /apache/logs/error.log file. I believe it's a warning message because
of the -w option. Is there a way to code it in such a way so that it
doesn't generate the warning/error message?

2) open( DATA, ">data.txt" ) or die "Cannot open file!";

The above code runs ok in shell, but in cgi it says "Cannot open file!".
How to fix the problem? I need to open some text files for writing...

I appreciate for any help. Thanks.


Daniel


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 28 Oct 2000 03:14:50 GMT
From: kumar1@home.com (Prasanth A. Kumar)
Subject: Re: Perl CGI
Message-Id: <m3itqdwtat.fsf@C654771-a.frmt1.sfba.home.com>

dVoon <dvoon@my-deja.com> writes:
<snip>
> 2) open( DATA, ">data.txt" ) or die "Cannot open file!";

Try specifying the full path to where this CGI process can write a
file because this process is normally run as 'nobody' which cannot
write in the directory it is executing.

> 
> The above code runs ok in shell, but in cgi it says "Cannot open file!".
> How to fix the problem? I need to open some text files for writing...
> 
> I appreciate for any help. Thanks.
> 
> Daniel
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

-- 
Prasanth Kumar
kumar1@home.com


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

Date: Fri, 27 Oct 2000 20:51:23 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Perl CGI
Message-Id: <39FA4D3B.7AF21888@vpservices.com>

dVoon wrote:
> 
>          #!/usr/bin/perl -w
>            :
>          my $text = param('t');
>          $text = ($text =~ /\w+/)? $text: ''; # default to empty string.
> 
> The last line above generate "Use of uninitialized variable..." message
> in /apache/logs/error.log file.

    my $text = param('t');
    $text = '' unless defined $text;

That way $text has a value no matter what.  Your way tries to check what
$text contains before $text is defined.

> 2) open( DATA, ">data.txt" ) or die "Cannot open file!";

Put in "$!" into the error message so you can see *why* it cannot open
the file.

-- 
Jeff


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

Date: Fri, 27 Oct 2000 23:15:25 GMT
From: iam@thebeach.com
Subject: Positions Available
Message-Id: <39fa0c84.3165004@news.pacbell.net>

Z-Concepts is currently recruiting for the following positions:

Please see www.z-concepts.com for more information:

Microwave Engineer
Snr Software Engineer
Software Engineer (x2)
Snr Software Engineer
Snr Software Engineer
Senior Test Engineer
Product Line Manager
Product Line Manager
Software Engineer
RF Engineer-Snr
Group Product Manager
Applications Engineer
Director of Engineering
 RF Staff Engineer
RF Design Engineer
Product Manager
Product Manager
Manager/Director Engineering
Software Engineer
Digital Design Engineer
Firmware Engineer
RF Engineer
Software Engineer Snr
HRMS/Payroll Analyst
Senior Corporate Engineer
Regional Sales Account Manager
Network Technologies Sales Specialist
Regional Sales Account Manager 
VP., Project/Program Management
Senior Components Engineer
Product Manager, Network Powering & Engineering
Telecom Analyst
Product Design Engineer
Product Manager




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

Date: Sat, 28 Oct 2000 08:57:15 +0800
From: "­»´ä¸}" <crud_alex@yahoo.com>
Subject: problem of perldoc command
Message-Id: <8td8c0$b2f$1@imsp026.netvigator.com>

while i entered "perldoc perldoc"and expect a description,i got this message
instead
"invalid command.com"
"enter correct name of command interpreter"
why is this happening?it works fine before....





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

Date: Fri, 27 Oct 2000 22:48:40 GMT
From: Dean J. Pompilio <dean_j_pompilio@yahoo.com>
Subject: Re: Problems compiling "libnet" under 5.6.0
Message-Id: <8td0o6$fq3$1@nnrp1.deja.com>

In article <slrn8vju3g.c8.mgjv@martien.heliotrope.home>,
  mgjv@tradingpost.com.au wrote:
> On Fri, 27 Oct 2000 19:27:29 GMT,
> 	Dean J. Pompilio <dean_j_pompilio@yahoo.com> wrote:
> > In article <slrn8vhcjh.ksa.mgjv@verbruggen.comdyn.com.au>,
> >   mgjv@tradingpost.com.au wrote:
> > > When you removed the old perl, did you really, really remove it?
Every
> > > last binary and link? /usr/bin/perl, /usr/local/bin/perl, and
anything
> > > else all point to your new perl? Maybe you should search your
system
> > > for all perl binaries that may be around.
> >
> > After running "make test", I am still getting the same errors.
> >
> > Can't locate package  for @Net::Config::ISA at blah blah blah...
> >
> > I can't find any reference to "@Net::Config::ISA".  Shouldn't this
be
> > included in the "libnet-1.0703" archive?  Where can I get this
package?
>
> This is odd. I can't of course reproduce your complete system, since I
> already have libnet installed, and installign acompletely new perl
just
> to test this is not what I want to do right now :)
>
> All I can say is that for me it works, but since libnet detects that
you
> already have an old installation, there might be a problem when there
> isn't an old installation yet. Maybe you should send Graham Barr a
> message?
>
> Martien
> --
> Martien Verbruggen              |
> Interactive Media Division      | Never hire a poor lawyer. Never buy
> Commercial Dynamics Pty. Ltd.   | from a rich salesperson.
> NSW, Australia                  |
>

I just sent Graham an email... I'll let you know what fixes the problem.

Thanx!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 28 Oct 2000 00:21:17 GMT
From: innocent_smith@my-deja.com
Subject: redirecting output changes order?
Message-Id: <8td65o$jvd$1@nnrp1.deja.com>

I'm really confused by this.  Why does directing
the output to a file change the order?

milprod:/tmp # cat systest.pl
#!/usr/bin/perl
print "line1\n";
system "echo line2";
milprod:/tmp # ./systest.pl
line1
line2
milprod:/tmp # ./systest.pl > x
milprod:/tmp # cat x
line2
line1
milprod:/tmp #

I must be missing something fundamental here I
just don't know what it is.

Mark



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 28 Oct 2000 02:10:45 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: redirecting output changes order?
Message-Id: <39FA358E.EE0C0387@rochester.rr.com>

innocent_smith@my-deja.com wrote:
> 
> I'm really confused by this.  Why does directing
> the output to a file change the order?
> 
> milprod:/tmp # cat systest.pl
> #!/usr/bin/perl
> print "line1\n";
> system "echo line2";
> milprod:/tmp # ./systest.pl
> line1
> line2
> milprod:/tmp # ./systest.pl > x
> milprod:/tmp # cat x
> line2
> line1
> milprod:/tmp #
> 
> I must be missing something fundamental here I
> just don't know what it is.
> 
> Mark
 ...
You need to look up the $| variable, which turns file buffering off for
the selected filehandle.  

    perldoc perlvar
    perldoc -f select

Basically, your print statements are putting characters in an internal
buffer, and actual I/O operations happen only every once in a while
(like when 8K characters are accumulated).  When you switch from your
Perl program to another program, the other program will run and write
out the contents of its buffered I/O operations when it terminates --
and meanwhile, Perl's output is still pending in the bugger.  Setting $|
nonzero while a given filehandle is selected will set that filehandle so
that every print statement causes an actual physical I/O operation, and
buffering is not used.  This is referred to as setting autoflush on. 
Note that having autoflush on is much less efficient, since physical I/O
has to occur much more often.
-- 
Bob Walton


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

Date: Fri, 27 Oct 2000 21:56:50 GMT
From: dottiebrooks@my-deja.com
Subject: Running Perl as a scriptlet
Message-Id: <8tctn1$d42$1@nnrp1.deja.com>

Hi,
  I'm trying to get the scripts from an article in the Perl Journal
issue 12 running and am running into a couple of snags.  I have perl
5.005 installed from Activestate, so I assume that perlscript is
already installed.  I pulled down and installed the servers scriptlets
kit from microsoft, I believe.  I downloaded the examples from
TPJ.com.  I created a VB application and stuck a combo box, list box,
and text box in it.  I executed perl nws.pm and received no warning
messages.  When I try  perl nws.sct, however, I get

syntax error at nws.sct line 2, near "?scriptlet validate="true"
error="true" debug="true"?>"
Bareword found where operator expected at nws.sct line 7, near "progid"
        (Missing semicolon on previous line?)
Bareword found where operator expected at nws.sct line 8, near "version"
        (Missing semicolon on previous line?)
Bareword found where operator expected at nws.sct line 9, near "classid"
        (Missing semicolon on previous line?)
Bareword found where operator expected at nws.sct line 13,
near ""Automation" type"
        (Missing operator before type?)
Unterminated <> operator at nws.sct line 37.

Any thoughts or suggestions?

Regards,
Russ Brooks


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 28 Oct 2000 03:27:56 GMT
From: Nathan Smith <nwsmith@bigfoot.com>
Subject: Re: Script doesn't display the correct date. Help.
Message-Id: <5jhkvs8jgm8pkvrkt4m5n4bd1oh27bbv78@4ax.com>

On Wed, 4 Oct 2000 07:23:17 +0200, "Bostjan Kocan"
<webmajster@fiver.si> wrote:

>Hi,
>
>Script I wrote located at (with all the notes suplied):
>http://www.ixtc.com/cgi-bin/test.cgi displays the current date. The problem
>is it displays the wrong month. Instead of the 10th it displays the 9th.
>
>When you will run the script it will return all the notes on which commands
>were used, so you will see also the second command which returned the right
>month. The problem is that second command is of no use for me. I need that
>first command to display the correct month.

>Does anyone knows why it displays month like that?? Server date is 1000%
>correct.

Because months are indexed from zero when using the localtime command
(try perldoc -f localtime next time!).  If you want the 1-based index
you need to do something like

(my $month = (localtime)[4])++;

Which will assign $month to '10' for October.

n.


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

Date: Fri, 27 Oct 2000 22:24:12 GMT
From: "Elaine Ashton" <elaine@chaos.wustl.edu>
Subject: Re: stat / inode question
Message-Id: <ggnK5.12806$AM5.241214@news1.nokia.com>

"Mark-Jason Dominus" <mjd@plover.com> wrote in message
news:39f9f67d.287e$32b@news.op.net...
> Good Advice #11907 is unusually good.  It has saved me a lot of
> trouble in the past.

Indeed, but I've actually experienced a problem like that on a Solaris box
where perl was built on a SunOS box and the blocksize was different but it
still ran due to binary compat. It happens, albeit rare. Stat is so simple
as there is a working example in the man page...ah, well.

e.




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

Date: Sat, 28 Oct 2000 01:21:17 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: stat / inode question
Message-Id: <39fa2a0c.2d7c$25@news.op.net>

In article <ggnK5.12806$AM5.241214@news1.nokia.com>,
Elaine Ashton <elaine@chaos.wustl.edu> wrote:
>I've actually experienced a problem like that on a Solaris box
>where perl was built on a SunOS box and the blocksize was different 

Amazing.  Did you ever find out why it was subtracting 6 from the i-number?

Maybe the Good Advice file should also include something like this:

        #11965 There are more things in heaven and earth, Horatio,
               Than are dreamt of in your philosophy.



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

Date: 28 Oct 2000 02:11:34 GMT
From: tarael200@aol.com (Tarael200)
Subject: Re: the silly project of Dale's
Message-Id: <20001027221134.04363.00001213@ng-cm1.aol.com>

so write it in basic :-)

Ryan



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

Date: Sat, 28 Oct 2000 03:50:19 GMT
From: webqueen, queen of the web <webqueen@my-deja.com>
Subject: This is a really NEAT perl switch
Message-Id: <8tdidq$t50$1@nnrp1.deja.com>

Check out p495 in Programming Perl (3rd Ed), and the -i switch. Wow this
is cool- you can modify a file without opening, reading, printing,
closing.

Say you got a cgi script that you need to change a variable x1 to x2
(the backup part SAVES the original in that file ID):


  perl -pi'*.backup' -e 's/x1/x2/' cgifile

You can do it with multiple -e's too.


NEAT! Perl does it again :)

-PG



--
Time is nature's way of preventing everything from happening at once.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

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

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


------------------------------
End of Perl-Users Digest V9 Issue 4747
**************************************


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