[11350] in Perl-Users-Digest
Perl-Users Digest, Issue: 4950 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 20 14:07:21 1999
Date: Sat, 20 Feb 99 11:00:19 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 20 Feb 1999 Volume: 8 Number: 4950
Today's topics:
Anonymous surfing <botta@workmail.com>
Re: Apache for winblows95 <ozette@imaginative-creations.com>
Re: Are there any distance locators? <jdf@pobox.com>
Re: can I run perl on Win 98?????? <jonesy@rmi.nospam.net>
Re: can I run perl on Win 98?????? <ozette@imaginative-creations.com>
FAQ 8.45: How do I install a CPAN module? <perlfaq-suggestions@perl.com>
FAQ 8.46: What's the difference between require and use <perlfaq-suggestions@perl.com>
File Upload / Retaining File Name <mmelton@together.net>
Re: Handling files greater than 2.1 GB <jdf@pobox.com>
Re: LDAP programming in Perl? <ltl@rgsun43.viasystems.com>
Re: Newbie Q: a better sort? (Andrew M. Langmead)
Re: perl ldap problem HELP please <ltl@rgsun43.viasystems.com>
Re: Q on diff of array vs hash (Larry Rosler)
Re: Q on diff of array vs hash (Andre L.)
Re: Q on diff of array vs hash <jdf@pobox.com>
Re: Q on localtime <jdf@pobox.com>
untainting a list of variables (Alan Young)
Win32-Perl: How do I call other perl programs ? thst@my-dejanews.com
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 20 Feb 1999 19:04:50 +0200
From: Susan <botta@workmail.com>
Subject: Anonymous surfing
Message-Id: <36CEEB31.77CBE058@workmail.com>
Hi!
I'm willing to offer a free anonymous surfing service, but I can not
perl.
So could you please help me?
This code shows the code of a web-page:
#!/usr/local/bin/perl
use LWP::Simple;
$code=get $ARGV[0];
print "Content-type: text/html\n\n";
print $code;
Now I need your help:
1) The Content-type must depend on the type of the requested file.
2) All 'HREF' and 'SRC' parameters must be changed to:
http://my_cgi_url?[absolute URL]
3) All href mailto:
http://my_mailto_cgi?[somebody@somewhere.com]
4) <TITLE>...</TITLE> must be changed to:
<TITLE>Anonym:...</TITLE>
And somethin other you find out...
Thanks in advance :-)
- Susan -
------------------------------
Date: Sat, 20 Feb 1999 13:59:28 -0500
From: "Mr. Ozette Brown" <ozette@imaginative-creations.com>
Subject: Re: Apache for winblows95
Message-Id: <36CF0610.34E07C61@imaginative-creations.com>
Hey,
You can also say: #!c:/perl/bin/perl.exe (that's forward slashes).
Thanks, it works for me.
O-
jeremygurney@hotmail.com wrote:
> In article <36ce1aea.23859977@news-s01.ny.us.ibm.net>,
> tryout666@geocities.com (tryout) wrote:
> > Hya ppl,
> >
> > I am trying to use Apache WebServer for Win95, but i dont manage to
> > run perl's progms from that.. i read the help and it says to run
> > suEXEC to run perl scripts.. i edited some lines from httpd.conf to
> > get sucess on that.. but i didnt.
> >
> > tks
> > tryout
> >
>
> Oddly enough I've just had the same problem.
>
> For me the solution was just making sure that I had the correct path for the
> #!c:\perl\bin\perl.exe
> line at the top of my perl code.
>
> Apache unlike Xitami seems to need it.
>
> Jeremy Gurney
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
Mr. Ozette J. Brown <President>
Imaginative Creations <webmaster@imaginative-creations.com>
A Website Development and Consulting Company.
http://www.imaginative-creations.com
------------------------------
Date: 20 Feb 1999 13:20:51 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Are there any distance locators?
Message-Id: <m3soc1kkcc.fsf@joshua.panix.com>
Jonathan Stowe <gellyfish@btinternet.com> writes:
> Or for those gadget freaks amongst us I have an ultrasonic measuring
> device in my toolbox
"Well, the wall is exactly 3.5523 meters from the cabinet, and the
baby looks perfectly healthy."
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 20 Feb 1999 16:59:36 GMT
From: Jonesy <jonesy@rmi.nospam.net>
Subject: Re: can I run perl on Win 98??????
Message-Id: <7amplo$7g4$1@news1.rmi.net>
t_alter@hotmail.com wrote:
: How? Plaese inform, time is running out.
Oh , I see. We have a mid-term assignment that's coming due.
Jonesy
------------------------------
Date: Sat, 20 Feb 1999 13:55:28 -0500
From: "Mr. Ozette Brown" <ozette@imaginative-creations.com>
Subject: Re: can I run perl on Win 98??????
Message-Id: <36CF0520.692F0BF6@imaginative-creations.com>
Tom,
I am currently running Win98 and Perl with no problems. Get Perl from
www.activestate.com.
Give it a shot.
Thanks,
Ozette
t_alter@hotmail.com wrote:
> Hi everybody;
> I am starting to learn perl. Can I do it with my Win98 PC?
> I have been informed that I will have to go for Either UNIX or WinNT for that.
>
> Please drop an email at t_alter@hotmail.com
>
> Thanks a million.
>
> Tom
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
Mr. Ozette J. Brown <President>
Imaginative Creations <webmaster@imaginative-creations.com>
A Website Development and Consulting Company.
http://www.imaginative-creations.com
------------------------------
Date: 20 Feb 1999 10:00:01 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 8.45: How do I install a CPAN module?
Message-Id: <36ceea11@csnews>
(This excerpt from perlfaq8 - System Interaction
($Revision: 1.36 $, $Date: 1999/01/08 05:36:34 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq8.html
if your negligent system adminstrator has been remiss in his duties.)
How do I install a CPAN module?
The easiest way is to have the CPAN module do it for you. This module
comes with perl version 5.004 and later. To manually install the CPAN
module, or any well-behaved CPAN module for that matter, follow these
steps:
1 Unpack the source into a temporary area.
2 perl Makefile.PL
3 make
4 make test
5 make install
If your version of perl is compiled without dynamic loading, then you
just need to replace step 3 (make) with make perl and you will get a new
perl binary with your extension linked in.
See the ExtUtils::MakeMaker manpage for more details on building
extensions. See also the next question.
--
"Lazy people never bother to actually read the manual. Instead they
(like kids) pick something with big, colorful buttons."
--Eugene Tyurin <gene@insti.physics.sunysb.edu>
------------------------------
Date: 20 Feb 1999 11:00:04 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 8.46: What's the difference between require and use?
Message-Id: <36cef824@csnews>
(This excerpt from perlfaq8 - System Interaction
($Revision: 1.36 $, $Date: 1999/01/08 05:36:34 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq8.html
if your negligent system adminstrator has been remiss in his duties.)
What's the difference between require and use?
Perl offers several different ways to include code from one file into
another. Here are the deltas between the various inclusion constructs:
1) do $file is like eval `cat $file`, except the former:
1.1: searches @INC and updates %INC.
1.2: bequeaths an *unrelated* lexical scope on the eval'ed code.
2) require $file is like do $file, except the former:
2.1: checks for redundant loading, skipping already loaded files.
2.2: raises an exception on failure to find, compile, or execute $file.
3) require Module is like require "Module.pm", except the former:
3.1: translates each "::" into your system's directory separator.
3.2: primes the parser to disambiguate class Module as an indirect object.
4) use Module is like require Module, except the former:
4.1: loads the module at compile time, not run-time.
4.2: imports symbols and semantics from that package to the current one.
In general, you usually want `use' and a proper Perl module.
--
"Don't wear rollerskates to a tug-of-war." --Larry Wall
------------------------------
Date: Sat, 20 Feb 1999 12:30:18 -0500
From: "Matt Melton" <mmelton@together.net>
Subject: File Upload / Retaining File Name
Message-Id: <36ceeedc.0@news.together.net>
Hello,
Using cgi-lib.pl and Steven Brenners fup.cgi, I am able to get the file to
upload via a web browser to the correct directory, but the script renames
the file. I would like to be able to keep the original file name, though I
don't know how to do this. From the cgi-lib homepage, it says:
Note: the files saved on disk have different names from those uploaded. This
is in order to avoid potential security holes. If you want to set the file
on disk to have the same name, you need to use the rename() function. The
original name (which is tainted) is stored in the %cfn variable.
I'd appreciate some help as to how to implement this,
Thank you,
Matt
matt@unicat.com
------------------------------
Date: 20 Feb 1999 12:53:46 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Amod Kale <amod.kale@vlsi.com>
Subject: Re: Handling files greater than 2.1 GB
Message-Id: <m3vhgxkllh.fsf@joshua.panix.com>
>>>>> "AK" == Amod Kale <amod.kale@vlsi.com> writes:
AK> Now my file size has grown to 2.2 GB and the perl script
AK> refuses to recognize it.
There is no inherent limitation in the size of a file that Perl will
manipulate. What do you mean by "refuses to recognize"? Can you give
us a brief code sample that clearly demonstrates this failure?
You're not trying to read the entire file into memory at once, are
you?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 20 Feb 1999 17:20:22 GMT
From: lt lindley <ltl@rgsun43.viasystems.com>
Subject: Re: LDAP programming in Perl?
Message-Id: <7amqsm$n9s$1@rguxd.viasystems.com>
dubing@lisco.com wrote:
:>Hi there,
:>I have the book "ldap programming directory-enabled...". But it is in C. I
:>am more comfortable with Perl. Does anybody know where I can find on-line
:>docs on LDAP programming in Perl?
:>Any hint would be greatly appreciated. Please email me at bing-du@tamu.edu as
:>well. Thanks.
There is some documentation with Net::LDAPapi, but it presumes that
you know about LDAP api. There are a few examples that helped me.
I don't pretend to know all of the ins and outs of LDAP. I just read
enough to make this thing work.
Here is a cgi-bin script to query and update a MS Exchange server
database. It is not rigorous. It doesn't do anything about
locking. It moves passwords around in the clear. It doesn't pretend
to handle all possible error conditions. It just works well enough
for our needs.
Note that the user and password have to match an account with
update authority on the Exchange server.
HTH.
PS
Sorry about the tab stops at 4 and line wraps.
====================================================================
#!/usr/lib/lprgs/perl -w
# Set your tabstops to 4 for to view this program. In vi, :set ts=4 sw=4
use Net::LDAPapi;
use CGI;
use strict;
my $exchange_host = 'your_server_name_here';
# This array needs to be kept in sync with the display_names hash assignment
# below
my @attrs_wanted = qw/
cn
uid
telephoneNumber
facsimileTelephoneNumber
pager
title
info
physicalDeliveryOfficeName
department
rfc822Mailbox
/;
my %display_names;
# Perl is so cool! Look at this assignment using a hash slice.
@display_names{@attrs_wanted} = (
'Address book name',
'Initials',
'Telephone Number',
'Fax Number',
'Pager',
'Title',
'Job Function',
'Location',
'Department',
'Internet Mail Address',
);
my ($bindname, $bindpass, $ld);
# This is boilerplate for web pages
my $q = new CGI;
# Since ldap core dumps occasionally when I don't do it correctly,
# may need to turn on autoflush for debugging
#$| = 1;
print $q->header;
print $q->start_html(-title => 'Exchange Server Update',
-author => 'your_email_address\@your_domain.com',
-base => 'true',
-BGCOLOR => '#ffffcc',
-TEXT => '#hhhhhh',
-VLINK => '#aa0000',
-LINK => '#0000ff',
);
print "<center><h1>Exchange Server Update</h1></center>\n";
#Look and see whether we've been given a search or update
unless (defined $q->param('searchstring') || defined $q->param('updateit')) {
# First time into this, so put out a query form
print_query_form($q);
print_footer($ld);
exit 0;
}
# If got here then it is either a query or an update.
# Will need this for both. It is a standard ldap thingie
$ld = new Net::LDAPapi(-host => $exchange_host, -port => 389);
if ($ld == -1) {
print "<b>ERROR: Connect to exchange server failed</b>\n";
print_footer($ld);
exit 0;
}
if (defined $q->param('updateit')) {
print "<center>Success/failure of last update. Chance to do another.</center><p>\n";
$bindname = $q->param('bindname');
$bindpass = $q->param('bindpass');
if ($bindname eq '' || $bindpass eq '') {
print "<b>ERROR: You must provide an authorized user id and password to do an update</b>\n";
print_footer($ld);
exit 0;
}
my $status = $ld->bind_s(-dn => "cn=$bindname",
-password => $bindpass,
-type => LDAP_AUTH_SIMPLE);
if ($status != LDAP_SUCCESS) {
my $errno = $ld->errno;
my $errstring = $ld->errstring;
print "<b>ERROR: bind_s failed with status: $status and errno: $errno and errstr: $errstring </b>\n";
#print "<p>bindname: $bindname bindpass: $bindpass\n";
print "<p>You probably entered a bad authorized user id or password\n";
print_footer($ld);
exit 0;
}
my %vals = ();
$vals{dn} = $q->param('dn');
# I need this one to do a new query and the update
# These are the values from the web form
foreach my $atr (@attrs_wanted) {
$vals{$atr} = $q->param($atr);
}
# First, get current values from ldap server, then see what changed
#
my $msgid = $ld->search_s('ou=your_location,o=your_company,c=US',
LDAP_SCOPE_SUBTREE,
"(cn=$vals{cn})",
\@attrs_wanted,
0);
if ($msgid < 0) {
my $errno = $ld->errno;
my $errstring = $ld->errstring;
print "<p><b>ERROR: search_s failed with status: $msgid and errno: $errno and errstr: $errstring </b>\n";
print_footer($ld);
exit 0;
}
my $recs_ref = $ld->get_all_entries;
unless (defined $recs_ref) {
print "<br><b>ERROR: Couldn't find the record again</b>\n";
print_footer($ld);
exit 0;
}
my ($dn, $attrs_ref) = each %$recs_ref; # only one of them
# I'm only going to pick off the first one that matches!!!
unless (defined $dn) {
print "<br><b>ERROR: Couldn't find the record again</b>\n";
print_footer($ld);
exit 0;
}
# ANd there should ONLY be 1! There can be only 1!
my %mod_hash = ();
print "<h3>Fields updated in last transaction:</h3>\n",
"<table border=4>\n",
"<tr><td><b>Field Name</b></td>\n",
"<td><b>New Value</b></td>\n",
"<td><b>Old Value</b></td></tr>\n";
foreach my $atr (@attrs_wanted) {
next if ($atr eq 'cn' || $atr eq 'dn' || ! defined $vals{$atr}
|| $vals{$atr} eq '');
# This doesn't address the case of multiple values. How to handle?
if ((! defined $attrs_ref->{$atr})
|| $vals{$atr} ne $attrs_ref->{$atr}[0]) {
if (defined $vals{$atr}) {
if (my $errstr = validate_exchange_field($atr, $vals{$atr})) {
print "<br><b>ERROR: $errstr </b>\n<br>\n";
print_footer($ld);
exit 0;
}
print "<tr><td>$atr</td><td>$vals{$atr}</td>\n";
}
print " <td>$attrs_ref->{$atr}[0]</td>\n"
if (defined $attrs_ref->{$atr}
&& defined $attrs_ref->{$atr}[0]);
print "</tr>\n";
$mod_hash{$atr} = "$vals{$atr}";
}
}
print "</table><br>End of fields to update<br>\n";
# How to find out if hash is empty? Use keys in scalar context
if (keys %mod_hash <= 0) {
print "Nothing to update.\n";
print_footer($ld);
exit 0;
}
# Some prints for debugging
#print "<br>Before modify_s<br>\n";
$status = $ld->modify_s("$dn", \%mod_hash);
#print "<br>After modify_s<br>\n";
if ($status != LDAP_SUCCESS) {
my $errno = $ld->errno;
my $errstring = $ld->errstring;
print "<b>ERROR: modify_s failed with status: $status and errno: $errno and errstr: $errstring </b>\n";
#print "<p>bindname:$bindname bindpass:$bindpass\n";
print_footer($ld);
exit 0;
}
print_query_form($q, $bindname, $bindpass);
print_footer($ld);
exit 0;
}
if (defined $q->param('searchstring')) {
my $searchstring = $q->param('searchstring');
$bindname = $q->param('bindname');
$bindpass = $q->param('bindpass');
$searchstring =~ s/^\s+//;
$searchstring =~ s/\s+$//;
if ($searchstring eq '') {
print "<b>Error: You must enter a name to search for.</b>\n";
print "<p>Press the back button and try again.\n";
print_footer($ld);
exit 0;
}
my $status = $ld->bind_s; # anonymous is ok for query
if ($status != LDAP_SUCCESS) {
my $errno = $ld->errno;
my $errstring = $ld->errstring;
print "<b>ERROR: bind_s failed with status: $status and errno: $errno and errstr: $errstring </b>\n";
print_footer($ld);
exit 0;
}
my $msgid = $ld->search_s('ou=your_location,o=your_company',
LDAP_SCOPE_SUBTREE,
"(cn=${searchstring}*)",
\@attrs_wanted,
0);
if ($msgid < 0) {
my $errno = $ld->errno;
my $errstring = $ld->errstring;
print "<p><b>ERROR: search_s failed with status: $msgid and errno: $errno and errstr: $errstring </b>\n";
print_footer($ld);
exit 0;
}
my $recs_ref = $ld->get_all_entries;
my ($dn, $attrs_ref) = each %$recs_ref; # only one of them
print $q->start_form;
print "<table border=4>\n";
print "<tr><td>Distinguished Name</td><td>",
$q->textfield( -name => 'dn',
-value => $dn,
-size => 50,
-maxlength => 50,
),
"</td></tr>\n";
foreach my $atr (@attrs_wanted) {
if (exists $attrs_ref->{$atr}) {
foreach my $val (@{ $attrs_ref->{$atr} }) {
print "<tr><td>$display_names{$atr} </td><td>",
$q->textfield(-name => $atr,
-value => $val,
-size => 40,
-maxlength => 40,
),
"</td></tr>\n";
}
} else {
print "<tr><td>$display_names{$atr}</td><td>",
$q->textfield(-name => $atr,
-size => 40,
-maxlength => 40,
),
"</td></tr>\n";
}
}
print "</table>\n<br>\nAuthorized User: ",
$q->textfield( -name => 'bindname',
-value => $bindname,
-size => 20,
-maxlength => 20,
),
"\nPassword: ",
$q->password_field( -name => 'bindpass',
-value => $bindpass,
-size => 20,
-maxlength => 20,
),
$q->submit('updateit', 'Update this entry');
print $q->endform, "\n";
print_footer($ld);
exit 0;
}
sub print_footer {
my $ldl = shift;
my $last_changed = localtime((stat($0))[9]); # Last changed time of
# this script file
print <<EO_footer;
<hr>
<font size=1>
<b>Author:</b> Your Name(<a
HREF=mailto:Your_email_handle\@your_domain>your_email_handle\@your_domain</A>)
<br>
<b>WebMaster:</b> <a href="mailto:webmaster\@your_domain">webmaster\@your_domain</a>
<br>
<b>Last Updated:</b> $last_changed
</font>
EO_footer
close(STDOUT);
$ldl->unbind if (defined $ldl && $ldl != -1);
}
sub print_query_form {
my ($q, $bindname, $bindpass) = @_;
# bindname and bindpass values may not be defined
print "<p>Enter enough of the last name to match the entry you want. If there is more than one person with the same last name, then you must enter a comma and a space after the last name and then enough of the first name to make it unique. Example: jones, john\n<hr>\n";
print $q->start_form,
$q->textfield( -name => 'searchstring',
-size => 20,
-maxlength => 20,
),
" ",
$q->submit('getit', 'Search for an Entry'),
"<br>\nAuthorized User: ",
$q->textfield( -name => 'bindname',
-value => $bindname,
-size => 20,
-maxlength => 20,
),
"\nPassword: ",
$q->password_field( -name => 'bindpass',
-value => $bindpass,
-size => 20,
-maxlength => 20,
),
"\n<br>\n",
$q->endform, "\n";
}
sub validate_exchange_field {
my ($key, $val) = @_;
if ($key eq 'telephoneNumber' || $key eq 'facsimileTelephoneNumber'
|| $key eq 'pager') {
# This regex is ugly, but works. Actually, I don't like
# the next line at all.
return "$key field must be in format '1 (###) ###-####' where the '#' chars are digits. $val does not match." if ($val !~ /1 \(\d{3}\) \d{3}\-\d{4}/);
}
return undef;
}
================================================================
--
// Lee.Lindley | There was a time when I thought that "being right"
// @bigfoot.com | was everything. Then I realized that getting along
// | was more important. Still, being right is more fun!
// | And if I'm wrong, somebody will get some joy out of telling me!
------------------------------
Date: Sat, 20 Feb 1999 18:47:00 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Newbie Q: a better sort?
Message-Id: <F7GuuD.GrF@world.std.com>
"M. Morgan" <mmorgan@gladstone.uoregon.edu> writes:
>sort...
>alphabetically
>special characters and numbers first
>lower case first
>exclude the word "The" on sort but keep it for output
>any other parameters I haven't thought of for a dictionary word list
Create some sort of mapping between your input and your search
criteria. (For example a hash with the data element as they key and
the computed value as the (uhm) value.) Then in your search subroutine
retrieve the computed value and specify which is greater based on the
computed value.
#!/usr/bin/perl -w
use strict;
# set up our sorting order...
my @order = ( split(//,
'!"#$%&\'()*+,=./:;<=>?[\\]^_`{|}~'), # special characters
'0' .. '9', # then numbers
'a' .. 'z', # then lower case
'A' .. 'Z', # then upper case
' ', # finally spaces
);
# create a mapping between the standard character set encoding
# and our special sorting encoding.
my %map;
my $comparison_value = 0;
for my $letter ( @order ) {
my $packed_comparison_value = pack 'C', $comparison_value++;
$map{$letter} = $packed_comparison_value;
}
# read each word, remove extraneous symbols, and then convert
# from the standard encoding to our encoding.
my (%compare,@words);
while(<DATA>) {
chomp;
my $remove_ignored;
($remove_ignored = $_) =~ s/\bthe\b//gi; # ignore "the"
$remove_ignored =~ s/\s+/ /g; # treat multiple spaces as one
$remove_ignored =~ s/^\s+//g; # ignore leading spaces
$remove_ignored =~ s/\s+$//g; # ignore trailing spaces
$compare{$_} = join '', map { $map{$_} } split //, $remove_ignored;
push @words, $_;
}
# now sort the words based on our special encoding.
for my $word( sort { $compare{$a} cmp $compare{$b} } @words ) {
print "$word\n";
}
__END__
Andrew Langmead
andrew langmead
the shebang line
the #!/usr/bin/perl line
--
Andrew Langmead
------------------------------
Date: 20 Feb 1999 16:45:11 GMT
From: lt lindley <ltl@rgsun43.viasystems.com>
Subject: Re: perl ldap problem HELP please
Message-Id: <7amoqn$mjj$1@rguxd.viasystems.com>
shaven.monkey <shaven.monkey@throw.me.the.banana.first> wrote:
:>Can anybody see what's wrong with this piece of code?
:>I get the error message "bind error Invalid syntax" and can't figure out
:>why.
:>If an existing user already has an attribute rfc822Mailbox I can modify
:>the value,
:>but I can't add the attribute to a user.
[ code snipped ]
I don't know about the error message. And I have only read enough
LDAP to do whatever I was trying to do at the time.
Are you sure that the user does not already have an attribute
rfc822Mailbox that happens to be Null? Try using "modify_s"
instead of add.
--
// Lee.Lindley | There was a time when I thought that "being right"
// @bigfoot.com | was everything. Then I realized that getting along
// | was more important. Still, being right is more fun!
// | And if I'm wrong, somebody will get some joy out of telling me!
------------------------------
Date: Sat, 20 Feb 1999 09:35:37 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Q on diff of array vs hash
Message-Id: <MPG.1138924118088323989a65@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <36cedafc@news1.us.ibm.net> on Sat, 20 Feb 1999 09:55:29 -
0600, tavi367@ibm.net <tavi367@ibm.net> says...
> I have two methods to do the same thing... (listed at end of note)
>
> Can some one please tell me the pros and cons of each, and which would you
> use and why?
>
> I created the first, another guru suggested the second, and I am trying to
> understand the real difference.
>
> And I am really not asking what the fundamentals of what an array is and
> what a hash is, I know that. I looking to know why one is better then the
> other in this instance.
#!/usr/local/bin/perl -w
use Benchmark;
sub hash0
{
my %shortMonthName = ( 0 => Jan,
1 => Feb,
2 => Mar,
3 => Apr,
4 => May,
5 => Jun,
6 => Jul,
7 => Aug,
8 => Sep,
9 => Oct,
10 => Nov,
11 => Dec
);
$shortMonthName{$_[0] + 0}
}
my %shortMonthName = ( 0 => Jan,
1 => Feb,
2 => Mar,
3 => Apr,
4 => May,
5 => Jun,
6 => Jul,
7 => Aug,
8 => Sep,
9 => Oct,
10 => Nov,
11 => Dec
);
sub hash1 { $shortMonthName{$_[0] + 0} }
sub array0
{
my @shortMonthName = qw( Jan Feb Mar Apr May Jun
Jul Aug Sep Oct Nov Dec );
$shortMonthName[$_[0]]
}
my @shortMonthName = qw( Jan Feb Mar Apr May Jun
Jul Aug Sep Oct Nov Dec );
sub array1 { $shortMonthName[$_[0]] }
sub subst0 { substr 'JanFebMarAprMayJunJulAugSepOctNovDec',
3 * $_[0], 3 }
my $shortMonthName = 'JanFebMarAprMayJunJulAugSepOctNovDec';
sub subst1 { substr $shortMonthName, 3 * $_[0], 3 }
timethese(1 << (shift || 0), {
Array0 => sub { array0(6) },
Array1 => sub { array1(6) },
Hash0 => sub { hash0 (6) },
Hash1 => sub { hash1 (6) },
Subst0 => sub { subst0(6) },
Subst1 => sub { subst1(6) },
}});
__END__
Benchmark: timing 65536 iterations of Array0, Array1, Hash0, Hash1,
Subst0, Subst1...
Array0: 10 wallclock secs ( 9.61 usr + 0.00 sys = 9.61 CPU)
Array1: 1 wallclock secs ( 0.71 usr + 0.00 sys = 0.71 CPU)
Hash0: 18 wallclock secs (17.80 usr + 0.00 sys = 17.80 CPU)
Hash1: 5 wallclock secs ( 3.96 usr + 0.00 sys = 3.96 CPU)
Subst0: 1 wallclock secs ( 0.94 usr + 0.00 sys = 0.94 CPU)
Subst1: 2 wallclock secs ( 0.93 usr + 0.00 sys = 0.93 CPU)
These numbers speak for themselves. There is one more fundamental
difference worth noting:
The index into an array is an integer. A string argument such as '06'
is automatically converted to the number 6 during the indexing process.
The index into a hash is a string. A string argument such as '06' would
not find the value 'Jul' in the hash. That is why I added 0 to the
argument. A string argument '06' is converted to the number 6 by the
addition and then converted to the string '6' during the indexing
process.
In words of one sentence, table lookup via small non-negative integers
is naturally done best with an array; other table lookups are naturally
done best with a hash; substringing is cute, but slower than array
lookup (if the array is pre-initialized).
Signed, 'another guru'. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 Feb 1999 12:56:14 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Q on diff of array vs hash
Message-Id: <alecler-2002991256140001@dialup-543.hip.cam.org>
In article <36cedafc@news1.us.ibm.net>, <tavi367@ibm.net> wrote:
> I have two methods to do the same thing... (listed at end of note)
>
> Can some one please tell me the pros and cons of each, and which would you
> use and why?
If "Jan" is stored at position 0 in a list, and "Feb" is at position 1,
etc., you don't really need to explicitely associate those numbers with
the values in a hash. Using the month number to index a list of month
names is the practical thing to do.
I personally like:
sub getShortMonth {
(qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/)[shift];
}
Andre
------------------------------
Date: 20 Feb 1999 13:24:51 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: <tavi367@ibm.net>
Subject: Re: Q on diff of array vs hash
Message-Id: <m3pv75kk5o.fsf@joshua.panix.com>
<tavi367@ibm.net> writes:
> Can some one please tell me the pros and cons of each, and which
> would you use and why?
When you can use a non-sparse range of integers as keys, then an array
is a natural data structure. This is for reasons of aesthetics *and*
efficiency, since a hash access requires that the key be manipulated
in a hashing function (hence the name).
In either case, you'd want to declare the tables outside of the
functions, since they're static.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 20 Feb 1999 13:46:18 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: <tavi367@ibm.net>
Subject: Re: Q on localtime
Message-Id: <m3n228lxqd.fsf@joshua.panix.com>
<tavi367@ibm.net> writes:
> my ($sec, $min, $hour, $day, $mon, $year) = localtime;
Some might opt to only create those variables that will actually be
used.
my ($day, $month, $year) = (localtime)[3..5];
> sprintf '%.2d/%.2d/%d', $mon + 1, $day, $year + 1900
Again, just my opinion, but I think that '0' is clearer than '.' in
asking for a zero-padded integer.
"%02d"
> If I place it in an external
> require "dateTime.pl";
> I get...
> Use of uninitialized value at C:\Perl\5.005\lib/dateTime.pl line 210.
I can't reproduce this problem.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Sat, 20 Feb 1999 17:03:48 GMT
From: alany@2021.com (Alan Young)
Subject: untainting a list of variables
Message-Id: <36ceea06.65300449@news.supernews.com>
I have a question about untainting a list of variables:
I want to untaint a list of variables that I may be changing, adding
to or deleting from. Instead of doing
var1 =~ expr;
var1 = $1;
var2 =~ expr;
var2 = $1;
... etc.
for each variable, I tried to do the following:
for $throwaway (qw(LogFile Errorfile DebugFile)) {
$$throwaway =~ /([\w\d\.\/]+)/;
$$throwaway = $1;
}
If LogFile & co. are not declared with a my() structure this works
fine, but if they are declared with a my() structure I get
uninitialized variable errors. I realize I can undef the variables,
but I'm trying to cut down on later maintenance if at all possible.
This is my test program:
#!/u/alany/bin/perl
-------
my ( $test1, $test2, $test3 );
$test1 = "Hello ";
$test2 = "there!";
$test3 = "world!";
for $var (qw(test1 test2 test3)) {
print "tainted: $var is $$var\n";
$$var =~ /([\w\d\.\/]+)/;
$$var = $1;
print "untainted: $var is $$var\n";
}
$test1 = "";
$test2 = "";
$test3 = "";
-------
I get this output:
tainted: test1 is
untainted: test1 is
tainted: test2 is
untainted: test2 is
tainted: test3 is
untainted: test3 is
If I comment out the my() structure I get the following:
tainted: test1 is Hello
untainted: test1 is Hello
tainted: test2 is there!
untainted: test2 is there
tainted: test3 is world!
untainted: test3 is world
Can anyone tell me why? Thanks for your time and consideration.
I have 5.004_76 for PA-RISC1.1 on HPUX 10.20
--
Alan Young Technical Support
http://members.xoom.com/AlanYoung 2021.Interactive, LLC
If your happy and you know it, clunk your chains! http://www.2021.com
967 Ignorance can be cured -- but stupid is forever.
------------------------------
Date: Sat, 20 Feb 1999 18:37:49 GMT
From: thst@my-dejanews.com
Subject: Win32-Perl: How do I call other perl programs ?
Message-Id: <7amvdt$6np$1@nnrp1.dejanews.com>
If I want to call other perl programs (not subroutines) from within a perl
program: How do I do that ? The following doesn't work:
`/usr/www/user12/cgi-bin/someprog.pl param1`;
or
/usr/www/user12/cgi-bin/someprog.pl param1;
Bye
Thomas
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 4950
**************************************