[19806] in Perl-Users-Digest
Perl-Users Digest, Issue: 2001 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 24 18:05:55 2001
Date: Wed, 24 Oct 2001 15:05:11 -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: <1003961111-v10-i2001@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 24 Oct 2001 Volume: 10 Number: 2001
Today's topics:
'bash : *.gif' with regex, any nice idea ? <process@club-internet.fr>
Re: 'bash : *.gif' with regex, any nice idea ? (Jason Kohles)
Re: CGI::Lite file upload corruption (Mark Jason Dominus)
Re: CPAN.pm complaining all the time (Stephen Patterson)
dynamic DBD::Oracle SELECT? <bing-du@tamu.edu>
Re: dynamic DBD::Oracle SELECT? <bing-du@tamu.edu>
Re: dynamic DBD::Oracle SELECT? <djberge@qwest.com>
GD::Graph plot keeps failing (adam denenberg)
Re: Jon Ericson <jurgenex@hotmail.com>
Re: Jon Ericson <jeff@vpservices.com>
Re: lookingglass.pl (Mark Jason Dominus)
Re: lookingglass.pl (Mark Jason Dominus)
Re: lookingglass.pl <tsee@gmx.net>
Re: Plaintext to passwd file? <plarkin@beth.k12.pa.us>
Re: Plaintext to passwd file? <plarkin@beth.k12.pa.us>
Re: Plaintext to passwd file? <tsee@gmx.net>
Telnet client in perl <news@scottbell.org>
Re: Telnet client in perl <joe+usenet@sunstarsys.com>
Transfer to & from remote machine using telnet (Anand Ramamurthy)
Re: Transfer to & from remote machine using telnet <spam@thecouch.homeip.net>
Re: What exactly will "make install" do for my module? (Stephen Patterson)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 24 Oct 2001 23:20:25 +0200
From: Laurent Stefan <process@club-internet.fr>
Subject: 'bash : *.gif' with regex, any nice idea ?
Message-Id: <3BD73099.1E99FF4B@club-internet.fr>
Hi,
I'd like to simulate a 'bash reg' like : *.gif in regex.
My script read a configuration file where tags HideFile can be found. So
the file or the 'bash reg' (I don't know how to call it) will be hide.
I keep all the file to hide in an array. then i proceed in a directory,
excluding the file defined with the HideFile.
I wrote something like this :
(Reading each line of the the configuration file)
...
if( $tag eq 'HideFile' ) { push( @hide, $value); }
...
...
$hidden = join("\|",@hide);
$hidden =~ s:\.:\\\.:g;
$hidden =~ s:\*:\(\.\*\):g;
...
(In a recursive readdir loop, if a file)
...
if($hidden ne '') {
push( @show , '$directory/$direntry' ) if ( $direntry !~ m:$hidden: );
} else {
push( @show , '$directory/$direntry' );
}
...
Maybe it's a way to do it, but i'm not satisfied with this (ugly and
maybe heavy and wrong in some case).
If somebody have an idea ... Thanks by advance.
------------------------------
Date: 24 Oct 2001 21:30:52 GMT
From: usenet@jasonkohles.com (Jason Kohles)
Subject: Re: 'bash : *.gif' with regex, any nice idea ?
Message-Id: <slrn9tecki.p2b.usenet@poseidon.mediabang.com>
On Wed, 24 Oct 2001 23:20:25 +0200, Laurent Stefan wrote:
>Hi,
>
>I'd like to simulate a 'bash reg' like : *.gif in regex.
>
>My script read a configuration file where tags HideFile can be found. So
>the file or the 'bash reg' (I don't know how to call it) will be hide.
>
perldoc -f glob
>I keep all the file to hide in an array. then i proceed in a directory,
>excluding the file defined with the HideFile.
>
>I wrote something like this :
>
>(Reading each line of the the configuration file)
>...
>if( $tag eq 'HideFile' ) { push( @hide, $value); }
>...
>
>...
>$hidden = join("\|",@hide);
>$hidden =~ s:\.:\\\.:g;
>$hidden =~ s:\*:\(\.\*\):g;
>...
>
>(In a recursive readdir loop, if a file)
>...
>if($hidden ne '') {
> push( @show , '$directory/$direntry' ) if ( $direntry !~ m:$hidden: );
>} else {
> push( @show , '$directory/$direntry' );
>}
>...
>
>Maybe it's a way to do it, but i'm not satisfied with this (ugly and
>maybe heavy and wrong in some case).
>If somebody have an idea ... Thanks by advance.
--
Jason S Kohles
email@jasonkohles.com http://www.jasonkohles.com/
------------------------------
Date: Wed, 24 Oct 2001 18:11:15 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: CGI::Lite file upload corruption
Message-Id: <3bd70443.a46$86@news.op.net>
In article <xxiB7.44062$1%.12043661@typhoon.nyroc.rr.com>,
Josh <<void@127.0.0.1> wrote:
>Okay, so if I hack Lite.pm like this, it works okay. Is there anyway around
>this with me not having to modify the CGI::Lite module (big portability
>issue)?
It sounds like it is a defect in CGI::Lite. I suggest that you send
your change to Benjamin Low, the author (b.d.low@ieee.org) and see
what he says.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Wed, 24 Oct 2001 19:28:14 BST
From: spam@freeuk.com (Stephen Patterson)
Subject: Re: CPAN.pm complaining all the time
Message-Id: <slrn9te23j.de.spam@localhost.localdomain>
On Tue, 23 Oct 2001 22:04:01 -0400, Benjamin Goldberg wrote:
> Lou Moran wrote:
>>
>> On a RH 6.2 machine whenever I run:
>>
>> # perl -MCPAN -e 'install Some::Module'
>>
>> CPAN complains that I don't have Net::FTP and could I install it
>> really soon and if I just install Bundle::libnet everything will be
>> fine, including Net::FTP.
>>
>> Dutifully I have installed Bundle::libnet which CPAN admits I have
>> everytime I try to install it (again,) but it always complains about
>> Net::FTP but won't let me install Net::FTP!
Have you tried just 'install Net::FTP'?
--
Stephen Patterson http://home.freeuk.net/s.patterson/
s.patterson@SPAM.freeuk.com (remove spam to reply)
ICBM address 54-22-0N 0-28-0W
------------------------------
Date: Wed, 24 Oct 2001 14:02:54 -0500
From: Bing Du <bing-du@tamu.edu>
Subject: dynamic DBD::Oracle SELECT?
Message-Id: <3BD7105E.84364613@tamu.edu>
Hi,
I'm using DBI/DBD::Oralce.
Is it possible that part of the WHERE clause is a variable? What should
be the correct syntax? The following SELECT I made up does not return
anything. (Note: depending on user's input, $where is constructed before
$sth=$dbh->prepare())
$sth = $dbh->prepare(
"SELECT
STU_COURSE.student_id,stu_email.email,stu_course.student_name,student_view.major,student_view.class,student_view.lphone
FROM STU_COURSE,student_view, stu_email where $where and
stu_course.student_id=stu_email.student_id and
stu_course.student_id=student_view.sid(+)"
);
Any ideas?
Bing
------------------------------
Date: Wed, 24 Oct 2001 14:45:57 -0500
From: Bing Du <bing-du@tamu.edu>
Subject: Re: dynamic DBD::Oracle SELECT?
Message-Id: <3BD71A75.94AF6C4@tamu.edu>
I figured it out. After adding single quotes around the values in $where, it worked just fine.
Bing
Bing Du wrote:
> Hi,
>
> I'm using DBI/DBD::Oralce.
>
> Is it possible that part of the WHERE clause is a variable? What should
> be the correct syntax? The following SELECT I made up does not return
> anything. (Note: depending on user's input, $where is constructed before
> $sth=$dbh->prepare())
>
> $sth = $dbh->prepare(
> "SELECT
> STU_COURSE.student_id,stu_email.email,stu_course.student_name,student_view.major,student_view.class,student_view.lphone
> FROM STU_COURSE,student_view, stu_email where $where and
> stu_course.student_id=stu_email.student_id and
> stu_course.student_id=student_view.sid(+)"
> );
>
> Any ideas?
>
> Bing
------------------------------
Date: Wed, 24 Oct 2001 16:00:06 -0500
From: "Mr. Sunblade" <djberge@qwest.com>
Subject: Re: dynamic DBD::Oracle SELECT?
Message-Id: <AVFB7.184$yw4.184952@news.uswest.net>
"Bing Du" <bing-du@tamu.edu> wrote in message
news:3BD71A75.94AF6C4@tamu.edu...
<snip>
> >
> > Is it possible that part of the WHERE clause is a variable? What should
> > be the correct syntax? The following SELECT I made up does not return
> > anything. (Note: depending on user's input, $where is constructed before
> > $sth=$dbh->prepare())
> >
> > $sth = $dbh->prepare(
> > "SELECT
> >
STU_COURSE.student_id,stu_email.email,stu_course.student_name,student_view.m
ajor,student_view.class,student_view.lphone
> > FROM STU_COURSE,student_view, stu_email where $where and
> > stu_course.student_id=stu_email.student_id and
> > stu_course.student_id=student_view.sid(+)"
> > );
> >
> > Any ideas?
Bing,
Consider using a placeholder instead of an interpolated statement.
e.g.
$sth = $dbh->prepare("
SELECT
STU_COURSE.student_id,stu_email.email,stu_course.student_name,student_view.m
ajor,student_view.class,student_view.lphone
FROM STU_COURSE,student_view, stu_email
?
AND stu_course.student_id=stu_email.student_id
AND stu_course.student_id=student_view.sid(+)"
);
$sth->bind_param(1, "WHERE stu_body = 'hot'");
$sth->execute();
You may have to replace the "?" with ":1". Book says it'll work, but Oracle
may complain (I'm guessing Oracle based on your outer join syntax there).
See the section entitled "Bind Values Versus Interpolated Statements" in Tim
Bunce's "Programming the Perl DBI" (O'Reilly & Associates), pp. 122-124 for
more info.
Regards,
Mr. Sunblade
------------------------------
Date: 24 Oct 2001 14:06:39 -0700
From: adam@dberg.org (adam denenberg)
Subject: GD::Graph plot keeps failing
Message-Id: <78526aa1.0110241306.3fe73fac@posting.google.com>
Hey,
I am using GD::Graph and I am trying to plot data from 2 stored
arrays, but it is failing
here is an example of what i am trying to do ..
code ..
#! /usr/local/bin/perl -w
use GD::Graph::area;
require 'save.pl';
@labels = ('label1', 'label2');
@vals = (1,2);
$my_graph = new GD::Graph::area(600,300);
$my_graph->set(
x_label => 'TIME OF DAY',
y_label => 'Percentage',
y_max_value => 100,
y_tick_number => 8,
y_label_skip => 2,
accentclr => 'green',
transparent => 0,
box_axis => 1,
show_values => 1,
x_labels_vertical => 1,
text_space => 4,
);
$my_graph->set_legend( '% number');
$my_graph->plot([@labels],[@vals]);
save_chart($my_graph, 'sample21');
#./testme.pl
gd-png: fatal libpng error: Invalid number of colors in palette
gd-png error: setjmp returns error condition
#
i have tried setting the plot method with both
([@labels],[@vals]) and (\@labels,\@vals).
and still no dice..
any help would be appreciated ..
Thanks
-adam
adam@dberg.org
------------------------------
Date: Wed, 24 Oct 2001 11:08:27 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Jon Ericson
Message-Id: <3bd7039f@news.microsoft.com>
"SJC" <cooperste@hotmail.com> wrote in message
news:143f4c01.0110240602.114c1450@posting.google.com...
In accordance with Pi's Law you just lost.
jue
------------------------------
Date: Wed, 24 Oct 2001 11:53:06 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Jon Ericson
Message-Id: <3BD70E12.7C5120CA@vpservices.com>
SJC wrote:
>
> Personally I think he is a idiot.
Perhaps by "a idiot", you meant "an idiot".
Perhaps "he" refers to yourself.
With those corrections, your post is still supremely clueless.
*plonk*
--
Jeff
------------------------------
Date: Wed, 24 Oct 2001 18:45:41 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: lookingglass.pl
Message-Id: <3bd70c54.b10$141@news.op.net>
In article <87hesuq9r1.fsf@abra.ru>, Ilya Martynov <ilya@martynov.org> wrote:
>I never use $#array because I think it looks ugly. Of course it is my
>'IMHO'.
Mine too.
But in my experience most uses of $#array become clearer when they are
rewritten with @array instead. For example, just today someone posted
an article (<3bd6d2ec.77079640@news) in which:
if ($#files > -1) {
...
}
Here I think
if (@files) {
...
}
is a clear improvement. (In this particular case, the entire 'if' was
superfluous, but in general it's not.) Another typical example is
if ($#array >= 3) {
my ($name, $date, $age, $salary) = @array;
...
} else {
die ...;
}
This would be better as:
if (@array >= 4) {
my ($name, $date, $age, $salary) = @array;
...
} else {
die ...;
}
Here's a real example that someone sent me for use in my class:
if ($#ARGV == 0) { chomp($flag=shift); } # $flag used for manual override
I think this is clearer:
if (@ARGV == 1) { chomp($flag=shift); } # $flag used for manual override
Here's another example, this time from article
<C1KA7.37706$ev2.44251@www.newsranger.com>. I added the indentation,
which was absent in the original code::
# The original total number of elements in the IP Log
$totalIPLogElements=$#IPLogArrayCopy;
for ($x=0; $x <= $#ParsedIPLogArray; $x++) {
$hash{$ParsedIPLogArray[$x]}++; # Increment IP occurance counter
if ($hash{$ParsedIPLogArray[$x]} > 1) {
# Current no. of elements in the array and subtract
# the original total no.
$elementNumber = $x + ($#IPLogArrayCopy-$totalIPLogElements);
splice (@IPLogArrayCopy, $elementNumber, 1);
}
}
I think the big problem here is that the variable names are wrong.
$totalIPLogElements *is not* the total number of elements in
@IPLogArrayCopy. This could confuse someone who's watching that
value of the variable in the debugger. Is it off by one, or not?
To fix the variable names, you start by replacing
$totalIPLogElements=$#IPLogArrayCopy;
with
$origNumberOfElements = @IPLogArrayCopy;
and
$elementNumber = $x + ($#IPLogArrayCopy-$totalIPLogElements);
with
my $currentNumberOfElements = @IPLogArrayCopy
my $numElementsDeleted =
$origNumberOfElements - $currentNumberOfElements;
$currentElementIndex = $x - $numElementsDeleted;
(Note that the original subtraction was in the wrong order, so the
result was negative, and that accounts for the bizarre '$x + ...'
expression in the original code.)
After you do that, you can start to understand what the whole block is
doing, and replace the entire thing with:
my @unique_elements;
for (@parsedIPLogArray) {
push @unique_elements, $_ unless $seen{$_}++;
}
Seven lines become three.
>I'd like to know if there is anything wrong with usage of
>@array in scalar context instead of $#array.
Nothing I can think of.
>I tried to find mentioned discussion with google but I haven't found
>anything.
I think I'm going to add $#array to my 'Program Repair Shop and Red
Flags' class as a red flag: Whenever you see $#array, you should stop
and see whether you have an opportunity to write clearer code
involving @array instead.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Wed, 24 Oct 2001 19:21:00 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: lookingglass.pl
Message-Id: <3bd7149b.bb8$65@news.op.net>
In article <slrn9t3pk0.2fg.tadmc@tadmc26.august.net>,
Tad McClellan <tadmc@augustmail.com> wrote:
>How is @array-1 "better" than $#array ?
I don't think it is. In some cases, $#array really is the best
choice:
for ($i = $#array; $i>=0; $i--) {
...
}
or
for $i (reverse (0 .. $#array)) {
...
}
But in my experience, you don't have the choice between $#array and
@array-1 very often. It's much more common to have a choice between
@array and $#array+1. Programmers who use only $#array tend to have
more inappropriate code than programmers who use only @array.
Here are some recent examples:
----------------------------------------------------------------
Subject: Re: random link from web page
Message-Id: <3B8A467C.859400B1@si.urv.es>
my @links = sort keys %seen;
my $random_link = int(rand($#links + 1));
----------------------------------------------------------------
Subject: inline average
Message-Id: <9hm1cs$2h15$1@news.aros.net>
my $total = 0;
foreach $color (@spectrum) {
$total += $values{$color};
}
$total = $total / ($#spectrum + 1);
return $total;
----------------------------------------------------------------
Subject: PERL And ASP
Message-Id: <F2093saXz5jy8SpzzzU0001405f@hotmail.com>
sub letters {
local ($i) = @_;
local ($div) = int(($i) / ($#letter+1));
if($div!=0) { return &letters($div-1).$letter[$i % ($#letter+1)] }
else { return $letter[$i % ($#letter+1)] }
}
----------------------------------------------------------------
In contrast, here are some uses of @array-1:
----------------------------------------------------------------
Subject: sorting
Message-Id: M3AFF948F.C69037C9@postoffice.pacbell.net>
sub StandDeviation
{
...
return sqrt($deviations/(@all-1));
}
That suspicious-looking '@all-1' is exactly correct here; the standard
deviation formula says to use one less than the number of elements.
----------------------------------------------------------------
Subject: Is an array of hashes the best way to do this?
Message-Id: <MPG.1500735286cb6f2b98968b@news.mtcibs.com>
my @cartitems = readcart($cartid);
for (0..(@cartitems-1)) {
if (exists $cartitems[$_]{'SKU'}) {
if ($cartitems[$_]{'SKU'} eq "some_product" &&
$cartitems[$_]{'QTY'} > 1) {
# Do something here
}
}
}
Here you can say that @cartitems-1 should have been $#cartitems. But
really, both are wrong; the whole thing should have been:
my @cartitems = readcart($cartid);
for (@cartitems) {
if (exists $_->{'SKU'}) {
if ($_->{'SKU'} eq "some_product" &&
$_->{'QTY'} < 1) {
# Do something here
}
}
}
I think this is typical. Most places where people use $#array, and
@array is *not* preferable, it turns out that $#array was unnecessary
also. Here's another example of the same sort of thing:
----------------------------------------------------------------
Subject: Re: Convert hex dump to binary
Message-Id: <3B9DC6B3.D710C97A@sxb.bsf.alcatel.fr>
while(<>) { # read from standard input
chomp;
my @words = split(/ +/);
$string .= $words[@words - 1];
}
Here it should have been not $words[$#words], but $words[-1].
----------------------------------------------------------------
Here, on the other hand, is a counterexample (from someone who should
have known better):
Subject: Re: non repeating random numbers
Message-Id: <8zneh8a3.fsf@pobox.com>
# create an array of indices into the list of questions
@q_index = (0 .. @questions-1);
# scramble it, using the method outlined in perlfaq4
fisher_yates_shuffle( \@q_index );
# then ask the questions in the shuffled order we just created
ask_question($questions[$_]) foreach @q_index;
@questions-1 should evidently have been $#questions.
----------------------------------------------------------------
Anyway, grepping over a couple of thousand articles, I found many more
cases of @array-1 being used appropriately than $#array+1. The best
replacement for $#array+1 was almost always @array (and the context
issue doesn't come up as often as you might think). But the best
replacement for @array-1 was not usually $#array but rather something
else entirely.
This isn't the measure one would use if one were going to study the
issue carefully, but it's interesting and suggestive.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Wed, 24 Oct 2001 22:03:18 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: lookingglass.pl
Message-Id: <9r77ap$d77$01$1@news.t-online.com>
Mark,
thanks a lot for finding the examples I couldn't supply.
However, it seems like your opinion is something like:
$#array better than @array-1
and
@array better than $#array+1
while @array-1 is clearer and usually better-used than $#array+1. I
wholeheartedly agree on this if I understood you correctly.
Steffen
--
$_=q;33352987319029872958319011313364356732192639127636833335345138283712
3712336415083973397340602842912;;s;\n;;;print"\n";$o=$_;push@o,substr($o,
$_*4,4)for(0..24);pop@o;for(@o){$i++;print' 'x(26-$i).(chr$_/29-$i)."\n"}
------------------------------
Date: Wed, 24 Oct 2001 15:28:40 -0400
From: "Patrick J. Larkin" <plarkin@beth.k12.pa.us>
Subject: Re: Plaintext to passwd file?
Message-Id: <B7FC8EA8.DF09%plarkin@beth.k12.pa.us>
in article 3bd6ffa8.9ba$3cf@news.op.net, Mark Jason Dominus at
mjd@plover.com wrote on 10/24/01 1:51 PM:
> In article <B7FC7523.D7E6%plarkin@beth.k12.pa.us>,
> Patrick J. Larkin <plarkin@beth.k12.pa.us> wrote:
>> I have a giant list of usernames and plain text passwords. I wrote a simple
>> script to make an htpasswd file out of them but I don't know how to encrypt
>> the passwords! I thought I could use the crypt() function but that asks for
>> a SALT?
>>
>> I thought I could do something simple like:
>>
>> $public_pw = crypt($password);
>>
>> Obviously, I need a SALT after $password. What should I put there?
>
> On systems that use a salt, it is usually a string of to characters
> chosen from the set ('A'..'Z', 'a'..'z', '0'..'9', '.', '/'). The
> particular salts don't matter, but you want to choose them so that
> every password has a different salt, if possible.
>
> Probably the simplest thing you can do that will work is:
>
> my $cur_salt_num = 0;
> sub next_salt {
> my @chars = ('A'..'Z', 'a'..'z', '0'..'9', '.', '/');
> my $salt = join '', @chars[$cur_salt_num / 64, $cur_salt_num % 64];
> ++$cur_salt_num;
> $cur_salt_num = 0 if $cur_salt_num == 4096;
> return $salt;
> }
>
> while (...) {
> my ($username, $password) = ...;
> my $crypted_password = crypt($password, next_salt());
> print "$username:$crypted_password\n";
> }
>
> This uses all the possible salts in order until each one has been
> used, and then starts over.
>
>> Sorry if this question is really lame.
>
> Not at all.
Thanks. I followed your example and all seemed to work well. I created the
htpasswd file but Apache won't authenticate anyone except the LAST user on
the list. Strange.
------------------------------
Date: Wed, 24 Oct 2001 15:59:58 -0400
From: "Patrick J. Larkin" <plarkin@beth.k12.pa.us>
Subject: Re: Plaintext to passwd file?
Message-Id: <B7FC95FD.E16A%plarkin@beth.k12.pa.us>
in article B7FC8EA8.DF09%plarkin@beth.k12.pa.us, Patrick J. Larkin at
plarkin@beth.k12.pa.us wrote on 10/24/01 3:28 PM:
> in article 3bd6ffa8.9ba$3cf@news.op.net, Mark Jason Dominus at
> mjd@plover.com wrote on 10/24/01 1:51 PM:
>
>> In article <B7FC7523.D7E6%plarkin@beth.k12.pa.us>,
>> Patrick J. Larkin <plarkin@beth.k12.pa.us> wrote:
>>> I have a giant list of usernames and plain text passwords. I wrote a simple
>>> script to make an htpasswd file out of them but I don't know how to encrypt
>>> the passwords! I thought I could use the crypt() function but that asks for
>>> a SALT?
>>>
>>> I thought I could do something simple like:
>>>
>>> $public_pw = crypt($password);
>>>
>>> Obviously, I need a SALT after $password. What should I put there?
>>
>> On systems that use a salt, it is usually a string of to characters
>> chosen from the set ('A'..'Z', 'a'..'z', '0'..'9', '.', '/'). The
>> particular salts don't matter, but you want to choose them so that
>> every password has a different salt, if possible.
>>
>> Probably the simplest thing you can do that will work is:
>>
>> my $cur_salt_num = 0;
>> sub next_salt {
>> my @chars = ('A'..'Z', 'a'..'z', '0'..'9', '.', '/');
>> my $salt = join '', @chars[$cur_salt_num / 64, $cur_salt_num % 64];
>> ++$cur_salt_num;
>> $cur_salt_num = 0 if $cur_salt_num == 4096;
>> return $salt;
>> }
>>
>> while (...) {
>> my ($username, $password) = ...;
>> my $crypted_password = crypt($password, next_salt());
>> print "$username:$crypted_password\n";
>> }
>>
>> This uses all the possible salts in order until each one has been
>> used, and then starts over.
>>
>>> Sorry if this question is really lame.
>>
>> Not at all.
>
> Thanks. I followed your example and all seemed to work well. I created the
> htpasswd file but Apache won't authenticate anyone except the LAST user on
> the list. Strange.
>
Nevermind. I think I was missing a chomp
------------------------------
Date: Wed, 24 Oct 2001 23:36:31 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Plaintext to passwd file?
Message-Id: <9r7c5n$jiv$05$1@news.t-online.com>
"Mark Jason Dominus" <mjd@plover.com> schrieb im Newsbeitrag
news:3bd6ffa8.9ba$3cf@news.op.net...
[snip]
| This uses all the possible salts in order until each one has been
| used, and then starts over.
I have been using a random salt in the past. (Usually only for few
passwords, but the general issue remains valid.) Can you tell me why a
predictable exhaustion of all possible salts is preferred over random
selection? I bet I just don't really understand the underlying concept and
will dig into the matter a little further anyway.
Steffen
--
$_=q;33352987319029872958319011313364356732192639127636833335345138283712
3712336415083973397340602842912;;s;\n;;;print"\n";$o=$_;push@o,substr($o,
$_*4,4)for(0..24);pop@o;for(@o){$i++;print' 'x(26-$i).(chr$_/29-$i)."\n"}
------------------------------
Date: Wed, 24 Oct 2001 21:52:46 +0100
From: "Scott Bell" <news@scottbell.org>
Subject: Telnet client in perl
Message-Id: <lPFB7.92106$sF.7517840@news2-win.server.ntlworld.com>
Does anyone know of a telnet client in perl, I'm not looking for a telnet.pm
module, an actual perl script.
Thanks.
--
Scott Bell
Email: scott@scottbell.org
The content of this message has been certified 100% correct.
------------------------------
Date: 24 Oct 2001 17:05:16 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Telnet client in perl
Message-Id: <m31yjs696b.fsf@mumonkan.sunstarsys.com>
"Scott Bell" <news@scottbell.org> writes:
> Does anyone know of a telnet client in perl, I'm not looking for a
> telnet.pm module, an actual perl script.
% perl -MCPAN -e "install Net::Telnet"
% perldoc Net::Telnet
--
Joe Schaefer "The man who doesn't read has no advantage over the man who
can't read."
--Mark Twain
------------------------------
Date: 24 Oct 2001 14:42:22 -0700
From: anand_ramamurthy@yahoo.com (Anand Ramamurthy)
Subject: Transfer to & from remote machine using telnet
Message-Id: <761041e6.0110241342.32afddac@posting.google.com>
I have need to tansfer file(s) to & froma remote machine using through telnet
(not ftp or any other means). Is this possible? If yes, is there an example
perl script for the same.
------------------------------
Date: Wed, 24 Oct 2001 18:02:58 -0400
From: "Mina Naguib" <spam@thecouch.homeip.net>
Subject: Re: Transfer to & from remote machine using telnet
Message-Id: <RTGB7.40672$p64.2568292@wagner.videotron.net>
"Anand Ramamurthy" <anand_ramamurthy@yahoo.com> wrote in message
news:761041e6.0110241342.32afddac@posting.google.com...
> I have need to tansfer file(s) to & froma remote machine using through
telnet
> (not ftp or any other means). Is this possible? If yes, is there an
example
> perl script for the same.
Telnet is not a file transfer protocol. The simple answer is no.
However, telnet is an established tcp/ip connection between two machines, so
theoretically with the right client pumping stuff out to STDOUT on the
telnet server, and the right client capturing that output as the telnet
client, and some exhausting error checking, you could get a carefully
constructed sender+receiver pair to transfer a file over telnet.
On the other hand, it might be easier to write your own protocol. You
haven't elaborated much on your weird limitation.
------------------------------
Date: Wed, 24 Oct 2001 19:32:53 BST
From: spam@freeuk.com (Stephen Patterson)
Subject: Re: What exactly will "make install" do for my module?
Message-Id: <slrn9te2ca.de.spam@localhost.localdomain>
On Wed, 24 Oct 2001 14:22:34 +0200, Edwin Günthner wrote:
> Hi there,
>
> I developped a new module that needs to run on a lot of OS/2
> machines. All those machines do not have make/gcc installed,
> [I need gcc to compile some xs stuff] so there is no way
> to tell my users:
>
> *get perl,
> *get my module,
> *do "perl Makefile.pl",
> *do "make install"
Doing 'perl Makefile.pl' and 'make' should build your module in a blib
directory in the current directory (unless you have a really custom
Makefile.PL). AFAIK, you can zip the blib directory and unzip its
contents onto a blib directory on another machine.
--
Stephen Patterson http://home.freeuk.net/s.patterson/
s.patterson@SPAM.freeuk.com (remove spam to reply)
ICBM address 54-22-0N 0-28-0W
------------------------------
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 2001
***************************************