[22281] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4502 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 2 14:05:45 2003

Date: Sun, 2 Feb 2003 11:05:11 -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           Sun, 2 Feb 2003     Volume: 10 Number: 4502

Today's topics:
    Re: Attitude to Perl in academia <bart.lateur@pandora.be>
    Re: Attitude to Perl in academia <ubl@schaffhausen.de>
    Re: Best way to set up option files Andrew Lee
    Re: Finding out whether program is running. (Ben Morrow)
        giving up after successful match? <mpapec@yahoo.com>
    Re: giving up after successful match? (h\)
    Re: giving up after successful match? (Tad McClellan)
    Re: giving up after successful match? (Tad McClellan)
    Re: giving up after successful match? (h\)
    Re: giving up after successful match? <mpapec@yahoo.com>
    Re: giving up after successful match? <mpapec@yahoo.com>
    Re: giving up after successful match? <mpapec@yahoo.com>
    Re: Hashes - OT (Mark007)
    Re: Hashes - OT Andrew Lee
    Re: Hashes <bart.lateur@pandora.be>
    Re: How to echo verbatim lines to output (h\)
    Re: How to echo verbatim lines to output <fma@doe.carleton.ca>
    Re: inconsistent handling of undefined values? Andrew Lee
        MLWP <pons@gmx.li>
    Re: MLWP <wembley06@yahoo.fr>
    Re: MLWP <pons@gmx.li>
    Re: MLWP <pons@gmx.li>
    Re: MLWP (Ben Morrow)
    Re: my sorting is slow <goldbb2@earthlink.net>
    Re: my sorting is slow <abigail@abigail.nl>
    Re: Net::Telnet - 'unknown terminal type network' error <jay@rgrs.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 02 Feb 2003 13:22:32 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Attitude to Perl in academia
Message-Id: <bm6q3v4a35eud4kqa13modkq6g36c3rssq@4ax.com>

Pierre Asselin wrote:

>In <3E3B5212.1BCF0163@earthlink.net> Benjamin Goldberg <goldbb2@earthlink.net> writes:
>>Show me even one standard module where circular refs are used.
>
>There are such modules in CPAN, for example HTML::TreeBuilder .  Their documentation
>warn about the circularity and they provide ->delete() methods to reclaim the memory.

In such cases, the new tool utility to make references weak, can fix
that. Make the parent reference the child with a normal (hard)
reference, link back from the child to the parent with a weak reference,
and you no longer have to think about it any more.

Weak references were introduced in the module WeakRef, but later, it has
been assimilated into Scalar::Util.

-- 
	Bart.


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

Date: Sun, 02 Feb 2003 18:05:55 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Attitude to Perl in academia
Message-Id: <b1jmd5$10h$1@news.dtag.de>

Benjamin Goldberg wrote:
>>    Actually, I think you'll find that Perl does have a typing system,
>>but it's of the form of languages like ML or Smalltalk; it's an
>>implicit typing system.
> 
> 
> No -- with ML and Smalltalk, every variable's type is inferred *at the
> time that the function is typed in*... in other words, at compile time.

Are you sure about this?

This should be valid Smalltalk:

| var |

var := 1;
var := 'String';

Smalltalk is only type-safe at runtime. Thats why method parameters are 
often called aString or aFooObject, so you can see what you should pass 
to the function; it won't be checked at compile time though. That'd be 
really bad, because Smalltalk doesn't have Java like Interfaces. So, 
thinks like delegation to objects which share a common interface would 
not be possible (unless they share a common superclass).

Actually, I think that some Smalltalk Implementation even have a method 
in Object called:
changeClassToThatOf: aSymbol
which is, as far as I know, not possible in Perl (One could hack around 
it doing tricks with ISA, I guess).

I agree with the rest of your arguments, though.

Greetings,
->malte



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

Date: Sun, 02 Feb 2003 12:45:31 -0500
From: Andrew Lee
Subject: Re: Best way to set up option files
Message-Id: <29lq3v478orlqa7c8t3jdb4a0mv2u4t8ja@4ax.com>

On 2 Feb 2003 00:32:18 -0500, jester@panix.com (Jesse Sheidlower) wrote:

>
>I've inherited a group of programs that need to be refactored,
>and I'm trying to figure out the best way to do it. They're
>all relating to Web-based database management. The way it was
>set up, there are various configuration files for different
>projects, called things like sales.conf and clients.conf; each
>one basically has a single %config hash that contains assorted
>set-up info, like:
>
>$config{'TEMPLATE_PATH'}    = "$config{'BASE_PATH'}/templates";
>$config{'LOG_PATH'}         = "$config{'BASE_PATH'}/logs";
>$config{'CGI_URL'}          = "/cgi-bin/sales/";
>$config{'DB_NAME'}          = 'sales';
>$config{'DB_USER'}          = 'sales';
>$config{'DB_PASS'}          = 'salespasswd';
>
>and so forth. A CGI program that uses a particular database will
>then have at the start a BEGIN { require "/path/to/sales.conf"; }.
>Then, general modules will use the %config hash, so that the
>main database-handling module begins,

You will want to build the hash outside the program ... see below.

>
>package DBhandling;
>
>use strict;
>use DBI;
>
>my $host_name = $main::config{'DB_HOST'};
>my $db_name = $main::config{'DB_NAME'};

I got tired of seeing everyone's database password at the top of a CGI
script so I spun this up to hide that bit of crucial information.  It is
mysql specific -- but can be easily genralized.  It is not terribly well
written -- but not too shabby either -- the main ideas come from the
Perl Cookbook by Tom Christiansen.  I've been meaning to fiddle with it
some more but it works for me as is.  I am certain you can play with the
idea so that you can make all your configuration information available
via some hash -- saving you fram having to cut and paste it over and
over.


#!/usr/bin/perl -w
use strict;
use DBI;

package DBConf;
require Exporter;

our $VERSION = "0.3";
our @ISA = qw/Exporter/;
our @EXPORT = qw/new get_dbh setVars/;

=head1 DBConf

DbConf.pm is a simple utility that allows you specify arguments to the
DBD::mysql connect
method via a hash or a configuration file.

=cut

=head2 Usage

my $conf = new DbConf ('dbdriver' =E<gt> 'mysql', 'dbname' =E<gt>
'mydatabase');

my $conf = new DbConf ('myconfigfile');

my $DBhandle = $conf-E<gt>get_dbh();

my $DBhandle = $conf-E<gt>get_dbh(%attr);

=cut

=head2 Configuration Files

DbConf expects a configuration file in the form :

flag1=value1

flag2=value2

flag3=value3

It ignors blank lines or lines that start with a pound sign.

=cut

sub new {
	my $classname = shift;
	my $class = ref($classname) || $classname;
	my $self = { };
	bless($self, $class);
	if(@_) {
		$self->_init(@_);
	} 
	return $self;
}


sub _init {
	my $self = shift;
	if (-f $_[0]) {
		my $filename = shift;	
		my @config_array;
		open (FH, "<$filename") or die "Could not open config file $!";
		while(my $line = <FH>) { 
			chomp ($line); 
			$line =~ s/\s+//g;			# eat whitespace
			if ($line =~ /^&/) { next }	# skip blank lines	
			if ($line =~ /^\s*#/) { next }	# skip commented lines	
			push @config_array, $line;
		}
		close FH or die "error closing file : $!";
# this is the magical config hash
		my %config_options = map {split /=/} @config_array;
		@$self{keys %config_options} = values %config_options;
	} else { # not a file
		# create a hash of whatever is passed
		my %config_options = @_;
		@$self{keys %config_options} = values %config_options;
	}
}

sub get_dbh {
	my $self = shift;
	my $attr = {};
	$attr = shift;	# hasref of extra attributes passed
	#  take a fair guess
	my $dbdriver = $self->{dbdriver} || "mysql";
	my $dbname = $self->{dbname} || "mysql";
	my $dbhost = $self->{dbhost} || "localhost";
	my $dbport = $self->{dbport} || "3306"; 
	my $dbuser = $self->{dbuser} || "";
	my $dbpass = $self->{dbpass} || "";			# maybe anonymous users
can select ??

	my $dbh = DBI->connect("DBI:$dbdriver:$dbname;$dbhost;$dbport",
			$dbuser, $dbpass, %$attr) or die DBI::errstr;

	return $dbh;
}

sub setVars {
	my $self = shift;

	$self->Usage() unless @_;

	$self->_init(@_);
}

sub Usage {
	
	print "Usage : my \$conf = new DbConf('filename') or my \$conf = new
DbConf(\$hashref);\n\n";

}	



1;
__END__


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

Date: Sun, 2 Feb 2003 15:38:03 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Finding out whether program is running.
Message-Id: <b1je0r$blq$1@wisteria.csv.warwick.ac.uk>

b_duke@octa4.net.invalid (Brian Salter-Duke) wrote:
>On 1 Feb 2003 15:41:30 GMT, Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> wrote:
>> In article <6sM_9.1586$YU1.37055@news.optus.net.au>,
>> Brian Salter-Duke <b_duke@octa4.net.invalid> wrote:
>>:I have this problem. From within a perl script I need to know whether a
>>:particular program is actually running.
>
<snip>
>
>Someone else asked about using a pid file for the daemon. I am starting
>the daemon but it sometimes dies without deleting the pid file, so that
>test is not good enough.

The person who suggested a pid file said 'check if the pid file exists _and_
if the process named therein still exists'.

You may want to add more checks, such as checking the name of the process,
checking its UID, and checking it has been running since the pid file was
created, in case a stale pidfile is around for a while and pids wrap around.

Ben


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

Date: Sun, 02 Feb 2003 14:58:28 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: giving up after successful match?
Message-Id: <7j4q3vscpsj0tcv4g5qndlovp16jjcij53@4ax.com>

$cfg = q{
key1=val1
key2=val2
key3=val3
};

I want to replace values in $cfg but only these which exists in %Q

$cfg =~ s/(\w+)(=.*)/exists $Q{$1} : "$1=$Q{$1}" ? "$1$2"/gex;
this works, but I would rather write something like:
$cfg =~ s/(\w+)=.*/exists $Q{$1} : "$1=$Q{$1}" ? do_nothing/gex;

or should I first do plain m// match with checks and s/// after that?



-- 
Matija


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

Date: Sun, 2 Feb 2003 15:55:21 +0100
From: "Michael Peuser \(h\)" <post@mpeuser.de>
Subject: Re: giving up after successful match?
Message-Id: <b1jbeq$nid$03$1@news.t-online.com>


"Matija Papec" <mpapec@yahoo.com> schrieb im Newsbeitrag
news:7j4q3vscpsj0tcv4g5qndlovp16jjcij53@4ax.com...
> $cfg = q{
> key1=val1
> key2=val2
> key3=val3
> };
>
> I want to replace values in $cfg but only these which exists in %Q
>
> $cfg =~ s/(\w+)(=.*)/exists $Q{$1} : "$1=$Q{$1}" ? "$1$2"/gex;
> this works, but I would rather write something like:
> $cfg =~ s/(\w+)=.*/exists $Q{$1} : "$1=$Q{$1}" ? do_nothing/gex;
>
> or should I first do plain m// match with checks and s/// after that?
>

There of course is the "brute" force method:

 my $checks= join '|', keys %Q;
 $cfg =~ s/($checks)=.*/$1=$Q{$1}/g;

But benchmark it before - it might take some time if there are some thousend keys in %Q
You might improve it by /o if  %Q is fixed.

I wonder why you used /x? A matter of  habit?
Or do you want to have this:
 $cfg =~ s/($checks)\s*=\s*.*/$1=$Q{$1}/g;


Kindly
Mike




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

Date: Sun, 2 Feb 2003 09:28:16 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: giving up after successful match?
Message-Id: <slrnb3qe8g.ffl.tadmc@magna.augustmail.com>

Matija Papec <mpapec@yahoo.com> wrote:

> $cfg =~ s/(\w+)(=.*)/exists $Q{$1} : "$1=$Q{$1}" ? "$1$2"/gex;
                                     ^             ^
                                     ^             ^
> this works


Really?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 2 Feb 2003 09:40:24 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: giving up after successful match?
Message-Id: <slrnb3qev8.ffl.tadmc@magna.augustmail.com>

Matija Papec <mpapec@yahoo.com> wrote:
> $cfg = q{
> key1=val1
> key2=val2
> key3=val3
> };
> 
> I want to replace values in $cfg but only these which exists in %Q


Consider converting $cfg into a real hash, %cfg. Then it
would get much easier:

   # populate %cfg first
   @cfg{ keys %Q } = values %Q;   # hash slice

That overwrites any of %cfg's values that have a corresponding key
in %Q, but it will also add any pairs that happen to be in %Q
but not in %cfg...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 2 Feb 2003 17:07:51 +0100
From: "Michael Peuser \(h\)" <post@mpeuser.de>
Subject: Re: giving up after successful match?
Message-Id: <b1jfmp$ugt$01$1@news.t-online.com>


"Tad McClellan" <tadmc@augustmail.com> schrieb im Newsbeitrag
news:slrnb3qev8.ffl.tadmc@magna.augustmail.com...
> Matija Papec <mpapec@yahoo.com> wrote:
> > $cfg = q{
> > key1=val1
> > key2=val2
> > key3=val3
> > };
> >
> > I want to replace values in $cfg but only these which exists in %Q
>
>
> Consider converting $cfg into a real hash, %cfg. Then it
> would get much easier:
>
>    # populate %cfg first
>    @cfg{ keys %Q } = values %Q;   # hash slice
>
> That overwrites any of %cfg's values that have a corresponding key
> in %Q, but it will also add any pairs that happen to be in %Q
> but not in %cfg...

 .. and this is probably NOT what the OP wants.

But
       foreach (keys  %cfg) { $cfg{$_} = $Q{$_} if exists $Q{$_}}

if you can live with a loop.... I think there is no other way in cutting hashes.

Kindly Mike




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

Date: Sun, 02 Feb 2003 19:40:05 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: giving up after successful match?
Message-Id: <ismq3vca2khqqca2rte5k97ub7an33a6b6@4ax.com>

X-Ftn-To: Michael Peuser (h) 

"Michael Peuser \(h\)" <post@mpeuser.de> wrote:
>> $cfg =~ s/(\w+)(=.*)/exists $Q{$1} : "$1=$Q{$1}" ? "$1$2"/gex;
>> this works, but I would rather write something like:
>> $cfg =~ s/(\w+)=.*/exists $Q{$1} : "$1=$Q{$1}" ? do_nothing/gex;
>>
>> or should I first do plain m// match with checks and s/// after that?
>>
>
>There of course is the "brute" force method:
>
> my $checks= join '|', keys %Q;
> $cfg =~ s/($checks)=.*/$1=$Q{$1}/g;
>
>But benchmark it before - it might take some time if there are some thousend keys in %Q
>You might improve it by /o if  %Q is fixed.

I'll try that. %Q is rather small and "brute force" shouldn't take much
time.

>I wonder why you used /x? A matter of  habit?
>Or do you want to have this:
> $cfg =~ s/($checks)\s*=\s*.*/$1=$Q{$1}/g;

No, I used it to ignore whitespaces in right part of substitution; at least
I used to think that /x does such thing.<blush>


-- 
Matija


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

Date: Sun, 02 Feb 2003 19:40:04 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: giving up after successful match?
Message-Id: <rioq3v43et2v9qgmuk03kfei6k34gfb9g9@4ax.com>

X-Ftn-To: Tad McClellan 

tadmc@augustmail.com (Tad McClellan) wrote:
>Matija Papec <mpapec@yahoo.com> wrote:
>
>> $cfg =~ s/(\w+)(=.*)/exists $Q{$1} : "$1=$Q{$1}" ? "$1$2"/gex;
>                                     ^             ^
>                                     ^             ^
>> this works
>
>Really?

Well, not really. :)



-- 
Matija


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

Date: Sun, 02 Feb 2003 19:40:07 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: giving up after successful match?
Message-Id: <4loq3v0kvdp3c6u28redl9qnhes1lfpp00@4ax.com>

X-Ftn-To: Tad McClellan 

tadmc@augustmail.com (Tad McClellan) wrote:
>> I want to replace values in $cfg but only these which exists in %Q
>
>Consider converting $cfg into a real hash, %cfg. Then it
>would get much easier:
>
>   # populate %cfg first
>   @cfg{ keys %Q } = values %Q;   # hash slice
>
>That overwrites any of %cfg's values that have a corresponding key
>in %Q, but it will also add any pairs that happen to be in %Q
>but not in %cfg...

That is the problem, %Q has some keys which should not be in %cfg, but tnx
for idea.


-- 
Matija


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

Date: Sun, 2 Feb 2003 07:30:00 -0500 (EST)
From: sisley3@webtv.net (Mark007)
Subject: Re: Hashes - OT
Message-Id: <29334-3E3D0F48-324@storefull-2178.public.lawson.webtv.net>

Actually, it's not me that wants webtv....my parents don't want to sign
up for computer internet service for some reason...I'm stuck with the
webtv, even though I'm the one that uses it the most.

Mark



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

Date: Sun, 02 Feb 2003 12:49:33 -0500
From: Andrew Lee
Subject: Re: Hashes - OT
Message-Id: <7gmq3vovuussr6tjkhitcge6cunsej37sa@4ax.com>

On Sun, 2 Feb 2003 07:30:00 -0500 (EST), sisley3@webtv.net (Mark007)
wrote:

>Actually, it's not me that wants webtv....my parents don't want to sign
>up for computer internet service for some reason...I'm stuck with the
>webtv, even though I'm the one that uses it the most.
>

Just lay off that geriatric porn

:-)




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

Date: Sun, 02 Feb 2003 13:00:00 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Hashes
Message-Id: <pg5q3vkqicfqrtebtpq8keqpjnhg3vndk7@4ax.com>

Mark007 wrote:

>Ok, I'm sorry to be such a newbie, but could someone please explain to
>me the value of hashes? I don't quite understand them yet, and any help
>would be appreciated..

Basically, they're in-memory databases. You can very quickly find any
record by whatever you choose as an ID.

-- 
	Bart.


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

Date: Sun, 2 Feb 2003 12:20:49 +0100
From: "Michael Peuser \(h\)" <post@mpeuser.de>
Subject: Re: How to echo verbatim lines to output
Message-Id: <b1iusl$fik$04$1@news.t-online.com>

Hi Fred,

for a tutorial I generally recommend
   Roberts's Perl Tutorial
It is 4 years old and has some bias to Win32, but the Perl part
is universal and imho still correct
You find it in different places, e.g.

http://www.sthomas.net/roberts-perl-tutorial.htm

But:
There is no escape from LEARNING Perl! There are a lot of books,
one of them might suit you - not necessarily the Camel Book  ;-)
but maybe the Cookbook....

Kindly Mike




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

Date: Sun, 02 Feb 2003 12:00:45 -0500
From: fred <fma@doe.carleton.ca>
Subject: Re: How to echo verbatim lines to output
Message-Id: <3E3D4EBD.5080900@doe.carleton.ca>



Michael Peuser (h) wrote:
> Hi Fred,
> 
> for a tutorial I generally recommend
>    Roberts's Perl Tutorial
> It is 4 years old and has some bias to Win32, but the Perl part
> is universal and imho still correct
> You find it in different places, e.g.
> 
> http://www.sthomas.net/roberts-perl-tutorial.htm
> 
> But:
> There is no escape from LEARNING Perl! There are a lot of books,
> one of them might suit you - not necessarily the Camel Book  ;-)
> but maybe the Cookbook....
> 
> Kindly Mike
> 
> 

Thanks, Mike.

Fred



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

Date: Sun, 02 Feb 2003 12:59:24 -0500
From: Andrew Lee
Subject: Re: inconsistent handling of undefined values?
Message-Id: <ksmq3v0g86dd98kms4m5tvoo6fj1d7nr37@4ax.com>

On Sun, 2 Feb 2003 11:01:37 +0000, RA Jones <ra.jones@NO_UCE*cwcom.net>
wrote:

>In message <3199358.653l2p2OUZ@nyoga.dubu.de>, Harald H.-J. Bongartz 
><bongie@gmx.net> writes
>>RA Jones wrote:
>>> But why does Perl hang when I try to print an undefined value, despite
>>> using 'strict', '-w' and CGI::Carp(fatalsToBrowser)?
>>
>>What do you mean by 'hang'?
>The browser task bar says 'Sending request to 127.0.0.1....' 
>indefinitely, and the browser continues to wait for a reply. A Perl 
>session remains open in the task manager and needs a manual 'End 
>process' to close it.

Do you have a rouge while loop ???   Are you waiting for input in a
while loop and never getting it?

e.g. while (<STDIN>) { ... } _before_ you have finished printing a form
or somesuch? 



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

Date: Sun, 2 Feb 2003 15:17:04 +0200
From: "Pons" <pons@gmx.li>
Subject: MLWP
Message-Id: <b1j5dg$13ja4l$1@ID-172702.news.dfncis.de>

$ perl -MLWP
Can't locate LWP.pm in @INC (@INC contains:
/usr/local/lib/perl5/site_perl/5.005/i386-freebsd
/usr/local/lib/perl5/site_perl/5.005 . /usr/libdata/perl/5.00503/mach
/usr/libdata/perl/5.00503).
BEGIN failed--compilation aborted.
any help?

-Pons
pons@gmx.li





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

Date: Sun, 2 Feb 2003 14:30:28 +0100
From: "Julian" <wembley06@yahoo.fr>
Subject: Re: MLWP
Message-Id: <3e3d1d70$0$238$626a54ce@news.free.fr>

Did you installed LWP module ?
If yes, check the folder where it is installed in, and put it in the PATH
(@INC)


"Pons" <pons@gmx.li> a écrit dans le message de news:
b1j5dg$13ja4l$1@ID-172702.news.dfncis.de...
> $ perl -MLWP
> Can't locate LWP.pm in @INC (@INC contains:
> /usr/local/lib/perl5/site_perl/5.005/i386-freebsd
> /usr/local/lib/perl5/site_perl/5.005 . /usr/libdata/perl/5.00503/mach
> /usr/libdata/perl/5.00503).
> BEGIN failed--compilation aborted.
> any help?
>
> -Pons
> pons@gmx.li
>
>
>




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

Date: Sun, 2 Feb 2003 15:46:20 +0200
From: "Pons" <pons@gmx.li>
Subject: Re: MLWP
Message-Id: <b1j74d$134kuq$1@ID-172702.news.dfncis.de>

I ll check it ..
-Pons
"Julian" <wembley06@yahoo.fr> wrote in message
news:3e3d1d70$0$238$626a54ce@news.free.fr...
> Did you installed LWP module ?
> If yes, check the folder where it is installed in, and put it in the PATH
> (@INC)
>

>
> "Pons" <pons@gmx.li> a écrit dans le message de news:
> b1j5dg$13ja4l$1@ID-172702.news.dfncis.de...
> > $ perl -MLWP
> > Can't locate LWP.pm in @INC (@INC contains:
> > /usr/local/lib/perl5/site_perl/5.005/i386-freebsd
> > /usr/local/lib/perl5/site_perl/5.005 . /usr/libdata/perl/5.00503/mach
> > /usr/libdata/perl/5.00503).
> > BEGIN failed--compilation aborted.
> > any help?
> >
> > -Pons
> > pons@gmx.li
> >
> >
> >
>
>




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

Date: Sun, 2 Feb 2003 16:10:59 +0200
From: "Pons" <pons@gmx.li>
Subject: Re: MLWP
Message-Id: <b1j8il$13lh0o$1@ID-172702.news.dfncis.de>

On a FreeBSD
#perl -MCPAN -e shell;
 .....
Are you ready for manual configuration? [yes] no
Prototype mismatch: sub CPAN::FirstTime::prompt ($;$) vs none at
/usr/libdata/perl/5.00503/CPAN/FirstTime.pm line 85, <STDIN> chunk 1.
 .....
commit: wrote /usr/libdata/perl/5.00503/CPAN/Config.pm

cpan shell -- CPAN exploration and modules installation (v1.48)
ReadLine support available (try ``install Bundle::CPAN'')

cpan> install Bundle::CPAN
 .....
Not connected.
Not connected.
Bad luck... Still failed!
Can't access URL ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz.

Please check, if the URLs I found in your configuration file () are valid.
The urllist can be edited. E.g. with ``o conf urllist push ftp://myurl/''

Cannot fetch modules/03modlist.data.gz

Can't install Bundle::CPAN, don't have an associated bundle file. :-(
 at /usr/libdata/perl/5.00503/CPAN.pm line 1717

-Pons
pons@gmx.li


"Pons" <pons@gmx.li> wrote in message
news:b1j74d$134kuq$1@ID-172702.news.dfncis.de...
> I ll check it ..
> -Pons
> "Julian" <wembley06@yahoo.fr> wrote in message
> news:3e3d1d70$0$238$626a54ce@news.free.fr...
> > Did you installed LWP module ?
> > If yes, check the folder where it is installed in, and put it in the
PATH
> > (@INC)
> >
>
> >
> > "Pons" <pons@gmx.li> a écrit dans le message de news:
> > b1j5dg$13ja4l$1@ID-172702.news.dfncis.de...
> > > $ perl -MLWP
> > > Can't locate LWP.pm in @INC (@INC contains:
> > > /usr/local/lib/perl5/site_perl/5.005/i386-freebsd
> > > /usr/local/lib/perl5/site_perl/5.005 . /usr/libdata/perl/5.00503/mach
> > > /usr/libdata/perl/5.00503).
> > > BEGIN failed--compilation aborted.
> > > any help?
> > >
> > > -Pons
> > > pons@gmx.li
> > >
> > >
> > >
> >
> >
>
>




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

Date: Sun, 2 Feb 2003 15:44:13 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: MLWP
Message-Id: <b1jecd$bqh$1@wisteria.csv.warwick.ac.uk>

"Pons" <pons@gmx.li> wrote:
>On a FreeBSD
>#perl -MCPAN -e shell;
>.....
>Are you ready for manual configuration? [yes] no

Um, why did you say no? You have to configure it before you can use it...

Please don't top-post.

Ben


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

Date: Sun, 02 Feb 2003 12:27:55 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: my sorting is slow
Message-Id: <3E3D551B.91452B9F@earthlink.net>

someuser wrote:
> 
> why is this sorting so damn slow?

Because you're doing bubble-sort, which runs in O(N**2) time.

Use perl's sort, which runs in O(N log N) time.

> I'm tring to sort out a table by column.

There is an answer in the faq for how to do that.

> yeah, I know, lots of for loops.
> what's better?

Use a Schwartzian Transform.

my $sortsub =
   $FORM{sortMethod} eq "numeric" ?
   sub { $a->[1] <=> $b->[1] } :
   sub { $a->[1] cmp $b->[1] } ;
my $stripsub = 
   $FORM{sortMethod} eq "numeric" ?
   sub { $_[0] =~ tr/0-9//cd } :
   sub { $_[0] =~ tr/a-zA-Z0-9 \t\n//cd };
my @sorted =
   map $$_[1],
   sort &$sortsub
   map {
      my $thecol = (split /\|/)[$FORM{column}];
      $stripsub->($thecol);
      [ $_, $thecol ];
   }
   @db;
[untested]

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: 02 Feb 2003 17:30:22 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: my sorting is slow
Message-Id: <slrnb3qlde.ffe.abigail@alexandra.abigail.nl>

Benjamin Goldberg (goldbb2@earthlink.net) wrote on MMMCDXLII September
MCMXCIII in <URL:news:3E3D551B.91452B9F@earthlink.net>:
 ..  someuser wrote:
 .. > 
 .. > why is this sorting so damn slow?
 ..  
 ..  Because you're doing bubble-sort, which runs in O(N**2) time.
 ..  
 ..  Use perl's sort, which runs in O(N log N) time.

These two statements together don't mean anything. Perl sort also runs
on O (N**2) time. And they both run in O (N**3).

The problem with bubble-sort is that its O (N**2) upperbound is also
tight. 

Note also that Perl's sort has been O (N log N) only since 5.8. In
5.6 and before, quicksort was used, which has a tight upperbound
of O (N**2).


Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54\n" and s/<<EOT/<<EOT/ee and print;
"Just another Perl Hacker"
EOT


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

Date: 02 Feb 2003 11:30:52 -0500
From: Jay Rogers <jay@rgrs.com>
To: jwillmore@cyberia.com (James Willmore)
Subject: Re: Net::Telnet - 'unknown terminal type network' error
Message-Id: <kwp65s2ir0j.fsf@panix5.panix.com>

jwillmore@cyberia.com (James Willmore) writes:
> While using Net::Telnet, I got the following message in my input log:
> ====BEGIN LOG=================
> AUTHORIZED USE ONLY
> 
> 
> maxine login: jim
> Password: 
> You have new mail in /var/mail/jim.
> Last login: Sun Jan 26 13:25:47 from localhost
> 
> CONNECTIONS ARE LOGGED AND MONITORED
> 
> tset: unknown terminal type network
> Terminal type? 

The command "tset" is being run from a shell init file for user
"jim".  "tset" is prompting and waiting for you to enter a
terminal type.

You've got three choices to deal with this (ordered from easiest
to hardest):

  1. Change the remote user's shell initialization to *not* invoke
     the tset command.

  2. Instead of using login() to login, use a combination of
     waitfor() and print().

  3. Have Net::Telnet send the term type during initial telnet
     negotiation (see example below).

     The problem with setting the terminal type to something like
     "vt100" is that the remote side will then send terminal
     escape sequences interspersed with the data.  This generally
     makes it more difficult to extract the information you're
     looking for.

Here's some code that demonstrates how to send the terminal type
on initial telnet negotiation.  This code only works for
Net::Telnet v3.03 or later since it uses put().  An older example
of this code posted to a comp.lang.perl newsgroup doesn't work
for v3.03 or later.

    ## Module import.
    use Net::Telnet qw(TELNET_IAC TELNET_SB TELNET_SE TELOPT_TTYPE);

    ## Global variables.
    my $Term = "vt100";

    ## Main program.
    {
        my($host, $username, $passwd) = @ARGV;
        die "usage: $0 host username passwd\n" unless @ARGV == 3;
        my $t;

        $t = new Net::Telnet (Prompt => '/\$ $/',
                              Dump_log => "$ENV{HOME}/log.dump",
                              Option_log => "$ENV{HOME}/log.option");

        ## Set up callbacks to negotiate terminal type.
        $t->option_callback(sub {});
        $t->suboption_callback(\&subopt_callback);
        $t->option_accept(Do => TELOPT_TTYPE);

        ## Login and print value of TERM.
        $t->open($host);
        $t->login($username, $passwd);
        print "Remote TERM=", $t->cmd("printenv TERM");
        $t->close;

        exit;
    } # end main program


    sub subopt_callback {
        my ($t, $option, $parameters) = @_;
        my $telcmd;

        if ($option == TELOPT_TTYPE) {
            $telcmd = pack("C4 A* C2", TELNET_IAC, TELNET_SB, TELOPT_TTYPE, 0,
                           $Term, TELNET_IAC, TELNET_SE);
            $t->put(String => $telcmd,
                    Telnetmode => 0);
        }

        1;
    } # end sub subopt_callback


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

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


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