[23589] in Perl-Users-Digest
Perl-Users Digest, Issue: 5796 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 13 18:10:42 2003
Date: Thu, 13 Nov 2003 15:10:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 13 Nov 2003 Volume: 10 Number: 5796
Today's topics:
Re: installing a perl module <kingsman22004@yahoo.com>
Re: installing a perl module <kingsman22004@yahoo.com>
Re: installing a perl module <usenet@morrow.me.uk>
Re: installing a perl module <kingsman22004@yahoo.com>
Re: installing a perl module <usenet@morrow.me.uk>
Re: last index of array reference <ryantate@ryantate.com>
Re: last index of array reference <ryantate@OCF.Berkeley.EDU>
List into hash (Randy)
Re: List into hash <usenet@morrow.me.uk>
Re: long running perl programs & memory untilization ctcgag@hotmail.com
Re: Perl one-line equivalent to awk; multiple commands <dmcbride@naboo.to.org.no.spam.for.me>
Re: Problem with IO::Socket::INET and pop <asu1@c-o-r-n-e-l-l.edu>
Re: Wrong statement <founder@pege.org>
Re: Wrong statement <syscjm@gwu.edu>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 14 Nov 2003 06:32:09 +1100
From: King <kingsman22004@yahoo.com>
Subject: Re: installing a perl module
Message-Id: <3FB3DC39.6060908@yahoo.com>
Ben Morrow wrote:
> news@group.com wrote:
>
>>Ben Morrow wrote:
>>
>>>news@group.com wrote:
>>>. The first perl in root's PATH is /usr/bin/perl, not
>>>/usr/local/bin/perl. You need to make sure you invoke the right perl.
>>
>>and to make sure, I # cd /usr/local/bin which is the version of perl I
>>want to install the module under which is perl-5.8.1, what am I
>>missing?
>
>
> That Linux Is Not DOS. The current directory isn't (and shouldn't be,
> especially not for root) in your PATH, so if root's PATH has /usr/bin
> before /usr/local/bin (which it should) then 'perl' as root will
> invoke /usr/bin/perl. 'which perl' will tell you if this is the case.
>
>
>>[qoute] from a previous post
>>Become root, then
>># /usr/local/bin/perl -MCPAN -e'install "Data::Dumper"'
>>
>>well, I did.
>># /bin/su
>># cd /usr/local/bin
>># perl -MCPAN -e'install "Bit::Vector"'
>
>
> I do not see '/usr/local/bin/' in the line above.
>
>
>>$ perl -v
>>This is perl, v5.8.1 built for i686-linux
>><snipt>
>>
>>$ /bin/su
>># perl -v
>>This is perl, v5.8.0 built for i386-linux-thread-multi
>><snipt>
>>
>>what is this, I thought it should say v5.6.1 which is the system perl.
>>why did it change? oh.. boy
>
>
> As this says 'i386' not 'i686' my guess is this is a Debian copy of
> perl... have you updated the perl package? If you have, and everything
> hasn't broken :), then I would strongly suggest you get rid of
> /usr/local/bin/perl until you know a little more about using Linux.
>
> Ben
>
like Chris said, if I installed the package to the wrong perl because I
should have did #/usr/local/bin/perl -MCPAN -e'install "Data::Dumper"'
instead of /usr/local/bin/#perl -MCPAN -e'install "Data::Dumper"'
then why whould this change the output of
# perl -v from v5.6.1 to v5.8.0
and no I have not updated the perl package, unless # apt-get update and
#apt-get upgrade did that which I don't think it can.
so I srewed up my system !? again
I don't know why this seams the way I often learn...
------------------------------
Date: Fri, 14 Nov 2003 06:34:43 +1100
From: King <kingsman22004@yahoo.com>
Subject: Re: installing a perl module
Message-Id: <3FB3DCD3.5020804@yahoo.com>
Chris Mattern wrote:
> King wrote:
>
>> Ben Morrow wrote:
>>
>>> news@group.com wrote:
>>>
>>>> Hello
>>>> I installed a Bit::Vector
>>>>
>>>> $
>>>> $ pon <isp>
>>>> $ /bin/su
>>>> # cd /usr/local/bin
>>>> # perl -MCPAN -e 'install "Bit::Vector"'
>>>
>>>
>>>
>>>
>>> <sigh>
>>>
>>> I thought I explained this.
>>>
>>> Type, as root
>>>
>>> perl -v
>>>
>>> . The first perl in root's PATH is /usr/bin/perl, not
>>> /usr/local/bin/perl. You need to make sure you invoke the right perl.
>>
>>
>>
>> and to make sure, I # cd /usr/local/bin which is the version of perl I
>> want to install the module under which is perl-5.8.1, what am I missing?
>>
>> [qoute] from a previous post
>> Become root, then
>> # /usr/local/bin/perl -MCPAN -e'install "Data::Dumper"'
>>
>> well, I did.
>> # /bin/su
>> # cd /usr/local/bin
>> # perl -MCPAN -e'install "Bit::Vector"'
>
>
> Um, no, that's not the same thing. root may not have the current
> directory in its path. In fact, it shouldn't, IMHO. You needed
> to say ./perl.
aaaha, just now I got it. what a slow brain I have.
>
>>
>> $ perl -v
>> This is perl, v5.8.1 built for i686-linux
>> <snipt>
>>
>> $ /bin/su
>> # perl -v
>> This is perl, v5.8.0 built for i386-linux-thread-multi
>> <snipt>
>
>
> Pin-pon. You installed the package to the wrong perl.
>
so, can that be reversed with out damage?
------------------------------
Date: Thu, 13 Nov 2003 19:53:42 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: installing a perl module
Message-Id: <bp0ng6$bf2$2@wisteria.csv.warwick.ac.uk>
news@group.com wrote:
> like Chris said, if I installed the package to the wrong perl because I
> should have did #/usr/local/bin/perl -MCPAN -e'install "Data::Dumper"'
> instead of /usr/local/bin/#perl -MCPAN -e'install "Data::Dumper"'
> then why whould this change the output of
> # perl -v from v5.6.1 to v5.8.0
>
> and no I have not updated the perl package, unless # apt-get update and
> #apt-get upgrade did that which I don't think it can.
I'm sure it can. If Debian have decided 5.8.0 is stable now, then it
will have upgraded your perl...
What version is /usr/bin/perl?
What version of the perl package do you have installed? (I have no
idea how to find this out on Debian...)
> so I srewed up my system !? again
> I don't know why this seams the way I often learn...
We've all been there... :)
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Fri, 14 Nov 2003 07:19:28 +1100
From: King <kingsman22004@yahoo.com>
Subject: Re: installing a perl module
Message-Id: <3FB3E750.3050809@yahoo.com>
Ben Morrow wrote:
> news@group.com wrote:
>
>>like Chris said, if I installed the package to the wrong perl because I
>>should have did #/usr/local/bin/perl -MCPAN -e'install "Data::Dumper"'
>>instead of /usr/local/bin/#perl -MCPAN -e'install "Data::Dumper"'
>>then why whould this change the output of
>># perl -v from v5.6.1 to v5.8.0
>>
>>and no I have not updated the perl package, unless # apt-get update and
>>#apt-get upgrade did that which I don't think it can.
>
>
> I'm sure it can. If Debian have decided 5.8.0 is stable now, then it
> will have upgraded your perl...
>
> What version is /usr/bin/perl?
$ ls -l /usr/bin/ | grep perl
-rwxr-xr-x 1 root root 23346 Jun 6 00:59 find2perl
-rwxr-xr-x 2 root root 987564 Jun 6 01:03 perl
-rwxr-xr-x 2 root root 987564 Jun 6 01:03 perl5.8.0
-rwxr-xr-x 1 root root 36812 Jun 6 00:59 perlbug
-rwxr-xr-x 1 root root 19003 Jun 6 00:59 perlcc
-rwxr-xr-x 1 root root 125 Jun 6 01:03 perldoc
-rwxr-xr-x 1 root root 11664 Jun 6 00:59 perlivp
~$
> What version of the perl package do you have installed? (I have no
> idea how to find this out on Debian...)
>
>
$ dpkg -l | grep perl
ii libdbi-perl 1.35-1 The Perl5 Database Interface by Tim Bunce
ii libnet-perl 1.17-1 Implementation of Internet protocols
for Per
ii libperl5.6 5.6.1-8.3 Shared Perl library.
ii liburi-perl 1.18-1 Manipulates and accesses URI strings
ii libweakref-per 0.01-4 perl module to create weak references
ii libwww-perl 5.69-4 WWW client/server library for Perl
(aka LWP)
ii libxml-perl 0.07-5 Perl modules for working with XML
ii perl 5.8.0-18 Larry Wall's Practical Extraction and
Report
ii perl-base 5.8.0-18 The Pathologically Eclectic Rubbish
Lister.
rc perl-doc 5.6.1-8.3 Perl documentation.
ii perl-modules 5.8.0-18 Core Perl modules.
~$
------------------------------
Date: Thu, 13 Nov 2003 22:37:29 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: installing a perl module
Message-Id: <bp1139$fmg$3@wisteria.csv.warwick.ac.uk>
news@group.com wrote:
> Ben Morrow wrote:
> > What version of the perl package do you have installed? (I have no
> > idea how to find this out on Debian...)
>
> $ dpkg -l | grep perl
<snip>
> ii perl 5.8.0-18 Larry Wall's Practical Extraction and
> Report
Right, so Debian has upgraded you to 5.8. I'd strongly recommend you
uninstall your perl in /usr/local (or, say, simply delete everything
in /usr/local/bin with 'perl' in its name and delete
/usr/local/lib/perl5) and simply use the system perl. You may also
wish to see if there are Debian packages for the modules you need.
Ben
--
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else * ben@morrow.me.uk
------------------------------
Date: Thu, 13 Nov 2003 21:39:55 +0000 (UTC)
From: Ryan Tate <ryantate@ryantate.com>
Subject: Re: last index of array reference
Message-Id: <bp0tnb$2305$1@agate.berkeley.edu>
Abigail <abigail@abigail.nl> wrote:
| It seems to work with just $#{@array}. @{@array} doesn't give you a list
| of elements of @array.
I tried a simple replication of the error with perl5.005 -e and
couldn't immediately reproduce, so I did some digging.
Strangely, the problem appears related to taint mode.
Here is how I was able to reproduce the problem. This was done under
perl5.005 and then the same behavior was reproduced under perl5.6 and
perl5.8.
First of all, it is not reproducable from the command line using -e
(!), as I will show below. So I created the file test_leave_error,
which contains (between the lines):
----------------
my $arrayref=['one','two','three'];
print foreach 0 .. $#{@$arrayref};
----------------
Then I tried the following from the shell. (I have inserted two
linebreaks to make the perl output, when there was some, stand out
from the shell prompt):
----------------
apocalypse.OCF.Berkeley.EDU [56] perl -wT test_leave_error
Bizarre copy of ARRAY in leave at test_leave_error line 2.
apocalypse.OCF.Berkeley.EDU [57] perl -w test_leave_error
012
apocalypse.OCF.Berkeley.EDU [58] perl -ewT '$arrayref=["one","two","three"];print foreach 0 .. $#{@$arrayref}'
apocalypse.OCF.Berkeley.EDU [59] perl -ew '$arrayref=["one","two","three"];print foreach 0 .. $#{@$arrayref}'
apocalypse.OCF.Berkeley.EDU [60] perl -e '$arrayref=["one","two","three"];print foreach 0 .. $#{@$arrayref}'
012
apocalypse.OCF.Berkeley.EDU [61]
----------------
As you can see, the shell produced no output at all until warnings
were turned off.
At this point, in my code, which must run under taint mode, I have
reverted to using ((length @$arrayref) - 1).
Cheers
R
------------------------------
Date: Thu, 13 Nov 2003 21:55:24 +0000 (UTC)
From: Ryan Travis Tate <ryantate@OCF.Berkeley.EDU>
Subject: Re: last index of array reference
Message-Id: <bp0ukc$236d$1@agate.berkeley.edu>
Ryan Tate <ryantate@ryantate.com> wrote:
| At this point, in my code, which must run under taint mode, I have
| reverted to using ((length @$arrayref) - 1).
Erm, after re-reading the thread, I have switched to the significant
less brain dead $#{$arrayref}, which seems to work just fine, taint or
no. No point, I suppose, worrying why the other version works in some
cases but not others. IIRC & FWIW, the only reason I thought to do it
that way was I saw someone else do something like $#{1 .. 3}, which as
it turns out itself produces interesting results.
------------------------------
Date: 13 Nov 2003 14:42:32 -0800
From: hosshp@yahoo.com (Randy)
Subject: List into hash
Message-Id: <3d4770c2.0311131442.26368d0d@posting.google.com>
I am trying to take a list of domains and put them into a listing and
keep track of how many are repeated. I thought a hash would be the
easiest way to do this. I was wondering if anyone had any advice on
how to take the list I have, put each item in the list into the hash
without putting one in more then once, and then if it does show up
more then once, to add the value of the key of that item by one?
Sorry if this sounds confusing, I know what I'm trying to do, it's
just hard to explain it.
Thanks!
------------------------------
Date: Thu, 13 Nov 2003 22:47:12 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: List into hash
Message-Id: <bp11lg$fmg$5@wisteria.csv.warwick.ac.uk>
hosshp@yahoo.com (Randy) wrote:
> I am trying to take a list of domains and put them into a listing and
> keep track of how many are repeated. I thought a hash would be the
> easiest way to do this. I was wondering if anyone had any advice on
> how to take the list I have, put each item in the list into the hash
> without putting one in more then once, and then if it does show up
> more then once, to add the value of the key of that item by one?
my %domains;
my @domains = get_domain_list;
$domains{$_}++ for @domains;
print "domain $_: $domains{$_} times\n" for keys %domains;
Ben
--
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t # ben@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.
------------------------------
Date: 13 Nov 2003 21:38:37 GMT
From: ctcgag@hotmail.com
Subject: Re: long running perl programs & memory untilization
Message-Id: <20031113163837.417$N1@newsreader.com>
Stan Brown <stanb@panix.com> wrote:
>
> Thanks. The latest one of these "long running" scripts to exhibit this
> behavior, is really quite simple, in what it does, and has no real
> complex data structures.
>
> I suppose it would be inappropriate to post it here for criticism, right?
As long as the script is short and strict, it wouldn't be at all
inappropriate. Does the script run full-bore for months, or is it some
kind of server-like thing that spends most of it's time waiting?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Thu, 13 Nov 2003 20:26:29 GMT
From: Darin McBride <dmcbride@naboo.to.org.no.spam.for.me>
Subject: Re: Perl one-line equivalent to awk; multiple commands triggered by a search condition
Message-Id: <VNRsb.383684$pl3.304613@pd7tw3no>
J.W. wrote:
>
> In awk, I can easily do multiple commands based on a search condition:
> awk '/searchtext/ {x="hello"; print x;}'
>
> I'd like to do the same thing in a one line Perl script using the
> "-ne" option.
>
> This doesn't work:
> perl -ne '{$x="hello"; print $x;} if /searchtext/'
perl -ne 'if(/searchtext/){$x="hello";print $x;}' file1 file2...
> However, "comma" seems to work. Is this the correct way to do it?
> perl -ne '$x="hello" , print $x if /searchtext/'
That will work, too.
HTH
------------------------------
Date: 13 Nov 2003 19:54:35 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Problem with IO::Socket::INET and pop
Message-Id: <Xns943297ACCD5FBasu1cornelledu@132.236.56.8>
Ben Morrow <usenet@morrow.me.uk> wrote in
news:bp0jvq$a1k$1@wisteria.csv.warwick.ac.uk:
>
> "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote:
>> <blockquote>
>> A sample socket creation looks like:
>>
>> use IO::Socket::INET;
>> my $connection = IO::Socket::INET->new(@parameters)
>> or die "Cannot connect: $@";
>>
>> The @parameters will be described in a moment. Note that the error
>> comes back in $@, not $!. (Some have argued that this is a misdesign,
>> either on Perl's part or on the author's part, but we're stuck with
>> the inconsistency either way.)
>> </blockquote>
>
> I didn't know about that... thank you.
>
> Am I correct that this is not mentioned in the standard docs, or am I
> simply stupid... :) ?
It is in the IO::Socket::INET examples but I haven't seen it mentioned
elsewhere. And, I remember being confused about the meaningless error
messages printed by my programs when I was using $!.
HTH.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Thu, 13 Nov 2003 19:45:56 +0100
From: =?iso-8859-1?Q?Roland_M=F6sl?= <founder@pege.org>
Subject: Re: Wrong statement
Message-Id: <3fb3d735$0$32940$91cee783@newsreader01.highway.telekom.at>
> > This statement is wrong
> >
> > $display =~ s/\//\ \ \; \/\ \ \; /g;
> >
> > It was in a sub routine and caused about
> >
> > 500 MB memory usage after 2000 calls
>
> How many times are you doing that substitution on the same string?
Not the same, the sub is calle always with different parameters
--
Roland Mösl
http://www.pege.org Clear targets for a confused civilization
http://web-design-suite.com Web Design starts at the search engine
------------------------------
Date: Thu, 13 Nov 2003 14:32:14 -0500
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: Wrong statement
Message-Id: <3FB3DC3E.8020708@gwu.edu>
Roland Mösl wrote:
>>> This statement is wrong
>>>
>>> $display =~ s/\//\ \ \; \/\ \ \; /g;
>>>
>>> It was in a sub routine and caused about
>>>
>>> 500 MB memory usage after 2000 calls
>>
>>How many times are you doing that substitution on the same string?
>
>
> Not the same, the sub is calle always with different parameters
>
Are you sure $display has what you think it has? My guess,
knowing absolutely nothing about your program, is that you're
not using "use strict", you haven't declared $display with my()
(and it is therefore global) and every call you make, you're
running that substitution again over the same data in $display.
Since you won't post any relevant data, I have no way of tellling
if I'm right, but that's my guess.
Chris Mattern
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 5796
***************************************