[23457] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5672 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 16 18:05:46 2003

Date: Thu, 16 Oct 2003 15: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           Thu, 16 Oct 2003     Volume: 10 Number: 5672

Today's topics:
    Re: cleanup speed (named vs anonymous (and my?)) <ewilhelm@somethinglike.sbcglobalDOTnet>
    Re: How can i write the values of a form through a cgi  (JR)
    Re: How can i write the values of a form through a cgi  (Malcolm Dew-Jones)
    Re: How to generate 2 dimensional array-s? (Chris Charley)
    Re: How to generate 2 dimensional array-s? <GlgAs@netscape.net>
        Junior attempts binary data manipulation <jidanni@jidanni.org>
    Re: Junior attempts binary data manipulation <invalid-email@rochester.rr.com>
        line to array convertion (arctan)
    Re: line to array convertion <noreply@gunnar.cc>
    Re: line to array convertion <asu1@c-o-r-n-e-l-l.edu>
    Re: line to array convertion <invalid-email@rochester.rr.com>
        multi-platform support for perl (kepper)
    Re: Need help with "substitute" operator.... <krahnj@acm.org>
    Re: Need help with "substitute" operator.... <richp1234@hotmail.com>
    Re: Need help with "substitute" operator.... <djo@pacifier.com>
        Perl book for learning interface programming under win3 <aon.964008690@aon.at>
    Re: Perl scripts for Unix on my windows machine (Anno Siegel)
    Re: Q: Problem figuring out versions of DBI <dpetrou@ece.cmu.edu>
    Re: Q: Problem figuring out versions of DBI <dpetrou@ece.cmu.edu>
    Re: Q: Problem figuring out versions of DBI <dpetrou@ece.cmu.edu>
    Re: Q: Problem figuring out versions of DBI <invalid-email@rochester.rr.com>
    Re: Q: Problem figuring out versions of DBI <dpetrou@ece.cmu.edu>
    Re: Q: Problem figuring out versions of DBI <cpryce@pryce.net>
    Re: Unexpected alteration of array's content (Anno Siegel)
    Re: Unexpected alteration of array's content (Anno Siegel)
    Re: Unexpected alteration of array's content (Roy Johnson)
    Re: XSL - 3 lines explaination <syscjm@gwu.edu>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 16 Oct 2003 19:14:30 GMT
From: Eric Wilhelm <ewilhelm@somethinglike.sbcglobalDOTnet>
Subject: Re: cleanup speed (named vs anonymous (and my?))
Message-Id: <pan.2003.10.16.14.14.30.731326.13509@somethinglike.sbcglobalDOTnet>

On Thu, 16 Oct 2003 06:59:57 -0500, Brian McCauley wrote:

>> What about a DESTROY function?
> 
> All that does is allow you some control over the cleanup.  I don't see
> how it could make the cleanup faster.  You could use a DESTROY function
> so that CAD::Drawings usually cleaned up after itself but so that the
> user could set a flag to tell CAD::Drawing that the program is about to
> end and that it can forget cleaning up hereafter.
> 
>> I guess I'll have to try a few things, but I'd really like to find a
>> reason for the slowdown.
> 
> You have found the reason.

Thanks.  I'll have to think about this.

It would be great if I could detect whether the return value of new() was
headed for a lexical variable, but it looks like the default behavior
needs to be the one that doesn't leak:)

The situation where a lot of data accumulates inside of the object is
typically going to be the one that is outside of all of the loops
(example: a program which generates multiple small drawings inside of a
loop, but saves one big drawing at the end and then exits.)

For now, I guess it will be an option in new()

--Eric


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

Date: 16 Oct 2003 12:57:41 -0700
From: jorenders@hotmail.com (JR)
Subject: Re: How can i write the values of a form through a cgi script in a txt file.
Message-Id: <4096148f.0310161157.9400327@posting.google.com>

Tore Aursand <tore@aursand.no> wrote in message news:<pan.2003.10.15.18.41.09.901981@aursand.no>...
> On Wed, 15 Oct 2003 10:33:23 -0700, JR wrote:
> > How can i write the values of a form through a cgi script in a txt file.
> 
> What have you tried so far?  What doesn't work?

#!/usr/bin/perl

print "Content-type:text/html\n\n";

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
}

print "<html><head><title>Form Output</title></head><body>";
print "<h2>Results from FORM post</h2>\n";

open (EEP,"passwords.txt");foreach $key (keys(%FORM)) {
    print EEP "$key = $FORM{$key}<br>";
}

print "</body></html>";

close(EEP);

I can show them on the screen but not in a file


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

Date: 16 Oct 2003 14:05:46 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: How can i write the values of a form through a cgi script in a txt file.
Message-Id: <3f8f082a@news.victoria.tc.ca>

JR (jorenders@hotmail.com) wrote:
: Tore Aursand <tore@aursand.no> wrote in message news:<pan.2003.10.15.18.41.09.901981@aursand.no>...
: > On Wed, 15 Oct 2003 10:33:23 -0700, JR wrote:
: > > How can i write the values of a form through a cgi script in a txt file.
: > 
: > What have you tried so far?  What doesn't work?

: #!/usr/bin/perl

: print "Content-type:text/html\n\n";

: read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
: @pairs = split(/&/, $buffer);
: foreach $pair (@pairs) {
:     ($name, $value) = split(/=/, $pair);
:     $value =~ tr/+/ /;
:     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
:     $FORM{$name} = $value;
: }

: print "<html><head><title>Form Output</title></head><body>";
: print "<h2>Results from FORM post</h2>\n";

: open (EEP,"passwords.txt");foreach $key (keys(%FORM)) {
:     print EEP "$key = $FORM{$key}<br>";
: }

: print "</body></html>";

: close(EEP);

: I can show them on the screen but not in a file

1st, have you considered CGI.pm?  It is much easier to advance to file
uploads etc if you are already using CGI.pm, and that single `use' line is
a lot less error prone to write each time you write a cgi script

	#!perl
	use CGI qw(:standard); # or read the docs `perldoc CGI'
	print header;

2nd, always check the error code for open and anything else that could 
fail, and then at least tell yourself about any problems...

	open (EEP,"passwords.txt") or print "<h1>open error: $!</h1>";

	print EEP "string"         or print "print EEP error: $!";


(I would write `or warn...' OR `or die...', but the above is easiest to 
get started with in cgi as they won't cause other spurious problems with 
the output formats.)

3rd, to write into EEP you must have opened the file for write access 
first

	`perldoc -f open'



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

Date: 16 Oct 2003 12:19:20 -0700
From: charley@pulsenet.com (Chris Charley)
Subject: Re: How to generate 2 dimensional array-s?
Message-Id: <4f7ed6d.0310161119.2b532cce@posting.google.com>

GlgAs@Netscape.net (laszlo) wrote in message news:<945e4584.0310160701.9bd1825@posting.google.com>...
> I have an array which is consisted of comma separated lists, one list
> for each row. I would like to generate a two dimensional array.


my @array=("1,0,0", "0,1,0", "0,0,1");
my @two_d;
push @two_d, [split/,/] for @array;



>Also how can I find the length of the $i-th row
> without saving it into separate array?

my $len = @{ $two_d[$i] };


HTH
Chris


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

Date: Thu, 16 Oct 2003 20:28:40 GMT
From: gilgames <GlgAs@netscape.net>
Subject: Re: How to generate 2 dimensional array-s?
Message-Id: <YbDjb.2822$8x2.1622537@newssrv26.news.prodigy.com>

<<
 >I have an array which is consisted of comma separated lists, one list
 >> for each row. I would like to generate a two dimensional array.



my @array=("1,0,0", "0,1,0", "0,0,1");
my @two_d;
push @two_d, [split/,/] for @array;




 >>Also how can I find the length of the $i-th row
 >> without saving it into separate array?


my $len = @{ $two_d[$i] };


HTH
Chris
 >>

Thanks, it works.



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

Date: Fri, 17 Oct 2003 02:58:28 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: Junior attempts binary data manipulation
Message-Id: <87y8vlui0b.fsf@jidanni.org>

Say, I'm going to be making this file, each line with a time() string,
and a count,
print time ." ". 257
1066329734 257
I started thinking about space saving methods,
printf "%x %x", time, 257
3f8ee6df 101
why don't I just make the file
[4 byte time][2 byte count][4 byte time][2 byte count]...
that way, each time I append a time,count pair to the file, I only add
6 bytes.  Ok, so how do I write out such raw records, and how might I
turn such a file back into ASCII? Something like chr,ord... Assume the
file will not leave the machine, so byte order is not a problem.


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

Date: Thu, 16 Oct 2003 21:53:13 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Junior attempts binary data manipulation
Message-Id: <3F8F1195.2080708@rochester.rr.com>

Dan Jacobson wrote:

> Say, I'm going to be making this file, each line with a time() string,
> and a count,
> print time ." ". 257
> 1066329734 257
> I started thinking about space saving methods,
> printf "%x %x", time, 257
> 3f8ee6df 101
> why don't I just make the file
> [4 byte time][2 byte count][4 byte time][2 byte count]...
> that way, each time I append a time,count pair to the file, I only add
> 6 bytes.  Ok, so how do I write out such raw records, and how might I
> turn such a file back into ASCII? Something like chr,ord... Assume the
> file will not leave the machine, so byte order is not a problem.
> 

    perldoc -f pack

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: 16 Oct 2003 14:28:04 -0700
From: arctan@moonman.com (arctan)
Subject: line to array convertion
Message-Id: <c6d76a1b.0310161328.7df445bc@posting.google.com>

Hello Group

I am facing a problem well beyond my perl skills, and I would greatly
appreciate help or suggestions.

What I would like to do is start with a 1 line text file of n text
charachters. (spaceless, tabless, with all \s white space removed)

Then I would like to transform that to a text file of n lines, each
containing one text charachter, and no whitspace or special
charachters except of course the newline.

so if file looked like:

tokpsf

Then after script Id get:

t
o
k
p
s
f



Thanks alot in advance for any suggestions


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

Date: Thu, 16 Oct 2003 23:36:11 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: line to array convertion
Message-Id: <bmn32v$oh39d$1@ID-184292.news.uni-berlin.de>

arctan wrote:
> I am facing a problem well beyond my perl skills, and I would
> greatly appreciate help or suggestions.
-----------------------------^^^^^^^^^^

     http://learn.perl.org/

Especially you may want to check out the split() function.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 16 Oct 2003 21:44:33 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: line to array convertion
Message-Id: <Xns9416B47CCF9FAasu1cornelledu@132.236.56.8>

arctan@moonman.com (arctan) wrote in 
news:c6d76a1b.0310161328.7df445bc@posting.google.com:

> so if file looked like:
> 
> tokpsf
> 
> Then after script Id get:
> 
> t
> o
> k
> p
> s
> f

#! perl

use strict;
use warnings;

my $line = 'perldoc-fsplit';
my @lines = split('', $line);
print map("$_\n", @lines);
__END__


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

Date: Thu, 16 Oct 2003 21:50:08 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: line to array convertion
Message-Id: <3F8F10DD.2060603@rochester.rr.com>

arctan wrote:

> Hello Group
> 
> I am facing a problem well beyond my perl skills, and I would greatly
> appreciate help or suggestions.
> 
> What I would like to do is start with a 1 line text file of n text
> charachters. (spaceless, tabless, with all \s white space removed)
> 
> Then I would like to transform that to a text file of n lines, each
> containing one text charachter, and no whitspace or special
> charachters except of course the newline.
> 
> so if file looked like:
> 
> tokpsf
> 
> Then after script Id get:
> 
> t
> o
> k
> p
> s
> f
> 
> 
> 
> Thanks alot in advance for any suggestions
> 


on Windoze:


    perl -i.bak -pe "$_=join qq(\n),split //"

on *nix:

    perl -i.bak -pe '$_=join "\n",split //'

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: 16 Oct 2003 13:25:30 -0700
From: menogeek@hotmail.com (kepper)
Subject: multi-platform support for perl
Message-Id: <ba7ac334.0310161225.57124cad@posting.google.com>

Hi All, (questions at the end of this paragraph)
I work for a company that developes software for several UNIX
platforms like Solaris, HP-UX, Tru64, LINUX, and AIX.  We have been
using the native package creators (ie. SD-UX, pkgadd, etc) to make and
install our software products.  Now, because we want to implement a
patching philosopy, the way we install our product has to change. 
That means doing away with native package creators.  I have been
tasked with creating a proprietary installer and patch component for
our product.  I have chosen Perl as the scripting language to do this.
 At best, i'm an advanced newbie.  I have used Perl for a few projects
in the past, and they are all simple Perl scripts.  Now, because I
need extra functionality, I am forced somewhat to rely on Perl
Modules.  It dawned on me today that these modules will have to be
provided on our product CD when the install or patch occurs.  So, I
immediately downloaded the latest Perl source and built it on HP-UX.
(BTW, I primarily work on a LINUX box for my developement).  I finally
got through a compile of the Perl executable and tested my script on
HP-UX.  I ran into all sorts of problems.  On my LINUX developement
box, I have my .pm files stored in the same directory as my script. 
When I initially ran my script on the HP-UX box, it immediately
complained that it couldn't find a certain .pm file.  I sym-linked it
to the HP-UX directory (which, BTW, happens to be the Perl source tree
top).  I ran the script again and it complained about a .pm file that
i'm not using in my script.  Turns out it's a "use" in another .pm
file.  After about 7 or 8 more of these kind of errors, I did some
digging on how to best deal with this.  I created a "mylibs" directory
and moved my .pm files there.  Inside my script, on line 2, I entered
"use lib "mylibs";".  This supposedly looks immediately in the mylibs
directory for any .pm files.  Now, when I run my script, I get the
following error: Can't locate lib.pm in @INC
I have googled this message and all the answers seem to suggest that
it is caused by an improper installation of Perl.  I did not do an
install of Perl (what I mean is I did not do "make install").  I am
using the source tree version of Perl in my HP-UX directory.  I'm not
sure what violation, if any, this is causing.  But, here are some
questions I have about how to use Perl on multi-platform:

1. How can I solve this problem?
2. Do I have to "make install" Perl or can I use the source tree
version of Perl?
3. My customers will be installing from a CD-ROM and I have to assume
that Perl is not installed on their system, so when I invoke my
script, the first line will read "#!./perl".  Are there any pitfalls
in doing this.  I am going to create a "mylibs or mymods" directory to
store Perl modules.  Is there a better way to do this?

Any help would be greatly appreciated.

-kepper (rhymes with pepper  :P)


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

Date: Thu, 16 Oct 2003 21:18:39 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Need help with "substitute" operator....
Message-Id: <3F8F0B0F.E6EDB786@acm.org>

Rich Pasco wrote:
> 
> I'm not quite an expert in regular expressions yet...
> 
> I am trying to figure out a Perl "substitute" operator which will
> change any instances of "\*" (that's backslash asterisk) with "*"
> (an asterisk by itself), and also, if there are any asterisks not
> preceded by a backslahs, delete them and the remaining characters
> from there to the end of the string.
> 
> For example, let
> 
>   $str = 'It is \*urgent\* to do! * ignore this comment';
> 
> should turn into
> 
>   It is *urgent* to do!

$str =~ s/\\(\*)|\*.*/$1/g;


John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 16 Oct 2003 14:49:02 -0700
From: Rich Pasco <richp1234@hotmail.com>
Subject: Re: Need help with "substitute" operator....
Message-Id: <c5OdnePvJq8YjxKiXTWc-g@speakeasy.net>

I had asked,

> I am trying to figure out a Perl "substitute" operator which will
> change any instances of "\*" (that's backslash asterisk) with "*"
> (an asterisk by itself), and also, if there are any asterisks not
> preceded by a backslash, delete them and the remaining characters
> from there to the end of the string.

Brian McCauley wrote:

> $str = 'It is \*urgent\* to do! * ignore this comment';
> $str =~ s/(^|[^\\])\*.*/$1/; # Remove remove * not preceded by \ to EOL
> $str =~ s/\\\*/*/g;          # Replace \* with *.
> print "$str\n";

Glenn Jackman wrote:

> First, remove the trailing comment (a * not preceded by \):
>     $str =~ s/[^\\]\*.*//;
> Note, that a * at the beginning of the string will not match.
>
> Then, replace all escaped asterisks:
>     $str =~ s/\\\*/*/g;

John W. Krahn wrote:

> $str =~ s/\\(\*)|\*.*/$1/g;

Thanks to all who answered, good ideas all.  Actually John's solution
looks simplest, so I think I may go with that, unless anyone can see
any potential problems with it.

     - Rich




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

Date: Thu, 16 Oct 2003 21:52:07 GMT
From: "David Oswald" <djo@pacifier.com>
Subject: Re: Need help with "substitute" operator....
Message-Id: <bqEjb.13997$YO5.6446388@news3.news.adelphia.net>


"Rich Pasco" <richp1234@hotmail.com> wrote in message
news:QhycnXkTHLCPXhOiXTWc-g@speakeasy.net...
> I am trying to figure out a Perl "substitute" operator which will
> change any instances of "\*" (that's backslash asterisk) with "*"
> (an asterisk by itself), and also, if there are any asterisks not
> preceded by a backslahs, delete them and the remaining characters
> from there to the end of the string.
>
> For example, let
>
>   $str = 'It is \*urgent\* to do! * ignore this comment';
>
> should turn into
>
>   It is *urgent* to do!

my $string = "It is \*urgent\* to do! * ignore this comment';
$string =~ s/(?<!\\)\*.*$//;
$string =~s/\\(?=\*)//g;

The first substitution finds any asterisk that doesn't have a backslash in
front of it, and deletes everything from that point to the end of the line.

The second substitution finds any backslash that is followed by an asterisk
and deletes the backslash.

Dave




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

Date: Thu, 16 Oct 2003 22:45:21 +0200
From: Markus Praher <aon.964008690@aon.at>
Subject: Perl book for learning interface programming under win32
Message-Id: <3F8F0361.8070504@aon.at>

Hello!

I am seaching for a good perl book about programming USB-,  Fire wire-, 
rerial-, parallel-ports,... under windows.  It should also include examples.

It would be very nice if you can help me.

Thank you.



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

Date: 16 Oct 2003 21:58:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <bmn49m$m1g$1@mamenchi.zrz.TU-Berlin.DE>

Ren Patterson <reneap@hotmail.com> wrote in comp.lang.perl.misc:

[...]

> In case you do not get it yet I will repeat, I searched for the answer
> and I was not sure if I would cause my computer harm by installing it
> and then finding out afterwards. Is that too hard to grasp?

Easy to grasp, but hard to believe.

For the record, the question was "Is there a foreknown reason why the
Unix scripts would not work in these environments?"

Anno


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

Date: 16 Oct 2003 19:10:57 GMT
From: David Petrou <dpetrou@ece.cmu.edu>
Subject: Re: Q: Problem figuring out versions of DBI
Message-Id: <bmmqg1$3ia$1@nntp.ece.cmu.edu>

Bob Walton <invalid-email@rochester.rr.com> wrote:
> I note that method installed_versions is not mentioned in the DBI docs. 
>   Where did you get the idea to use it?

http://search.cpan.org/~timb/DBI-1.38/DBI.pm

> Bob Walton
> Email: http://bwalton.com/cgi-bin/emailbob.pl

thanks,
david


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

Date: 16 Oct 2003 19:13:16 GMT
From: David Petrou <dpetrou@ece.cmu.edu>
Subject: Re: Q: Problem figuring out versions of DBI
Message-Id: <bmmqkc$3ia$2@nntp.ece.cmu.edu>

Juha Laiho <Juha.Laiho@iki.fi> wrote:
> dpetrou@cs.cmu.edu said:
>>Hi.  I have a bunch of DBI questions I'm hoping ya'll can help me
>>with.  They are real simple questions, but I'm stymied after searching
>>the usual channels for answers.
> ...
>>The reason why I'm trying to figure out my DBI version is so that I
>>can upgrade, if needed to 2.1022 which is recommended for the version
>>of MySQL that I have installed.

> Hmm.. don't know whether this is the correct way, but at least works
> for my antique DBI:
> perm -MDBI -e 'print $DBI::VERSION;'

cool.  that works for me.  i have version 1.21.  perhaps the
installed_versions method was introduced in a later version.

> DBI doesn't contain DBDs, so you'll have to pick the ones important
> for you. But then, you'll find them at your closest CPAN mirror, so
> no hunting needed.

thanks!
david


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

Date: 16 Oct 2003 19:18:09 GMT
From: David Petrou <dpetrou@ece.cmu.edu>
Subject: Re: Q: Problem figuring out versions of DBI
Message-Id: <bmmqth$3ia$3@nntp.ece.cmu.edu>

James Willmore <jwillmore@remove.adelphia.net> wrote:
> To get the available drivers, there's a
> different method.  Read the DBI documentation for more information.

i couldn't find the info in the DBI doc, but the following gave me the
info on DBD::mysql, which is what i'm using:

perl -MDBI -MDBD::mysql -e 'print $DBD::mysql::VERSION;'

> Ouch!  You're trying to install DBD::mysql on a machine that does
> _not_ have MySQL installed on it?

no, that's not what i want to do.

i want to know how to tell DBD::mysql to look for my mysql
installation which is in a non-standard place.

right now, i have an old version of mysql installed in
/usr/local/mysql.  i cannot uninstall this copy.  i don't want
DBD::mysql to use it.

i have a new version of mysql installed off my home dir.  it's before
/usr/local/mysql in my path, but i just don't know whether DBD::mysql
is in fact using it, or is using /usr/local/mysql.

> Each different database system has it's own set of drivers.  So, yes,
> you have to hunt for the proper drivers.

thanks!
david


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

Date: Thu, 16 Oct 2003 21:26:45 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Q: Problem figuring out versions of DBI
Message-Id: <3F8F0B8E.6060909@rochester.rr.com>

David Petrou wrote:

> Bob Walton <invalid-email@rochester.rr.com> wrote:
> 
>>I note that method installed_versions is not mentioned in the DBI docs. 
>>  Where did you get the idea to use it?
>>
> 
> http://search.cpan.org/~timb/DBI-1.38/DBI.pm
> 
> 
>>Bob Walton
 ...
> david
> 

New item in version 1.38, I guess -- it's not in 1.37.  What version of 
DBI are you actually running?

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: 16 Oct 2003 21:36:15 GMT
From: David Petrou <dpetrou@ece.cmu.edu>
Subject: Re: Q: Problem figuring out versions of DBI
Message-Id: <bmn30f$61u$1@nntp.ece.cmu.edu>

Bob Walton <invalid-email@rochester.rr.com> wrote:
> New item in version 1.38, I guess -- it's not in 1.37.  What version of 
> DBI are you actually running?

1.37 also.

thanks,
david


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

Date: Thu, 16 Oct 2003 16:43:17 -0500
From: cp <cpryce@pryce.net>
Subject: Re: Q: Problem figuring out versions of DBI
Message-Id: <161020031643176216%cpryce@pryce.net>

In article <bmmqth$3ia$3@nntp.ece.cmu.edu>, David Petrou
<dpetrou@ece.cmu.edu> wrote:

> i want to know how to tell DBD::mysql to look for my mysql
> installation which is in a non-standard place.
> 
> right now, i have an old version of mysql installed in
> /usr/local/mysql.  i cannot uninstall this copy.  i don't want
> DBD::mysql to use it.
> 
> i have a new version of mysql installed off my home dir.  it's before
> /usr/local/mysql in my path, but i just don't know whether DBD::mysql
> is in fact using it, or is using /usr/local/mysql.


You probably want to have a look at the DBD::mysql installation guide.
It's posted conveniently on line as

http://search.cpan.org/src/RUDY/DBD-mysql-2.9002/INSTALL.html#configurat
ion

RTFM. This information took all of ten seconds to find.

-- 
cp


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

Date: 16 Oct 2003 18:21:54 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Unexpected alteration of array's content
Message-Id: <bmmnk2$f88$1@mamenchi.zrz.TU-Berlin.DE>

Roy Johnson <rjohnson@shell.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> news:<bmkji9$3kj$1@mamenchi.zrz.TU-Berlin.DE>...
> > Well, that is in the eye of the beholder.

[getting used to hard-to-read idioms]

> > No blink-effect there, not after a few years of the same.
> 
> Of course, this argument doesn't apply to something you said was not
> going to be common.

Even uncommon things leave an impression if they're uncommon in an
interesting way.  The construct "$count = () = <something that wants
array context>" isn't very common either, but most Perl programmers
know it, probably because it sends everyone on a trip to the docs when
they see it first.  Talk about readability...

> > In one context, the "@{[ ... ]}" construct *is* idiomatic.  It is regularly
> > used to interpolate arbitrary expressions into strings, as in
> > 
> >     print "1 + 2 = @{[ 1 + 2 ]}\n";
> 
> The only appeal of this is to the bloody-minded desire to do
> everything with interpolation. It could be written more clearly as
>     print '1 + 2 = ', 1+2, "\n";
> or, if the creation of a string were desired,
>     $str = '1 + 2 = ' . (1 + 2) . "\n";
> I don't see anything particularly onerous about either of those, for
> writing or for reading. Do you?

Not at all, I write a lot that way.  If I had a series of strings, all
compactly interpolated except one where I want to insert an expression,
I might consider array interpolation.

In qr// interpolation it is hard to find an alternative, because
concatenation would defeat the purpose.  That is one of the drawbacks
of qr///.

[...]

> > Another is a fix to a misbehaving map or grep.  "Oops, it's changing my
> > array!  Let's put @{[ ... ]} around it."
> 
> This is the best example, but it still smacks of a quick and dirty
> fix.

[alternatives]

I could probably come up with a situation where it's clearly the Thing To
Do, but there's the tediosity factor to consider...

> You seem to be playing both sides of the fence. If it's not going to
> come up often, the blink reflex isn't going to wear off. Solutions to
> unconventional problems are always going to require an instant of "oh,
> that's what he's doing". That's not a bad thing. What is a bad thing,
> IMO, is when solutions to common problems require that.

What is accepted as an idiom in a language, and what remains an oddity,
is not only decided by necessity, it is also a cultural thing.  This is
true for natural languages, but also, to a lesser degree, for computer
languages.  It may be more true for Perl than for most, because Perl puts
comparatively few necessities in the programmer's way.

> Again, this particular example isn't terribly obfuscated. It's just
> not a "best practice" (to borrow a phrase that probably has a high
> cringe factor). The mindset that "the most succinct solution is the
> one to use" is seductive, and warned against in perlstyle (though
> probably not in those words). The most straightforward, legible
> solution is the one to use, unless there is some distinct advantage to
> a more arcane one.

I agree that programs should written with the reader in mind.  But that
means in fact that they are, at best, written with one specific readership
in mind.  What readership a programmer expects may vary.  Like different
kinds of books make different demands, so may programs.  What is
obfuscated in one could be just stylish in another.

It was interesting to collect some plausible uses of the @{[ ... ]}
phrase.  Here is another:  To de-fuse an argument-modifying function
(that is, call it but don't let it change the arguments), you can say
"sub non_modifying { modifying( @{ [@_] })" without knowing anything
about the modifying function or its calls.

Anno


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

Date: 16 Oct 2003 19:04:01 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Unexpected alteration of array's content
Message-Id: <bmmq31$grp$1@mamenchi.zrz.TU-Berlin.DE>

Uri Guttman  <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> >>>>> "RJ" == Roy Johnson <rjohnson@shell.com> writes:
> 
>   RJ> I don't consider @{[...]} to be horrible, just mildly distasteful. It
>   RJ> gets worse depending on the size of the array.
> 
> i jumped in the middle of this thread (and i am not going back to the
> very beginning) but wouldn't a simple @foo = ( blah ) be enough? if you

Yes.  We're discussing the case where you don't want to do that for
some reason.

> have a reference already then @{$ref} is fine. so where would @{[ blah
> ]} be needed except to interpolate?

Well, abstractly speaking, when you want an anonymous copy of the list.
More concretely... uh, I don't think you really want to know, there
was nothing earth-shattering.  Post a followup and I'll make an excerpt
from the thread if you want one.

>                                      i see the word 'copy' in the thread
> and no reason for using a full anon array and deref. it seems to be a
> waste of an extra copy (the anon array is tossed!).

Thread drift...

Anno


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

Date: 16 Oct 2003 14:57:07 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Unexpected alteration of array's content
Message-Id: <3ee08638.0310161357.3573078d@posting.google.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<bmmnk2$f88$1@mamenchi.zrz.TU-Berlin.DE>...
> Even uncommon things leave an impression if they're uncommon in an
> interesting way.

Yes, but there is *still* a blink, then an "oh, yeah," and possibly an
"I wish they wouldn't do this crap."

> The construct "$count = () = <something that wants
> array context>" isn't very common either, but most Perl programmers
> know it

I just saw it for the first time lately. Still a blink, but a useful
one, because Perl doesn't have any operator expressly for the purpose
of providing list context.

> In qr// interpolation it is hard to find an alternative

It is hard to imagine the necessity of ${[@foo]} in qr//. Did you have
something in mind?

> I agree that programs should written with the reader in mind.  But that
> means in fact that they are, at best, written with one specific readership
> in mind.

Presumably, it would generally be the Perl-literate readership in
mind, and not the JAPH-minded readership. There are many tools
specifically designed for many basic tasks. Perl-literate people are
aware of the common uses.

> What is obfuscated in one could be just stylish in another.

Good style enhances readability. It doesn't interrupt it.

> Here is another:  To de-fuse an argument-modifying function
> (that is, call it but don't let it change the arguments), you can say
> "sub non_modifying { modifying( @{ [@_] })" without knowing anything
> about the modifying function or its calls.

But don't you think that
    sub non_modifying { modifying( my @scratch=@_ ) }
is still a tad more clear? It's certainly a well-established idiom.
:-)


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

Date: Thu, 16 Oct 2003 15:01:43 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: XSL - 3 lines explaination
Message-Id: <3F8EEB17.9000900@gwu.edu>

Kasp wrote:
> Below is a XSL that I can barely understand being a newbie to XSL world.

I must have missed something.  What was your perl question, again?

                            Chris Mattern



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 5672
***************************************


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