[16324] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3736 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 14:10:37 2000

Date: Tue, 18 Jul 2000 11:10:24 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963943824-v9-i3736@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 18 Jul 2000     Volume: 9 Number: 3736

Today's topics:
    Re: NEW: AI::NeuralNetwork - idea, comments <newspost@coppit.org>
    Re: no newlines and ANDING <npecca@yahoo.com>
    Re: no newlines and ANDING nobull@mail.com
    Re: NT4 can't create file in cgi-bin hacktic@my-deja.com
        Numerical evaluation in string <anuragmenon@my-deja.com>
        Perl and Sendmail??? lefkogt@my-deja.com
        Perl String???? lefkogt@my-deja.com
    Re: Perl String???? <cal@iamcal.com>
    Re: Producing an executable for Perl program vgm32@my-deja.com
        regular expression help please ! <tb97@usa.net>
    Re: regular expression help please ! <care227@attglobal.net>
    Re: regular expression help please ! <UlleAckermann@t-online.de>
    Re: regular expression help please ! <mike.solomon@eps.ltd.uk>
    Re: regular expression help please ! <lr@hpl.hp.com>
    Re: regular expression help please ! <sariq@texas.net>
    Re: Renaming files trough Perl? <lr@hpl.hp.com>
    Re: Running a CGI script <beshiffm@my-deja.com>
    Re: searching for a # within a range (Tad McClellan)
    Re: searching for a # within a range nobull@mail.com
    Re: Semi-newbie Regex question. <cal@iamcal.com>
        Socket closure problem with AS Perl 616 <michaels@my-deja.com>
        Sorting multidimensional arrays <no_email@no_email.com>
    Re: Sorting multidimensional arrays (Cameron Kennedy)
    Re: SSL programs nobull@mail.com
    Re: This software is worth to try.... <gte941n@prism.gatech.edu>
        Truly Orthogonal Persistence newsvan33@hotmail.com
    Re: Unflattening a multi-dimensional array (Neil Kandalgaonkar)
    Re: why does this not work? (Malcolm Ray)
    Re: why does this not work? <mike.solomon@eps.ltd.uk>
    Re: why does this not work? <gte941n@prism.gatech.edu>
    Re: why does this not work? (M.J.T. Guy)
    Re: why does this not work? <aqumsieh@hyperchip.com>
    Re: why does this not work? <gte941n@prism.gatech.edu>
    Re: why does this not work? <gte941n@prism.gatech.edu>
    Re: why does this not work? (Tad McClellan)
    Re: why does this not work? <gte941n@prism.gatech.edu>
    Re: Yet another string manipulation question - <anuragmenon@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 18 Jul 2000 11:17:45 -0400
From: David Coppit <newspost@coppit.org>
To: Logan Shaw <logan@cs.utexas.edu>
Subject: Re: NEW: AI::NeuralNetwork - idea, comments
Message-Id: <Pine.GSO.4.21.0007181115500.19498-100000@mamba.cs.Virginia.EDU>

On 18 Jul 2000, Logan Shaw wrote:

> In article <39741A48.C0A9E4FC@la.znet.com>,
> Kiralynne Schilitubi  <callgirl@la.znet.com> wrote:
> >I will register an objection to use of "AI" within
> >your module name. This suggests your module employs
> >"Artificial Intelligence" which is, with current
> >technology, regardless of programming language,
> >quite impossible even at a primitive level.
> >We are centuries away from any programming
> >which can be labeled, Artificial Intelligence,
> >with any degree of accuracy and truth.
> 
> Have you sent e-mail to the AAAI and the MIT AI lab informing them of
> their error?  It seems like you'd want to set them straight first,
> since they're higher profile groups so therefore they must be more
> embarassing.  While you're at it, there are hundreds of other
> university CS departments that need to be corrected as well.

Heh. Even "computer science" is misnamed, since it's more "computing science"
-- the science of computing.

> Having said all that, I'm just going to mention that "AI::NeuralNet" is
> shorter and just as clear.  But either seems great to me.

Agreed. I doubt anyone would have a problem understanding this classification.
(The only other possibility may be Algorithm::NeuralNet)

David



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

Date: Tue, 18 Jul 2000 19:31:15 +0400
From: "HB" <npecca@yahoo.com>
Subject: Re: no newlines and ANDING
Message-Id: <39747b0d@news.telekom.ru>

Slippery wrote...
> print "this is a test\n";
> but I am not getting any newlines

print "this is a HTML test<BR>\n...and this is it's 2nd line";

> Also, can we use bitwise operators.
> in VB6, I would use
> if (res AND 1)=1 then.....

 ... and in Perl, it will look like

if ( ($res & 1)==1 ) {.....}   #### 1st variant

if ($res & 1) {.....}          #### 2nd variant

 ..... if ( ($res & 1)==1 )     #### 3rd variant

 ..... if ($res & 1)            #### 4th variant

($res & 1) and .....           #### 5th variant

($res & 1) &&  .....           #### 6th variant

Perl is a bit more flexible than VB. I'd even say _a_byte_ more
flexible.







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

Date: 18 Jul 2000 17:43:21 +0100
From: nobull@mail.com
Subject: Re: no newlines and ANDING
Message-Id: <u9lmyzpexi.fsf@wcl-l.bham.ac.uk>

"Slippery" <richard.salute@redhotant.com> writes:

> Subject: Re: no newlines and ANDING

If you have two unrelated questions please post two separate articles.

> I am outputting a page eg print "this is a test\n"; but I am not getting any
> newlines.  It all appears as one huge line......Please help?

I'm guessing this has nothing to do with Perl.  You are probably
displaying the output in a web browser using content-type text/html.

> Also, can we use bitwise operators.

Dunno.  Can you read manuals?

>  in VB6, I would use  if  (res AND 1)=1
> then.....    How would I do it in perl.

See the documentation on Perl operators "perldoc perlop", in
particular the section on bitwise operators.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 18 Jul 2000 17:08:42 GMT
From: hacktic@my-deja.com
Subject: Re: NT4 can't create file in cgi-bin
Message-Id: <8l22u9$9f$1@nnrp1.deja.com>

Hi Jason,

I think I found out what went wrong ... it has something to do with
virtual directories. Every time I run a Perl script from the scripts
directory (named 'cgi-bin'), it acts as if its ran from the root
directory and I would need to specify 'cgi-bin\\test.txt' if I needed
to create a file in the cgi-bin directory. Quite weird if you'd ask me
though, not?

Thanks for the $! tip. I didn't know about that one.

Regards;
-Mark-

> >On a NT4 server where I only have FTP access, I tried to create a
file
> >in the cgi-bin with a Perl script, but it returns the msg that it
can't
> >make the file.
> >
> >#!perl
> >open(FP, ">test.txt")||print("Can't make file.");
> >print FP ("this is a test");
> >close(FP);
> >print "Hello world!";
> >
> >I thought it might be some restriction set on the scripts directory
by
> >the IIS. So I thought to write the text file in the root directory
or a
> >parent directory with one of the following.
> >
> >open(FP, ">\\test.txt")||print("Can't open file.");
> >open(FP, ">..\\test.txt")||print("Can't open file.");
>
> you should be including $! somewhere in your error output .. this
will
> tell you why you're unable to open these files (my guess is NT
> permissions on those directories .. but Perl will tell you)
>
> --
>   jason -- elephant@squirrelgroup.com --
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 18 Jul 2000 17:54:44 GMT
From: Vinod K. Menon <anuragmenon@my-deja.com>
Subject: Numerical evaluation in string
Message-Id: <8l25kp$2gp$1@nnrp1.deja.com>

Hey guys..

yet another question..how do I make a calculation inside a double
quoted string?

for example (I know the format is not right..just giving the idea!)

if I wanna do something like string = " 1/($keyVal/$len -1)) is the
answer"

I want it to evaluate to something like
and print

0.33 is the answer

how do I do that?

Thanks for all your help..once again!

Vinod.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 18 Jul 2000 16:25:14 GMT
From: lefkogt@my-deja.com
Subject: Perl and Sendmail???
Message-Id: <8l20cj$tuv$1@nnrp1.deja.com>

What is syntax for sending to multiple respondents using Sendmail and
Perl?

I tried this with no luck in my Perl CGI:
    print MAIL "To: $FORM{'supervisor'},$FORM{'peer'}\n";

Gary


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 18 Jul 2000 16:26:04 GMT
From: lefkogt@my-deja.com
Subject: Perl String????
Message-Id: <8l20e5$u0k$1@nnrp1.deja.com>

How do I extract (what function/procedure) the first character of a
string in Perl?


Gary


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 18 Jul 2000 17:47:17 +0100
From: "Cal Henderson" <cal@iamcal.com>
Subject: Re: Perl String????
Message-Id: <5S%c5.574$uY6.10670@news6-win.server.ntlworld.com>


<lefkogt@my-deja.com> wrote in...
:
: How do I extract (what function/procedure) the first character of a
: string in Perl?
:

You could use:

$foo = substr($foo,0,1);

but TMTOWTDI.

--
Cal Henderson

sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift@a,$a;}sub b{$c.=reverse
shift; while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);
shift@b;}}@b=(6,3,5,4,10,6,4,4,2,1);$a="l?jouipv"."ezvmxpbuxih";$a.=
",jofoqqibmzamsfsfxfjtuiIg";while($a ne ""){b(substr($a,0,2));$a=
substr($a,2);}print join(" ",@a);




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

Date: Tue, 18 Jul 2000 15:20:34 GMT
From: vgm32@my-deja.com
Subject: Re: Producing an executable for Perl program
Message-Id: <8l1sjd$qvl$1@nnrp1.deja.com>

In article <8l1mm6$lvu$1@nnrp1.deja.com>,
  sanjay33@my-deja.com wrote:
> Although I understand that Perl is an interpreted language, am I
correct
> in assuming that a Perl program is read into memory and converted into
> some intermediate form before it is executed. If this is true, then it
> should be possible to produce a executable file which runs the
program.
>
> Can anyone tell me how to produce this file?
>
> thanks
> sanjay
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

Anything I say will just be a repeat of
"How can I compile my Perl program into byte code or C?" in perlfaq3,
which can be accessed from http://www.perl.com/perl/faq/

--Victor


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 18 Jul 2000 16:27:18 +0100
From: "ARC" <tb97@usa.net>
Subject: regular expression help please !
Message-Id: <8l1suh$2v5$1@uranium.btinternet.com>


Hi,

I am currently picking up a field from a form on a web page and I need to
strip the field of everything except for numeric characters. I think there
is an expression to do this but I can't find it in my reference book !!
Could someone tell what the expression is !!

Thanks in advance

Adam.






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

Date: Tue, 18 Jul 2000 11:27:10 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: regular expression help please !
Message-Id: <3974774E.E8ED3A2C@attglobal.net>

ARC wrote:
> 
> Hi,
> 
> I am currently picking up a field from a form on a web page and I need to
> strip the field of everything except for numeric characters. I think there
> is an expression to do this but I can't find it in my reference book !!
> Could someone tell what the expression is !!
> 

What reference book are you using !!  Have you read the Perl 
regualr expression documentation !!  Its covered right in there
for you !!

$ perldoc perlre


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

Date: Tue, 18 Jul 2000 16:35:36 +0200
From: Ulrich Ackermann <UlleAckermann@t-online.de>
Subject: Re: regular expression help please !
Message-Id: <39746B38.8B6C5A5B@t-online.de>

ARC wrote:
> Could someone tell what the expression is !!

Could you give some more information about the data you are expecting?

You catch decimal numbers in a regex with \d plus quantifier (?, *, +,
{num}) and catch your match with brackets ().

perldoc perlre

Ulrich


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

Date: Tue, 18 Jul 2000 16:35:09 +0100
From: "mike solomon" <mike.solomon@eps.ltd.uk>
Subject: Re: regular expression help please !
Message-Id: <8l1tid$3j6gd$1@ID-36965.news.cis.dfn.de>

$foo =~ s/[^0-9]//g;

will do it

Regards

Mike Solomon


ARC <tb97@usa.net> wrote in message
news:8l1suh$2v5$1@uranium.btinternet.com...
>
> Hi,
>
> I am currently picking up a field from a form on a web page and I need to
> strip the field of everything except for numeric characters. I think there
> is an expression to do this but I can't find it in my reference book !!
> Could someone tell what the expression is !!
>
> Thanks in advance
>
> Adam.
>
>
>
>




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

Date: Tue, 18 Jul 2000 08:54:33 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: regular expression help please !
Message-Id: <MPG.13de1d928033078f98abdf@nntp.hpl.hp.com>

In article <3974774E.E8ED3A2C@attglobal.net>, care227@attglobal.net 
says...
> ARC wrote:

> > I am currently picking up a field from a form on a web page and I need to
> > strip the field of everything except for numeric characters. I think there
> > is an expression to do this but I can't find it in my reference book !!
> > Could someone tell what the expression is !!
> 
> What reference book are you using !!  Have you read the Perl 
> regualr expression documentation !!  Its covered right in there
> for you !!
> 
> $ perldoc perlre

Nevertheless, the best answer to the question has nothing to do with 
regular expressions (except the use of the binding operator).

    $string =~ tr/0-9//cd;

perldoc perlop

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 18 Jul 2000 11:16:46 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: regular expression help please !
Message-Id: <397482EE.CA963FFD@texas.net>

[Yet another Jeopardectomy performed]

mike solomon wrote:
> 
> ARC <tb97@usa.net> wrote in message
> news:8l1suh$2v5$1@uranium.btinternet.com...
> >
> > I am currently picking up a field from a form on a web page and I need to
> > strip the field of everything except for numeric characters.
> >
>
> $foo =~ s/[^0-9]//g;
> 
> will do it

But very inefficiently.  And '\D' is much nicer than a negated character
class.

The best solution is documented in the perlop page of the manual.

$foo =~ tr/0-9//cd;

- Tom


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

Date: Tue, 18 Jul 2000 08:07:13 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Renaming files trough Perl?
Message-Id: <MPG.13de1276d0b6e20b98abde@nntp.hpl.hp.com>

In article <F1Xc5.265$uY6.5238@news6-win.server.ntlworld.com>, 
cal@iamcal.com says...
> "Trond Aage Langtind" <trondage@langtind.no> wrote...
> :
> : How do I make a perl script that rename a file. I'm running UNIX.
> 
> rename "oldfile", "newfile";

Plus a suitable action or diagnostic (including $!) should the requested 
operation fail (return FALSE).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 18 Jul 2000 15:22:56 GMT
From: Bryan Shiffman <beshiffm@my-deja.com>
Subject: Re: Running a CGI script
Message-Id: <8l1snp$r11$1@nnrp1.deja.com>

Yup, this is definitely an Apache question.  I'll try to give you some
relevant info, but it's been a while since I screwed around with
Apache.  If this doesn't help, try an Apache newsgroup.

1. Check out .../apache/conf/httpd.conf.  There should be a line similar
to "<Directory "/usr/local/htdocs">" - after that, there is a list of
options.  Ensure that after Options comes the command ExecCGI (eg.
"Options Indexes FollowSymLinks ExecCGI").

That's all i can come up with.  AFter editing this file, restart httpd.
Check out the online docs which come with Apache (possibly in
/usr/local/apache/htdocs/manual/index.html).

Cheers,

Bryan

In article <39746155.90B5E7D7@watford53.freeserve.co.uk>,
  Jim Ford <jaford@watford53.freeserve.co.uk> wrote:
> I thought I'd have a play with CGI on my Linux box. I've downloaded
and
> installed the CGI.pm, but am unable to run the example scripts with
any
> browser (Netscape, Lynx etc.). All that happens is that I get the
source
> script displayed. I think it may be a configuration problem with
Apache,
> but don't know enough about Apache to risk fiddling with the (huge)
> config file. I'd also like to RTFM, but don't know what one I should
> look for!
>
> Any ideas - anyone, please.
>
> Regards: Jim Ford
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 18 Jul 2000 10:44:46 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: searching for a # within a range
Message-Id: <slrn8n8ure.u7.tadmc@maxim.metronet.com>

On Tue, 18 Jul 2000 06:41:38 GMT, padme67@my-deja.com 
   <padme67@my-deja.com> wrote:

>That said I am trying to do a search on a database that will determine
>if any value in the database falls into a user defined range.

>I can pattern match 


pattern matching is for *strings*.

numerical operators are for numbers.


>with words or phrases but finding a # in a range
>has me stumped.  If someone could just push me in the right direction I
>would be eternally grateful!

if ( ($val >150_000) && ($val < 200_000)) {
   print "'$val' is in range\n";
}


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 18 Jul 2000 17:42:35 +0100
From: nobull@mail.com
Subject: Re: searching for a # within a range
Message-Id: <u9n1jfpeys.fsf@wcl-l.bham.ac.uk>

padme67@my-deja.com.bbs@openbazaar.net () writes:

> I can pattern match with words or phrases but finding a # in a range
> has me stumped.  If someone could just push me in the right direction I
> would be eternally grateful!

The operators you are looking for are the numeric comparison ones and
the logic operators.  Do not attempt to use pattern matching for
things other than pattern matching.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 18 Jul 2000 16:11:00 +0100
From: "Cal Henderson" <cal@iamcal.com>
Subject: Re: Semi-newbie Regex question.
Message-Id: <Qr_c5.455$uY6.8668@news6-win.server.ntlworld.com>

"Jeff H" <jeffahill@lucent.com> wrote...
:
: What I'm trying to do should be very simple, but I can't seem to make it work.
: I want to read in a scalar string, see if there is a semicolon in it, and cut
: off everything from the semicolon, on.
:

How about:

$foo = (split(/;/$foo))[0];


--
Cal Henderson

sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift@a,$a;}sub b{$c.=reverse
shift; while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);
shift@b;}}@b=(6,3,5,4,10,6,4,4,2,1);$a="l?jouipv"."ezvmxpbuxih";$a.=
",jofoqqibmzamsfsfxfjtuiIg";while($a ne ""){b(substr($a,0,2));$a=
substr($a,2);}print join(" ",@a);




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

Date: Tue, 18 Jul 2000 16:03:12 GMT
From: Michael Sanders <michaels@my-deja.com>
Subject: Socket closure problem with AS Perl 616
Message-Id: <8l1v3i$svt$1@nnrp1.deja.com>

The code below works fine with 5.005_03 on Linux and with ActiveState
5.6.0 build 613 on NT, but fails on build 616 with the error "Bad file
descriptor at test.pl line 6", which is where an attempt is made to
close the socket.

use IO::Socket;
my $self = IO::Socket::INET->new( Proto => "tcp",
                                  PeerAddr => "www.activestate.com",
                                  PeerPort => "80" );

close $self || die $!;

Any ideas why? Is this the correct way to close a socket? Presumably it
*is* necessary to close a socket (or else the script could eventually
use up all OS file-handles)?

Thanks,
Michael Sanders


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 18 Jul 2000 12:15:56 -0400
From: Young <no_email@no_email.com>
Subject: Sorting multidimensional arrays
Message-Id: <397482BC.1FB0D37A@nortelnetworks.com>

Hi,

Can you tell me how to sort a multidimensional array?

I have an array @rows, with $rows[$i][0] being a number, and
$rows[$i][1] being the string I want to sort by (ascending).

How do I do this?

Please cc my e-mail address (yfan1@nortelnetworks.com). Thanks in
advance.



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

Date: Tue, 18 Jul 2000 09:35:59 -0800
From: kenned57@NoSpam.edu (Cameron Kennedy)
Subject: Re: Sorting multidimensional arrays
Message-Id: <kenned57-1807000936000001@alexthinkpad.salk.edu>

In article <397482BC.1FB0D37A@nortelnetworks.com>, Young
<no_email@no_email.com> wrote:

> Hi,
> 
> Can you tell me how to sort a multidimensional array?
> 
> I have an array @rows, with $rows[$i][0] being a number, and
> $rows[$i][1] being the string I want to sort by (ascending).
> 

@sorted=sort { $a->[1] cmp $b->[1]}@rows;

Cameron


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

Date: 18 Jul 2000 17:40:48 +0100
From: nobull@mail.com
Subject: Re: SSL programs
Message-Id: <u9r98rpf1r.fsf@wcl-l.bham.ac.uk>

"Tambaa Hapa" <tambaah@xhotmailx.com> writes:

> Anyone know of a site with good examples in perl for retrieving SSL pages
> and submitting SSL forms?

You mean HTTPS not SSL.

Appart from the "s" in the URLs these examples would be the same as
the HTTP examples.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 18 Jul 2000 15:03:58 GMT
From: Benjamin David Garrison <gte941n@prism.gatech.edu>
Subject: Re: This software is worth to try....
Message-Id: <8l1rku$n89$2@news-int.gatech.edu>

sdf@sdf.com wrote:
<spam>

and...how is this related to perl, mon ami?

-- 
Ben Garrison * ICQ#20300203 * IM ben628496 * www.ben.f2s.com
 Seen on a red license plate: "If this is blue, you're going too fast."


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

Date: Tue, 18 Jul 2000 17:46:13 GMT
From: newsvan33@hotmail.com
Subject: Truly Orthogonal Persistence
Message-Id: <8l254t$23d$1@nnrp1.deja.com>

There's been a lot of talk about "orthogonal persistence" in the past
couple of years-- being able to store classes in a database or file
without writing any special code for object storage.  This would
be especially useful if the objects you used contained references
to other objects that were defined by different programmers in
different modules.

The tangram module touts itself as such a solution for SQL databases.
However, because SQL data is typed (numerical, time/date, text, BLOB,
etc), the data from an object cannot be efficiently stored in an
SQL table without a schema to tell what kind of data it is.
This can be important when large amounts of data are present.
However, I would argue that it is not truly orthogonal--  You
don't need special methods but you do need to code schema.
It would be more accurate to say that it is as orthogonal
as humanly possible given the restrictions imposed by an SQL database.
(Actually I have suggested a way to make tangram more flexible
to the author, but nevermind that.)

I've noticed the common object serialization schemes are not truly
orthogonal either:  for instance when I try to serialize CPAN objects
like DBI or CGI.pm handles using FreezeThaw or Data::Dumper,
and then thaw them out, bad things happen.  (It does seem
to work fine for my own objects that I define, however.)  Some sample
code demonstrating this is appended to the end of this article.

I don't really know much perl (my forte is C++ and other languages),
but it seems to me that truly orthogonal persistance should be
implementable.  Here's my basic idea:

MyTie($ScalarYouWantToBeARef, $ClassYouWantTheScalarToBeaRefTo)?

My Tie would actually make the scalar a ref to its own
class which would contain a unique ID and a pointer.
The unique ID would help you look the guy up later.
The pointer would just be a reference to an object
that was created by calling ClassYouWant::new()).
At serialization, the pointer could be recursively
followed down to the its contents, whether it was
a hash, an array, an ordinary reference, or some kind of blessed
reference, all of the typing information and
data could be recursively coded up in a nested serialization.  Then
this serialization could be saved
and unraveled recursively when needed.  The unique
ID would be used for lookup.  This may not be terribly
efficient from an algorithmic standpoint but it seems
to me that it is closer to a truly orthagonal solution
than what has been implemented--  You wouldn't
have to create schema for your own objects, or
the objects pointed to by your classes, some of
which may have been defined by other programmers
in other modules.  Algorithmic optomization could be implemented below
the line later.  Since I'm not really a perl expert--  Is there
something naive about what I'm proposing that I've overlooked?


Bredan Gormley
bdgormley@hotmail.com


Appendix:
-----------------------------------------------------------------------
Here's a little experiment in freezing a DBI connection with
Data::Dumper (no practical application whatsoever):


$first_dbi_connection_string= Dumper( $First_DBI_Connection);
$Second_DBI_Connection= eval ($first_dbi_connection_string);
$second_dbi_connection_string= Dumper($Second_DBI_Connection);

$first_dbi_connection_string and $second_dbi_connection_string have the
same value:

$VAR1 = bless( {}, 'DBI::db' );

However, if I try to invoke methods on $Second_DBI_Connection, such as

$SecondSTH= $Second_DBI_Connection->prepare("Select * from MedCookies");
$SecondRV= $SecondSTH->execute();
I get the message:

dbih_getcom handle 'DBI::db=HASH(0x81caea0)' is not a DBI handle (has
no magic)
at test.cgi
-----------------------------------------------------------------------
Well, you see, it didn't work.  I have similiar problems with
FreezeThaw, and it doesn't matter whether I use DBI handles
or CGI.pm handles either.  These serialization schemes just
don't cut it.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 18 Jul 2000 15:22:20 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: Unflattening a multi-dimensional array
Message-Id: <8l1sbj$494$1@localhost.localdomain>

In article <slrn8n7rcs.v90.abigail@alexandra.delanet.com>,
Abigail <abigail@delanet.com> wrote:
>
>my    @dim  =               split " " => <INP>;
>my    @data = do {local $/; split " " => <INP>};
>
>my    $code = $multi = shift @data;';
>map  {$code =~ s/\$multi/\$multi [\$x$_]/;
>      $code = "for my \$x$_ (0 .. $dim[$_] - 1) {$code}";}
>       reverse 0 .. $#dim;
>eval  $code;
>
>
>Golf, anyone?

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

use Data::Dumper;

my @m=split" ",<DATA>;
my @d=do{local $/;split" ",<DATA>};
my @r;

# this is just the recursive solution, slightly simplified...
# all in one map.

while(@d){push@r,k(@m)}
sub k{map{@_?[k(@_)]:shift@d}1..shift} 

print Dumper (@r);

__DATA__
2 2 7 
a b c d e f g h i j k l m n o p q r s t u v w x y z


-- 
Neil Kandalgaonkar <neil@brevity.org>


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

Date: 18 Jul 2000 15:06:47 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: why does this not work?
Message-Id: <slrn8n8sk7.vkn.M.Ray@carlova.ulcc.ac.uk>

On 18 Jul 2000 14:55:40 GMT, Benjamin David Garrison <gte941n@prism.gatech.edu>
wrote:
>($current_month, $current_day, $current_year)=split(/-/, `date 
>"+%m-%d-%Y"`);
>$current_year=chomp $current_year;

perldoc -f chomp

will tell you what value chomp() returns: it's not what you think.  By the
way, that's a fairly unpleasant and non-portable way to get the current
date.  See 'perldoc -f localtime' and 'perldoc POSIX', paying attention to
strftime().
-- 
Malcolm Ray                           University of London Computer Centre


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

Date: Tue, 18 Jul 2000 16:12:20 +0100
From: "mike solomon" <mike.solomon@eps.ltd.uk>
Subject: Re: why does this not work?
Message-Id: <8l1s7j$3d3q7$1@ID-36965.news.cis.dfn.de>

try

($current_month, $current_day, $current_year)=split(/-/, `date
"+%m-%d-%Y"`);
chomp($current_year);

to avoid using `date` look at perldoc -f localtime


regards

mike Solomon







Benjamin David Garrison <gte941n@prism.gatech.edu> wrote in message
news:8l1r5c$n76$1@news-int.gatech.edu...
> ($current_month, $current_day, $current_year)=split(/-/, `date
> "+%m-%d-%Y"`);
> $current_year=chomp $current_year;
>
> --
> Ben Garrison * ICQ#20300203 * IM ben628496 * www.ben.f2s.com
>  "My God" - single log entry of the pilot of the Enola Gay on the day
>  that the bomb was dropped on Hiroshima, Japan.




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

Date: 18 Jul 2000 15:19:41 GMT
From: Benjamin David Garrison <gte941n@prism.gatech.edu>
Subject: Re: why does this not work?
Message-Id: <8l1sid$nac$1@news-int.gatech.edu>

mike solomon <mike.solomon@eps.ltd.uk> wrote:
> chomp($current_year);

that's what I was thinking...(I used that first)

syntax error in file ./dat at line 9, next 2 tokens "chomp("
Execution of ./dat aborted due to compilation errors.

-- 
Ben Garrison * ICQ#20300203 * IM ben628496 * www.ben.f2s.com
 "Witty quotes mean nothing" - Voltaire


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

Date: 18 Jul 2000 15:41:33 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: why does this not work?
Message-Id: <8l1trd$2be$1@pegasus.csx.cam.ac.uk>

Benjamin David Garrison  <gte941n@prism.gatech.edu> wrote:
>mike solomon <mike.solomon@eps.ltd.uk> wrote:
>> chomp($current_year);
>
>that's what I was thinking...(I used that first)
>
>syntax error in file ./dat at line 9, next 2 tokens "chomp("
>Execution of ./dat aborted due to compilation errors.

That's perl4.   Upgrade.


Mike Guy


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

Date: Tue, 18 Jul 2000 15:54:58 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: why does this not work?
Message-Id: <7asnt7igbx.fsf@merlin.hyperchip.com>


mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:

> Benjamin David Garrison  <gte941n@prism.gatech.edu> wrote:
> >mike solomon <mike.solomon@eps.ltd.uk> wrote:
> >> chomp($current_year);
> >
> >that's what I was thinking...(I used that first)
> >
> >syntax error in file ./dat at line 9, next 2 tokens "chomp("
> >Execution of ./dat aborted due to compilation errors.
> 
> That's perl4.   Upgrade.

I don't think so. Perl4 will give you:

	Unquoted string "chomp" may clash with future reserved word ..

I suspect there is a missing semicolon at the end of the line before the
chomp()?

--Ala



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

Date: 18 Jul 2000 15:58:29 GMT
From: Benjamin David Garrison <gte941n@prism.gatech.edu>
Subject: Re: why does this not work?
Message-Id: <8l1ur5$nkt$3@news-int.gatech.edu>

M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
> That's perl4.   Upgrade.

*light goes on*


ah...I didn't think of that.  Actually, upgrading is impossible...I'm
working with a sqerl variant that's designed to work with csds, so I'll
have to make do.

I just used chop, and it worked.  thanks for the tip.

-- 
Ben Garrison * ICQ#20300203 * IM ben628496 * www.ben.f2s.com
 "I'm not weird...everyone else is weird, and I'm normal."


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

Date: 18 Jul 2000 16:13:18 GMT
From: Benjamin David Garrison <gte941n@prism.gatech.edu>
Subject: Re: why does this not work?
Message-Id: <8l1vmu$nkt$5@news-int.gatech.edu>

Ala Qumsieh <aqumsieh@hyperchip.com> wrote:
> I don't think so. Perl4 will give you:

> 	Unquoted string "chomp" may clash with future reserved word ..

> I suspect there is a missing semicolon at the end of the line before the
> chomp()?

nope, what he said.  I should have mentioned that I was using a hybred
version.

-- 
Ben Garrison * ICQ#20300203 * IM ben628496 * www.ben.f2s.com
 >man woman
 No manual entry for woman


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

Date: Tue, 18 Jul 2000 10:48:40 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: why does this not work?
Message-Id: <slrn8n8v2o.u7.tadmc@maxim.metronet.com>

On 18 Jul 2000 15:19:41 GMT, Benjamin David Garrison 
   <gte941n@prism.gatech.edu> wrote:
>mike solomon <mike.solomon@eps.ltd.uk> wrote:
>> chomp($current_year);
>
>that's what I was thinking...(I used that first)
>
>syntax error in file ./dat at line 9, next 2 tokens "chomp("
>Execution of ./dat aborted due to compilation errors.


Get rid of Perl 4.

It is dead. It does not exist. It is a non-Perl.

It was superceded about *5 years* ago!!

It has large security holes and lots of unfixed bugs.

Upgrade.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 18 Jul 2000 16:35:56 GMT
From: Benjamin David Garrison <gte941n@prism.gatech.edu>
Subject: Re: why does this not work?
Message-Id: <8l211c$o65$1@news-int.gatech.edu>

Tad McClellan <tadmc@metronet.com> wrote:
> Get rid of Perl 4.

read the rest of the thread.  =)

> It is dead. It does not exist. It is a non-Perl.

duh.

> It was superceded about *5 years* ago!!

duh.

> It has large security holes and lots of unfixed bugs.

duh.

> Upgrade.

I can't, darn it!  =)

-- 
Ben Garrison * ICQ#20300203 * IM ben628496 * www.ben.f2s.com
 "My God" - single log entry of the pilot of the Enola Gay on the day
 that the bomb was dropped on Hiroshima, Japan.


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

Date: Tue, 18 Jul 2000 17:43:03 GMT
From: Vinod K. Menon <anuragmenon@my-deja.com>
Subject: Re: Yet another string manipulation question -
Message-Id: <8l24v1$208$1@nnrp1.deja.com>

The whole rule system is working perfectly except for one rule that I
am not sure how to write up..

v can be followed ONLY by a
if any other character follows v, then an X has to be inserted between
v and that character.
How do I do that?

adding v => 'a' into the %rules hash is not working right..

Thanks for all your help again..
Vinod.


In article <397d6026.50089106@news.newsguy.com>,
  kcivey@cpcug.org (Keith Calvert Ivey) wrote:
> elephant@squirrelgroup.com (jason) wrote:
>
> >  my %rules = ( a => 'be', c => 'd', e => 'kl' );
> >  my $char = 'X';
> >
> >  for my $key (keys %rules)
> >  {
> >    $String1 =~ s/$key([^$rules{$key}])/$key$char$1/g;
> >  }
>
> Consider what happens if $String1 is 'aacd'.  The second 'a'
> gets captured and ignored while the first 'a' is being
> processed, and you get 'aXacd' instead of 'aXaXcd'.  Change the
> substitution line to
>
>     $String1 =~ s/$key(?=[^$rules{$key}])/$key$char/g;
>
> --
> Keith C. Ivey <kcivey@cpcug.org>
> Washington, DC
> (Free at last from the forced spamsig of
> Newsfeeds.com, cursed be their name)
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3736
**************************************


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