[24965] in Perl-Users-Digest
Perl-Users Digest, Issue: 7215 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 6 14:07:10 2004
Date: Wed, 6 Oct 2004 11:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 6 Oct 2004 Volume: 10 Number: 7215
Today's topics:
Re: @INC [way off topic now] <mritty@gmail.com>
Re: @INC [way off topic now] <ftoewe@austin.rr.com>
Re: @INC [way off topic now] <emschwar@pobox.com>
@INC (Michael)
Re: @INC <1usa@llenroc.ude.invalid>
Re: @INC <mritty@gmail.com>
Re: @INC <tadmc@augustmail.com>
Re: @INC <1usa@llenroc.ude.invalid>
Re: @INC <mritty@gmail.com>
Re: @INC <ron.parker@povray.org>
Re: Can perl SHA1 module be applied to files? (Lee Hibberd)
Re: Error.pm and DBI.pm problem (Horst Walter)
Re: How do I merge two arrays or two strings? <tadmc@augustmail.com>
How to prevent the removal of \ from pairs of \\? (Bad Ynfo)
Re: How to prevent the removal of \ from pairs of \\? <noreply@gunnar.cc>
Re: How to prevent the removal of \ from pairs of \\? <mritty@gmail.com>
Re: How to prevent the removal of \ from pairs of \\? <uri@stemsystems.com>
Re: How to prevent the removal of \ from pairs of \\? <eam@7ka.mipt.ru>
Re: How to prevent the removal of \ from pairs of \\? <uri@stemsystems.com>
Re: How to prevent the removal of \ from pairs of \\? <tadmc@augustmail.com>
Re: initialize a list <nobull@mail.com>
Re: Is PHP still slower than Perl? <kevin@pricetrak.com>
Re: Is PHP still slower than Perl? <berislav.lopac@dimedia.hr>
Re: map function problem <nobull@mail.com>
perl net::ldap problem using variable eg attr => [ $v1 <tripal@arcor.de>
Re: perl net::ldap problem using variable eg attr => [ <mritty@gmail.com>
Re: perl net::ldap problem using variable eg attr => [ <richard@zync.co.uk>
Re: perl net::ldap problem using variable eg attr => [ <kkeller-usenet@wombat.san-francisco.ca.us>
Re: Regular Expression help please <tadmc@augustmail.com>
Re: Regular Expression help please <sbryce@scottbryce.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 06 Oct 2004 17:02:43 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: @INC [way off topic now]
Message-Id: <TyV8d.1765$Ua.1304@trndny04>
"Ron Parker" <ron.parker@povray.org> wrote
> On Wed, 06 Oct 2004 15:48:46 GMT, Paul Lalli wrote:
> >> > "Michael" <araxnid@hotmail.com> wrote i
> >>
> >> >> 10x
> > I have the nasty feeling it's supposed to be "thanks". Though how
and
> > when "ten" came to be pronounced the same as [THANE], I have no
idea.
>
> Perhaps it's a bastardization of TNX, which seems to be SMS-speak (and
> before that, ham radio shorthand) for "thanks."
Isn't ham radio an auditory medium? How would one audibly convey "TNX"
in such a manner as to be a shortcut for a one-syllable word?
Paul Lalli
------------------------------
Date: Wed, 06 Oct 2004 17:15:30 GMT
From: "Fred Toewe" <ftoewe@austin.rr.com>
Subject: Re: @INC [way off topic now]
Message-Id: <SKV8d.112$iC4.48@fe2.texas.rr.com>
"Paul Lalli" <mritty@gmail.com> wrote in message
news:TyV8d.1765$Ua.1304@trndny04...
> "Ron Parker" <ron.parker@povray.org> wrote
> > On Wed, 06 Oct 2004 15:48:46 GMT, Paul Lalli wrote:
> > >> > "Michael" <araxnid@hotmail.com> wrote i
> > >>
> > >> >> 10x
> > > I have the nasty feeling it's supposed to be "thanks". Though how
> and
> > > when "ten" came to be pronounced the same as [THANE], I have no
> idea.
> >
> > Perhaps it's a bastardization of TNX, which seems to be SMS-speak (and
> > before that, ham radio shorthand) for "thanks."
>
> Isn't ham radio an auditory medium? How would one audibly convey "TNX"
> in such a manner as to be a shortcut for a one-syllable word?
>
> Paul Lalli
>
>
Not initially. Remember the Morse Code? Initially, all Ham radio licenses
required some degree of proficiency in its use. Now you could say that was
auditory, but that's stretching it a bit.
Fred
------------------------------
Date: Wed, 06 Oct 2004 11:38:55 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: @INC [way off topic now]
Message-Id: <etopt3v21cg.fsf@wilson.emschwar>
"Paul Lalli" <mritty@gmail.com> writes:
> Isn't ham radio an auditory medium? How would one audibly convey "TNX"
> in such a manner as to be a shortcut for a one-syllable word?
Back in the bad old days before no-code licenses, people actually had
to learn Morse Code, and were only allowed to communicate using it
after receiving their initial license.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: 6 Oct 2004 06:51:55 -0700
From: araxnid@hotmail.com (Michael)
Subject: @INC
Message-Id: <b22ecb38.0410060551.6d54ff90@posting.google.com>
Hi!
How can I add path to @INC value from console?
Where is stores the values?
10x
------------------------------
Date: 6 Oct 2004 14:03:16 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: @INC
Message-Id: <Xns957A6647EFD12asu1cornelledu@132.236.56.8>
araxnid@hotmail.com (Michael) wrote in news:b22ecb38.0410060551.6d54ff90
@posting.google.com:
> Hi!
> How can I add path to @INC value from console?
> Where is stores the values?
See the ENVIRONMENT section in perldoc perlrun. Also, read perldoc -q lib.
Sinan.
------------------------------
Date: Wed, 06 Oct 2004 14:09:14 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: @INC
Message-Id: <e0T8d.1718$Ua.1264@trndny04>
"Michael" <araxnid@hotmail.com> wrote in message
news:b22ecb38.0410060551.6d54ff90@posting.google.com...
> Hi!
> How can I add path to @INC value from console?
From the 'console':
perldoc perlrun
(search for @INC)
From within a perl script:
perldoc lib
> Where is stores the values?
In the site-wide configuration of Perl. Unless you have a very good
reason, you don't want to mess with it. I could be wrong in this, but
I'm pretty sure editing the global @INC will involve re-building or
re-installing perl with the correct configuration options.
> 10x
ten times what?
Paul Lalli
------------------------------
Date: Wed, 6 Oct 2004 10:38:04 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: @INC
Message-Id: <slrncm84as.79m.tadmc@magna.augustmail.com>
Paul Lalli <mritty@gmail.com> wrote:
> "Michael" <araxnid@hotmail.com> wrote in message
> news:b22ecb38.0410060551.6d54ff90@posting.google.com...
>> 10x
>
> ten times what?
I was wondering that too.
Maybe it was a typo and was supposed to be "10q" instead?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Oct 2004 15:45:52 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: @INC
Message-Id: <Xns957A77AD08DA0asu1cornelledu@132.236.56.8>
Tad McClellan <tadmc@augustmail.com> wrote in
news:slrncm84as.79m.tadmc@magna.augustmail.com:
> Paul Lalli <mritty@gmail.com> wrote:
>> "Michael" <araxnid@hotmail.com> wrote in message
>> news:b22ecb38.0410060551.6d54ff90@posting.google.com...
>>> 10x
>> ten times what?
> Maybe it was a typo and was supposed to be "10q" instead?
Naaah, he real bad, he ten times bad :)
Sinan.
------------------------------
Date: Wed, 06 Oct 2004 15:48:46 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: @INC
Message-Id: <ytU8d.1365$4b.405@trndny09>
"Tad McClellan" <tadmc@augustmail.com> wrote
> Paul Lalli <mritty@gmail.com> wrote:
> > "Michael" <araxnid@hotmail.com> wrote i
>
> >> 10x
> > ten times what?
> I was wondering that too.
>
> Maybe it was a typo and was supposed to be "10q" instead?
I have the nasty feeling it's supposed to be "thanks". Though how and
when "ten" came to be pronounced the same as [THANE], I have no idea.
Paul Lalli
------------------------------
Date: Wed, 6 Oct 2004 11:02:25 -0500
From: Ron Parker <ron.parker@povray.org>
Subject: Re: @INC
Message-Id: <slrncm85oh.gsh.ron.parker@mail.parkrrrr.com>
On Wed, 06 Oct 2004 15:48:46 GMT, Paul Lalli wrote:
> "Tad McClellan" <tadmc@augustmail.com> wrote
>> Paul Lalli <mritty@gmail.com> wrote:
>> > "Michael" <araxnid@hotmail.com> wrote i
>>
>> >> 10x
>> > ten times what?
>> I was wondering that too.
>>
>> Maybe it was a typo and was supposed to be "10q" instead?
>
> I have the nasty feeling it's supposed to be "thanks". Though how and
> when "ten" came to be pronounced the same as [THANE], I have no idea.
Perhaps it's a bastardization of TNX, which seems to be SMS-speak (and
before that, ham radio shorthand) for "thanks."
--
#local R=<7084844682857967,0787982,826975826580>;#macro L(P)concat(#while(P)chr(
mod(P,100)),#local P=P/100;#end"")#end background{rgb 1}text{ttf L(R.x)L(R.y)0,0
translate<-.8,0,-1>}text{ttf L(R.x)L(R.z)0,0translate<-1.6,-.75,-1>}sphere{z/9e3
4/26/2001finish{reflection 1}}//ron.parker@povray.org My opinions, nobody else's
------------------------------
Date: 6 Oct 2004 07:59:53 -0700
From: l.hibberd@nls.uk (Lee Hibberd)
Subject: Re: Can perl SHA1 module be applied to files?
Message-Id: <cd2f693b.0410060659.1d17c1a8@posting.google.com>
Thanks for your reply Keith. I am now seeing the same value generated
for three different .jpg files I am working with so I guess something
is still wrong with my code. Could you give me a final nudge in the
right direction? Here's the modified code:
#!/usr/local/bin/perl
use Digest::SHA1;
my $datafile = "c:\testerforanette.jpg";
my $file_is_binary = ! -T $datafile;
open ((MYNEWFILE, $datafile) || die ("Can't find file"));
if ($file_is_binary) {
binmode(MYNEWFILE);
print Digest::SHA1->new->addfile(*MYNEWFILE)->hexdigest, "\n";
close (MYNEWFILE);
}
I've noticed if I replace addfile(*MYNEWFILE) with addfile(MYNEWFILE).
I also get the same result. Thanks - Lee
ko <kuujinbo@hotmail.com> wrote in message news:<2sf10rF1j4bslU1@uni-berlin.de>...
> Lee Hibberd wrote:
> > Hello all
> >
> > I have used sha1_file in php and want to know if there is an
> > equivalent in perl. i.e. I want to produce a sha1 value based on the
> > composition of the file and not the filename. I have used the perl
> > sha1 digest, but I'm unsure if this is working correctly. One reason
> > for my uncertainty is that the sha1 values produced by php sha1_file
> > differ. The second reason is I guess I would need to feed the
> > bit-stream through the sha1 in perl as if it were a line of text, and
> > I'm not sure that my code does that:
> >
> > my $fn="$file";
> > my $fh = new IO::File;
> > $fh->open($fn) or @row = $dbh->do( "
> > UPDATE All_Locations SET SHA1Date = Date(),SHA1Time =
> > Time(),ErrorCode=\'NoFile\' WHERE FileID=$row[0]
> > " );
> > $digest = new Digest::SHA1;
> > $digest->addfile($fh);
> > $fh->close;
> > $sha1var = $digest->hexdigest;
> > print $file.": ".$sha1var."\n";
> >
> > Any help would be greatly appreciated.
> >
> > Lee Hibberd
> > National Library of Scotland
>
> The documentation for addfile() states that the filehandle should be in
> binmode:
>
> use Digest::SHA1;
>
> open my $fh, shift or die $!;
> binmode($fh);
>
> print Digest::SHA1->new->addfile($fh)->hexdigest, "\n";
> close $fh;
>
> Digest::MD5 has an interface similar to Digest::SHA1 and example code
> you might want to look at.
>
> HTH - keith
------------------------------
Date: 6 Oct 2004 08:15:31 -0700
From: unkwb@web.de (Horst Walter)
Subject: Re: Error.pm and DBI.pm problem
Message-Id: <53867fbe.0410060715.7948a734@posting.google.com>
Yes, this is what I have guessed. But I tried many things and was not
able to do it.
I used
use Error qw(:try);
as in all the examples for error.pm. I have tried several tings as
use Error qw(:try with);
but none of them worked.
It would be great if somebody had an example on this.
Cheers
HW
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<ck0j7f$8bg$1@mamenchi.zrz.TU-Berlin.DE>...
> Horst Walter <unkwb@web.de> wrote in comp.lang.perl.misc:
> > As a newbie to Perl I run into the following problem. With this I get
> > the following problem with the code below:
> >
> > Can't call method "with" without a package or object reference at
> > autodb.pm line 163
>
> [...]
>
> Your code (still quoted below) is incomplete. It looks like you didn't
> import the with() function.
>
> Anno
>
> >
> > try {
> > my ($dbh) = @_;
> > unless ($dbh->disconnect) {
> > die("autodb::oracleLogoff $DBI::errstr");
> > };
> > }
> > catch Error with {
> > my $err = shift;
> > print "autodb::oracleLogoff(..) $err";
> > };
------------------------------
Date: Wed, 6 Oct 2004 07:48:33 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How do I merge two arrays or two strings?
Message-Id: <slrncm7qd1.66i.tadmc@magna.augustmail.com>
nntp <nntp@rogers.com> wrote:
>> nntp <nntp@rogers.com> wrote:
>> > I want to merge the two like you shuffle two decks of cards.
>> while ( @n + @m ) {
>> foreach my $i ( 1 .. int(1 + rand 3)) {
>> push @shuffled, shift @n if @n;
>> }
> could you tell me why 1 is always the start in @shuffled, which means,
Because my code always shifts from @n first (above) and from @m second (below).
You couldn't see that for yourself?
Are you a Programmer?
> it is
> not random.
Yes, I did not write your program for you, I illustrated some techniques
that you could employ to write your program. So go write it, inserting
more randomness whereever appropriate.
Just add a rand() call to determine which order to examine the arrays in.
What's the problem?
> also, could you explain what ( 1 .. int(1 + rand 3)) does?
Yes I could, but I don't want to until you've shown that you've
done your best to understand it on your own first.
Have you read the documentation for int() and rand()?
Was some part of that unclear to you?
Did you write a little test program with that code and see
what kind of numbers it gets you?
> you call $i which
> does not exist.
$i is a variable, you don't "call" variables, you call subroutines,
but $i is not a subroutine, so I dunno what you are talking about here...
> you tried to pick zero or one,
No I didn't.
> but why rand 3?,
Each part of the "fan" will be 1-3 cards from one of the arrays.
You will probably want to add some randomness in determining the
fan size too.
> will I get 1+3=4?
If you add 1 and 3 you will get 4, yes.
If you want to know what numbers my code generates, write a little
test program with my code in it, and see what numbers in generates.
Did it generate any "4"s?
>> foreach my $i ( 1 .. int(1 + rand 3)) {
>> push @shuffled, shift @m if @m;
>> }
>> }
> it gave me errors;
Then fix the error!
> Global symbol "@bp" requires explicit package name at testmerge.pl line 23.
perldoc strict
perldoc -f my
and look up the description for that message in
perldoc perldiag
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Oct 2004 06:53:26 -0700
From: badynfo@yahoo.fr (Bad Ynfo)
Subject: How to prevent the removal of \ from pairs of \\?
Message-Id: <d76524b7.0410060553.565691c1@posting.google.com>
Hi,
In perlop, it reads:
'', q//
The only interpolation is removal of \ from pairs \\.
So how can I assign '\\foo\bar' to a scalar without having to say
'\\\\foo\bar'? Is it possible?
TIA
------------------------------
Date: Wed, 06 Oct 2004 16:41:14 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to prevent the removal of \ from pairs of \\?
Message-Id: <2siek6F1lntdgU1@uni-berlin.de>
Bad Ynfo wrote:
> In perlop, it reads:
>
> '', q//
> The only interpolation is removal of \ from pairs \\.
>
> So how can I assign '\\foo\bar' to a scalar without having to say
> '\\\\foo\bar'? Is it possible?
I don't know of any other way.
For the case you are dealing with paths on Windows, you'd better use
straight slashes in Perl code.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 06 Oct 2004 14:43:39 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: How to prevent the removal of \ from pairs of \\?
Message-Id: <vwT8d.695$tc.258@trndny02>
"Bad Ynfo" <badynfo@yahoo.fr> wrote in message
news:d76524b7.0410060553.565691c1@posting.google.com...
> Hi,
>
> In perlop, it reads:
>
> '', q//
> The only interpolation is removal of \ from pairs \\.
>
> So how can I assign '\\foo\bar' to a scalar without having to say
> '\\\\foo\bar'? Is it possible?
About the only way I can think of is to use a single-quoted heredoc:
$path =<<'PATH';
\\foo\bar
PATH
Note that I don't especially understand why this works. Why would
single-quoted heredocs not work the same as 'normal' single-quoted
strings?
Paul Lalli
------------------------------
Date: Wed, 06 Oct 2004 14:56:06 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How to prevent the removal of \ from pairs of \\?
Message-Id: <x7llej522z.fsf@mail.sysarch.com>
>>>>> "PL" == Paul Lalli <mritty@gmail.com> writes:
>> So how can I assign '\\foo\bar' to a scalar without having to say
>> '\\\\foo\bar'? Is it possible?
PL> About the only way I can think of is to use a single-quoted heredoc:
PL> $path =<<'PATH';
PL> \\foo\bar
PL> PATH
PL> Note that I don't especially understand why this works. Why would
PL> single-quoted heredocs not work the same as 'normal' single-quoted
PL> strings?
because in single quoted strings \ is needed to escape ' and \. in
single quoted heredocs there is no need to escape anything as perl just
scans for the closing token. in normal double quoted heredocs, perl has
to scan for \ escapes like \n and \t so it must handle \\ and it makes
that into just \.
not that i have ever needed to use \ as data (i choose / path based
systems :), this is a good trick to know.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 6 Oct 2004 18:25:23 +0300
From: "Eugene Mikheyev" <eam@7ka.mipt.ru>
Subject: Re: How to prevent the removal of \ from pairs of \\?
Message-Id: <ck12ju$1fu9$1@news.univ.kiev.ua>
> So how can I assign '\\foo\bar' to a scalar without having to say
> '\\\\foo\bar'? Is it possible?
my $re = '\\foo\bar';
and then in the regex, use \Q..\E, i.e. /\Q$re\E/
------------------------------
Date: Wed, 06 Oct 2004 15:32:15 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How to prevent the removal of \ from pairs of \\?
Message-Id: <x7y8ij3luc.fsf@mail.sysarch.com>
>>>>> "EM" == Eugene Mikheyev <eam@7ka.mipt.ru> writes:
>> So how can I assign '\\foo\bar' to a scalar without having to say
>> '\\\\foo\bar'? Is it possible?
EM> my $re = '\\foo\bar';
have you tried that out and printed it?
perl -le '$x = q{\\foo\bar} ; print $x'
\foo\bar
he wants 2 \'s at the beginning of the string, hence his 4 \'s.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 6 Oct 2004 10:35:21 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to prevent the removal of \ from pairs of \\?
Message-Id: <slrncm845p.79m.tadmc@magna.augustmail.com>
Bad Ynfo <badynfo@yahoo.fr> wrote:
> Hi,
>
> In perlop, it reads:
>
> '', q//
> The only interpolation is removal of \ from pairs \\.
>
> So how can I assign '\\foo\bar' to a scalar without having to say
> '\\\\foo\bar'?
Why do you think you want to assign '\\foo\bar' to a scalar without
having to say '\\\\foo\bar'?
That is NOT a rhetorical question. This sounds like an XY Problem to me,
we could give a much better answer if we knew what the "Y" was...
What is it that you are ultimately trying to accomplish?
If those data are paths, then did you know that '//foo/bar' will
work in most cases?
How are you using these strings?
If you can switch to sensible slashes, your whole problem goes away
(which is what makes those silly slashes silly).
> Is it possible?
Sure, but the cure is MUCH worse than the disease.
What is your objection to backslashing backslashes in literal strings?
Here are some examples:
$_ = chr(92) . chr(92) . 'foo' . chr(92) . 'bar'; # works for ASCII
$_ = "@{[chr(92)]}@{[chr(92)]}foo@{[chr(92)]}bar"; # works for ASCII
my $bs = chr(92); # works for ASCII
$_ = "$bs${bs}foo${bs}bar";
$_ = '//foo/bar';
$_ =~ tr#/#\\#;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 06 Oct 2004 18:18:28 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: initialize a list
Message-Id: <ck194l$ppa$1@sun3.bham.ac.uk>
gnu valued customer wrote:
> my ($a, $b, $c, $d, $e) = ('') x 5; # all 5 are defined
>
> my ($a, $b, $c, $d, $e) = (0) x 5; # works for int too
>
> Is the above use of the repetition operator (x) a
> good practice for initializing a List, or are there
> better ways?
Others have shown you a better way, but I would also like to point out
that you may want to take a step back and consider if you are doing the
right thing.
I work by the rule of thumb that says if you are doing it 3 times you
are probably doing it wrong. If you are initialising 5 separate scalar
values to the same initial value at the same point there's a strong
chance you really wanted some sort of agregate rather than 5 separate
scalars.
Note I said 'probably' and 'strong chance'- it doesn't always hold -
it's just something that you should think about.
------------------------------
Date: Wed, 06 Oct 2004 14:48:42 +0100
From: Kevin Thorpe <kevin@pricetrak.com>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <4163f657$0$17571$afc38c87@news.easynet.co.uk>
>>WTF has C++ to do with C?
>
>
> C++ is what C programmers tend to use when they find they
> actually needed OO features after all - and that
> consequently they started their project in the wrong language.
ROFLMAO - no really, I'm not kidding I literally cracked up.
You are soooooo correct. Who on earth decided to add object oriented
stuff to what is essentially a macro-assembler? I learned OO from
Smalltalk, C++ is fundamentally wrong and broken.
------------------------------
Date: Wed, 6 Oct 2004 15:59:18 +0200
From: Berislav Lopac <berislav.lopac@dimedia.hr>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <9uhjamy07t84$.50yva1q0m888.dlg@40tude.net>
On Wed, 6 Oct 2004 12:17:03 GMT, Tim Tyler wrote:
> In comp.lang.php Tony Marston <tony@nospam.demon.co.uk> wrote or quoted:
>> "Tim Tyler" <tim@tt1lock.org> wrote in message news:I50oKB.rM@bath.ac.uk...
>>> In comp.lang.php John Bokma <postmaster@castleamber.com> wrote or quoted:
>
>>>> For me Perl is #1 (if possible) because PHP is probably the worst
>>>> designed language ever.
>>>
>>> PHP was never designed. It evolved.
>>
>> Most languages evolve for the simple reason that nobody ever gets it right
>> the very first time. Ideas change over time, so languages must change to
>> keep up with the times.
>
> Much as I respect evolutionary approaches to design - if you were
> planning on building a rocket ship in 1995 - it would have been
> best not to have started with a steam engine - and to have attempted
> a series of gradual changes once the thing was going along.
True. But, as Chris said above, they never planned to build a rocket ship
-- PHP was originally just a simple wheelcart made for pushing some earth
around. That it evolved into the transgalactic cargo hauler it is today is
simply amazing.
Berislav
------------------------------
Date: Wed, 06 Oct 2004 18:03:35 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: map function problem
Message-Id: <ck188n$p76$1@sun3.bham.ac.uk>
George Kinley wrote:
> Hi
> I have following command
> @ar1=map {if (/\\/) {$_}} @arr;
> which populates the ar1 with where it files"\" in @arr BUT it also
> appends BLANK records where it does'nt ,
> my question is how to avoid appending blank records
The return value of a block is the value of the last expression
evaluated in that block.
In then case of a block where the last statement is an unsatified if
statement without an else clause the last expression executed is the
condition.
$foo = do { if ( 0 ) { 666 } }; # $foo = 0
$foo = do { if ( 0 ) { 666 } else { 777 }; # $foo = 777
$foo = do { if ( 1 ) { 666 } }; # $foo = 666
$foo = do { if ( '' ) { 666 } }; # $foo = ''
$foo = do { if ( undef ) { 666 } }; # $foo = undef
However I would not want to assume this behaviour would never change.
If you want to use an if statement in a non-void context always give it
an appropriate else clause...
@ar1=map { if (/\\/) { $_ } else { () } } @arr;
Of course, if you are goint to put the whole if () {} else {} on one
line it would be more conventional to use ?: instead.
Some people dislike using if in a non-void context altogether - but I
often find that for non-trivial expressions it is less unreadable than
the ?: approach. (Although often factoring-out the inline if altogether
is better still).
my %h = (
THIS => 1,
THAT => 2,
do {
if ( wibble() ) {
( WIBBLE => 'lots of stuff that really would make you' .
'loose track of where the ?: started' );
} else {
();
}
},
OTHER => 777,
);
------------------------------
Date: Wed, 06 Oct 2004 15:43:07 +0200
From: Jadeja Tripal <tripal@arcor.de>
Subject: perl net::ldap problem using variable eg attr => [ $v1,$v2..]
Message-Id: <4163f66a$0$12580$9b4e6d93@newsread4.arcor-online.net>
Hi to all,
Some background about system.
perl perl, v5.6.1 (solaris 8)
perl-ldap-0.28
openldap 2.0.23-6.3 (debian)
The following works
---------
$addr = $ldap ->add(
dn => $dn,
attr => [ 'sn'=>$sn,
'givenName' => $givenName,
'cn' => $cn,
'mail' => $mail,
'o' => 'Comapany GmbH',
'c' => 'DE',
'preferredLanguage' => 'DE',
'gidNumber' => $gid,
'uid' => $uid,
'uidNumber' => $uidn,
'homeDirectory' => $home,
'userPassword' => $pw,
'objectClass' =>
['top','shadowAccount','posixAccount','person','inetOrgPerson']
]
);
--------------
Following fails with error
failed to add entry: 'c'=>: attribute description contains
inappropriate characters
--------
my $a_c = "\'c\' \=\> \'DE\'" ;
$addr = $ldap ->add (
dn => $dn,
attr => [ 'sn'=>$sn,
'givenName' => $givenName,
'cn' => $cn,
'mail' => $mail,
'o' => 'Comapany GmbH',
$a_c ,
#'c' => 'DE',
'preferredLanguage' => 'DE',
'gidNumber' => $gid,
'uid' => $uid,
'uidNumber' => $uidn,
'homeDirectory' => $home,
'userPassword' => $pw,
'objectClass' =>
['top','shadowAccount','posixAccount','person','inetOrgPerson']
]
);
-------------
I am stuck with this, please help.
Thanks in advance
tripal
------------------------------
Date: Wed, 06 Oct 2004 14:15:07 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: perl net::ldap problem using variable eg attr => [ $v1,$v2..]
Message-Id: <L5T8d.461$Ua.372@trndny03>
> Following fails with error
>
> failed to add entry: 'c'=>: attribute description contains
> inappropriate characters
> --------
>
> my $a_c = "\'c\' \=\> \'DE\'" ;
This is one simple string.
> $addr = $ldap ->add (
> dn => $dn,
> attr => [ 'sn'=>$sn,
> 'givenName' => $givenName,
this is a pair of scalars, two members of a list.
> 'cn' => $cn,
so is this
> 'mail' => $mail,
and this.
> 'o' => 'Comapany GmbH',
etc.
> $a_c ,
This is one simple string.
$a_c is a string. It is not a pair of values.
If for some odd reason you actually wanted to store this particular pair
of values in a variable, it should be in an array, not a scalar:
my @a_c = qw/c DE/;
You can then include @a_c inside your list.
By the way, why are you using what is traditionally hash syntax inside
an array reference? Your syntax makes it look like you're trying to
build a list of key/value pairs, but you're storing all these elements
inside an array reference. Are you sure that shouldn't be a hash
reference?
Paul Lalli
> #'c' => 'DE',
> 'preferredLanguage' => 'DE',
> 'gidNumber' => $gid,
> 'uid' => $uid,
> 'uidNumber' => $uidn,
> 'homeDirectory' => $home,
> 'userPassword' => $pw,
> 'objectClass' =>
> ['top','shadowAccount','posixAccount','person','inetOrgPerson']
> ]
> );
> -------------
>
> I am stuck with this, please help.
>
>
> Thanks in advance
> tripal
------------------------------
Date: Wed, 06 Oct 2004 15:38:11 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: perl net::ldap problem using variable eg attr => [ $v1,$v2..]
Message-Id: <ck100j$u3f$1@news.freedom2surf.net>
In article <4163f66a$0$12580$9b4e6d93@newsread4.arcor-online.net>, "Jadeja
Tripal" <tripal@arcor.de> wrote:
> Hi to all,
> Some background about system.
> perl perl, v5.6.1 (solaris 8)
> perl-ldap-0.28
> openldap 2.0.23-6.3 (debian)
> The following works
> ---------
>
> $addr = $ldap ->add(
> dn => $dn,
> attr => [ 'sn'=>$sn,
>
> 'givenName' => $givenName,
> 'cn' => $cn,
> 'mail' => $mail,
> 'o' => 'Comapany GmbH',
> 'c' => 'DE',
Here, 'c'=>'DE' is a pair of strings separated by a (fat) comma. The
first string is a single char, a lower case 'c', the second is a 2
character string, upper case 'DE'. The => operator is merely a comma
which automatically quotes barewords to its left.
> 'preferredLanguage' => 'DE',
> 'gidNumber' => $gid,
> 'uid' => $uid,
> 'uidNumber' => $uidn,
> 'homeDirectory' => $home,
> 'userPassword' => $pw,
> 'objectClass' =>
> ['top','shadowAccount','posixAccount','person','inetOrgPerson']
> ]
> );
> --------------
> Following fails with error
> failed to add entry: 'c'=>: attribute description contains
> inappropriate characters
> --------
> my $a_c = "\'c\' \=\> \'DE\'" ;
> $addr = $ldap ->add (
> dn => $dn,
> attr => [ 'sn'=>$sn,
>
>
> 'givenName' => $givenName,
> 'cn' => $cn,
> 'mail' => $mail,
> 'o' => 'Comapany GmbH',
> $a_c ,
Here $a_c is a single string, "'c' => 'DE'". This is not decomposed into
2 strings because it has a fat comma (=>) inside it. The whole of this
string is taken to be a string in the attr arrayref. The error about
inappropriate characters is most likely bitching about the '=>', as it
mentions. Even if this were not the case, you would still have the
problem of having missed out a value string and this shuffling the later
strings so that keys become values and values become keys.
All this is because $a_c is a single string, regardless of its content,
and the construction here clearly needs 2 strings at this point.
You could achieve what you want by a variety of methods:
@a_c = (c=>'DE') then use @a_c in the attr def
%a_c = (c=>'DE') then use %a_c in the attr def
or even
$a_c = [c=>'DE'] then use @$a_c in the attr def
$a_c = {c=>'DE'} then use %$a_c in the attr def
> #'c' => 'DE',
> 'preferredLanguage' => 'DE',
> 'gidNumber' => $gid,
> 'uid' => $uid,
> 'uidNumber' => $uidn,
> 'homeDirectory' => $home,
> 'userPassword' => $pw,
> 'objectClass' =>
> ['top','shadowAccount','posixAccount','person','inetOrgPerson']
> ]
> );
> -------------
> I am stuck with this, please help.
> Thanks in advance
> tripal
------------------------------
Date: Wed, 06 Oct 2004 08:26:42 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: perl net::ldap problem using variable eg attr => [ $v1,$v2..]
Message-Id: <iefd32xc9q.ln2@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
On 2004-10-06, Paul Lalli <mritty@gmail.com> wrote:
> By the way, why are you using what is traditionally hash syntax inside
> an array reference? Your syntax makes it look like you're trying to
> build a list of key/value pairs, but you're storing all these elements
> inside an array reference. Are you sure that shouldn't be a hash
> reference?
The Net::LDAP documentation calls for an arrayref. In rare cases
perhaps the order in which you add attributes to an LDAP entry is
important. Net::LDAP must be written to handle this syntax, since
I've used it to add entries and it's worked fine.
- --keith
- --
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBZA6uhVcNCxZ5ID8RAk+LAJ9YcghKIp2tUF5Xk/WqadtJyom3+gCgjxnh
yKJgkgI4vWYowxihlb+H9j8=
=J7pW
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 6 Oct 2004 08:34:04 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regular Expression help please
Message-Id: <slrncm7t2c.66i.tadmc@magna.augustmail.com>
ZafT <deja_nospam_@zaft.com> wrote:
> Is there some sort of re-initiation I have to go through to get off
> everyone's ignore list,
Each person maintains their own ignore list, so you have to convince
each person to take your address back out.
I remain unconvinced, I saw profound "bad attitude" in your followup,
so you are staying in _my_ list at least. There are plenty of questions
for me to answer from folks that have not proven themselves less worthy.
My policy is once an address goes in, it never comes out.
(which seemed draconian when the possible "transgressions" were
unwritten. This was what motivated me to write them down in the
Posting Guidelines.
)
> or do I have to assume a new identity?
That is about the only way.
(But I'll point out that if _I_ recognize you using a new address, I'll
simply make another entry for the new address too.
My aim is to spend no more of my time on questions from you, I've
already spent "the limit".
)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 06 Oct 2004 08:33:29 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Regular Expression help please
Message-Id: <10m80hjd79i79d@corp.supernews.com>
ZafT wrote:
> Textpad
>
> Search for:
> \(foo\?[0-9]+\)\(["]*\)
>
> Replace with:
> \1.txt"
>
>
> UltraEdit
>
> Search for:
> ^(foo?*^)"
>
> Replace with:
> ^1.txt"
Actually, this underscores the problem with asking for RE help in a Perl
newsgroup. We could answer the question in Perl syntax, but that same
syntax may not work in your chosen application.
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7215
***************************************