[31848] in Perl-Users-Digest
Perl-Users Digest, Issue: 3111 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 2 18:09:24 2010
Date: Thu, 2 Sep 2010 15:09:06 -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, 2 Sep 2010 Volume: 11 Number: 3111
Today's topics:
Re: Multidimensional array <jurgenex@hotmail.com>
Re: Multidimensional array <paul@pstech-inc.com>
Re: Multidimensional array <jurgenex@hotmail.com>
Re: Multidimensional array <cartercc@gmail.com>
Re: Multidimensional array <sherm.pendley@gmail.com>
Re: Multidimensional array <cartercc@gmail.com>
Re: Multidimensional array <sherm.pendley@gmail.com>
Re: Multidimensional array <ben@morrow.me.uk>
Re: Multidimensional array <sherm.pendley@gmail.com>
Re: Multidimensional array <ben@morrow.me.uk>
Re: Multidimensional array <paul@pstech-inc.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 01 Sep 2010 19:10:43 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Multidimensional array
Message-Id: <1o1u76pe4kenp24vdcdrh3jvrq969cql72@4ax.com>
"Paul E. Schoen" <paul@pstech-inc.com> wrote:
>I am working on a Windows Vista machine and Perl is installed on the server.
>I use Telnet to access my web space, assign permissions, run test scripts,
>and sometimes I even use the pico editor. But I'm using PerlEdit locally to
>edit the scripts and HTML/JavaScript files, and I use NCH Classic FTP for
>uploads. It's handy to have the docs available off-line.
It is even handier to have a Perl installation available off-line.
Actually, coming to think of it, it is quite stupid to do any
development work on a live web server.
jue
------------------------------
Date: Wed, 1 Sep 2010 22:53:46 -0400
From: "Paul E. Schoen" <paul@pstech-inc.com>
Subject: Re: Multidimensional array
Message-Id: <3lEfo.164232$1F6.2430@newsfe01.iad>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:1o1u76pe4kenp24vdcdrh3jvrq969cql72@4ax.com...
> "Paul E. Schoen" <paul@pstech-inc.com> wrote:
>>I am working on a Windows Vista machine and Perl is installed on the
>>server.
>>I use Telnet to access my web space, assign permissions, run test scripts,
>>and sometimes I even use the pico editor. But I'm using PerlEdit locally
>>to
>>edit the scripts and HTML/JavaScript files, and I use NCH Classic FTP for
>>uploads. It's handy to have the docs available off-line.
>
> It is even handier to have a Perl installation available off-line.
> Actually, coming to think of it, it is quite stupid to do any
> development work on a live web server.
I used the ActivePerl installation as suggested by Sherm and it works well.
However, I can't seem to get the proper URL to the Perl script on my local
machine to be used by the HTML event submission form.
And I also need to add the path to the C:\Perl\bin folder. I can do it from
the command line by using:
set path=%path%;C:\Perl\bin
but it is only temporary.
I agree that the local machine is the place to do the development work.
The project is coming along pretty well now. Thanks for the help!
Paul
------------------------------
Date: Wed, 01 Sep 2010 20:16:19 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Multidimensional array
Message-Id: <3h5u76h2b83i0rco063j3165mpehva2k7t@4ax.com>
"Paul E. Schoen" <paul@pstech-inc.com> wrote:
>
>"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
>news:1o1u76pe4kenp24vdcdrh3jvrq969cql72@4ax.com...
>> "Paul E. Schoen" <paul@pstech-inc.com> wrote:
>>>I am working on a Windows Vista machine and Perl is installed on the
>>>server.
>>>I use Telnet to access my web space, assign permissions, run test scripts,
>>>and sometimes I even use the pico editor. But I'm using PerlEdit locally
>>>to
>>>edit the scripts and HTML/JavaScript files, and I use NCH Classic FTP for
>>>uploads. It's handy to have the docs available off-line.
>>
>> It is even handier to have a Perl installation available off-line.
>> Actually, coming to think of it, it is quite stupid to do any
>> development work on a live web server.
>
>I used the ActivePerl installation as suggested by Sherm and it works well.
>However, I can't seem to get the proper URL to the Perl script on my local
>machine to be used by the HTML event submission form.
That depends on how you configurated your web server.
>And I also need to add the path to the C:\Perl\bin folder. I can do it from
>the command line by using:
>
> set path=%path%;C:\Perl\bin
>
>but it is only temporary.
Start menu -> right-click on "Computer" -> Properties -> Advanced System
Settings -> Environment Variables
But normally ActiveState will add the directory to your path
automatically upon installation.
jue
------------------------------
Date: Thu, 2 Sep 2010 07:12:10 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Multidimensional array
Message-Id: <704181e3-d76c-449c-9446-6500b7518a64@u6g2000yqh.googlegroups.com>
On Sep 1, 10:10=A0pm, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> It is even handier to have a Perl installation available off-line.
Yes.
> Actually, coming to think of it, it is quite stupid to do any
> development work on a live web server.
This depends. I do most of my work on servers, to which I connect with
a terminal emulator, or in the case of Windows with a remote desktop.
Some of these servers run httpd servers, along with other kinds of
servers such as database servers ftp servers, email servers, file
servers, and so on. If you develop on remote machines, you often don't
have any control on what servers run on those machines, and the fact
that a web server is running on a particular remote machine really
doesn't impact your development environment.
Too, you can develop applications on test servers not connected to the
internet, but accessible internally via TCP/IP, with the express
intention of developing on a 'live' web server. In fact, testing on a
'live' web server is mandatory!
This doesn't even include considerations such as developing of virtual
machines.
I agree that it probably isn't best to develop 'live' in the sense
that your in process code is available live over a WWW connection, but
this isn't the same as developing on a 'live' web server.
CC.
------------------------------
Date: Thu, 02 Sep 2010 11:02:31 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Multidimensional array
Message-Id: <m2hbi8qjco.fsf@sherm.shermpendley.com>
ccc31807 <cartercc@gmail.com> writes:
> Too, you can develop applications on test servers not connected to the
> internet, but accessible internally via TCP/IP, with the express
> intention of developing on a 'live' web server. In fact, testing on a
> 'live' web server is mandatory!
Once again, you're assigning new meaning to terms that disagree with
the meaning used by the rest of us, and then trying to argue that it's
everyone else's meaning that is wrong. Please stop doing that.
A "live" server is what is also called a "production" or "deployment"
server. The fact that your "staging," "development," or "test" servers
happen to run httpd and are accessible via TCP/IP does not imply that
they are "live" - that's not what the word means in this context.
sherm--
--
Sherm Pendley
<http://camelbones.sourceforge.net>
Cocoa Developer
------------------------------
Date: Thu, 2 Sep 2010 08:49:44 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Multidimensional array
Message-Id: <cdf9e03a-a0cc-46a0-8307-cc0d60e4045b@k10g2000yqa.googlegroups.com>
On Sep 2, 11:02=A0am, Sherm Pendley <sherm.pend...@gmail.com> wrote:
> Once again, you're assigning new meaning to terms that disagree with
> the meaning used by the rest of us, and then trying to argue that it's
> everyone else's meaning that is wrong. Please stop doing that.
Not so, I merely take words in their literal meaning unless they are
obviously meant to be taken non literally. JUE said,
>> Actually, coming to think of it, it is quite stupid to do
>> any development work on a live web server.
I take two things from this: (1) the use of the term 'any development
work' isn't limited to web apps, and it's common in my experience to
develop data munging apps on a machine that also happens to be running
a 'live' web server (unless you are in a Windows environment where you
use one piece of hardware for one software server), and (2) it's also
common in my experience to develop web apps outside the document root,
test them, and then copy them to the document root (or configure
Apache to serve them). I've contracted out three jobs in the past
year, all on remote servers, and in each case the machine I was hired
to work on was running a 'live' web server, and I never felt that it
was stupid to work on the same machine -- but in none of the cases was
I actually working on a live web site but ancillary applications.
> A "live" server is what is also called a "production" or "deployment"
> server. The fact that your "staging," "development," or "test" servers
> happen to run httpd and are accessible via TCP/IP does not imply that
> they are "live" - that's not what the word means in this context.
But he didn't say, "it is quite stupid to do web development work on a
production or deployment web server." If he had meant to say that, I'm
sure he would. That's what you understood him to say, but it's not
what he actually said. It seems to be that you have made some
assumptions that weren't explicity stated in JUE's statement and are
taking me to task because I don't share your assumptions.
Besides, I also said,
>> I agree that it probably isn't best to develop 'live'
>> in the sense that your in process code is available
>> live over a WWW connection, but this isn't the same
>> as developing on a 'live' web server.
which makes clear the meaning that you have untested and in-process
code in your document root for all to see. (We all do stupid things,
and I confess that I have been guilty of developing web apps on live
production servers fully connected to the internet, but only when told
to do so by a client who gave these instructions.)
CC.
------------------------------
Date: Thu, 02 Sep 2010 12:15:03 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Multidimensional array
Message-Id: <m2d3swqfzs.fsf@sherm.shermpendley.com>
ccc31807 <cartercc@gmail.com> writes:
> On Sep 2, 11:02Â am, Sherm Pendley <sherm.pend...@gmail.com> wrote:
>> Once again, you're assigning new meaning to terms that disagree with
>> the meaning used by the rest of us, and then trying to argue that it's
>> everyone else's meaning that is wrong. Please stop doing that.
>
> Not so, I merely take words in their literal meaning
Sigh. And, once again, you're trying to avoid admitting your mistake.
Grow up.
sherm--
--
Sherm Pendley
<http://camelbones.sourceforge.net>
Cocoa Developer
------------------------------
Date: Thu, 2 Sep 2010 17:51:50 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Multidimensional array
Message-Id: <6a15l7-4jt1.ln1@osiris.mauzo.dyndns.org>
Quoth Sherm Pendley <sherm.pendley@gmail.com>:
> ccc31807 <cartercc@gmail.com> writes:
>
> Sigh. And, once again, you're trying to avoid admitting your mistake.
>
> Grow up.
+-------------------+ .:\:\:/:/:.
| PLEASE DO NOT | :.:\:\:/:/:.:
| FEED THE TROLLS | :=.' - - '.=:
| | '=(\ 9 9 /)='
| Thank you, | ( (_) )
| Management | /`-vvv-'\
+-------------------+ / \
| | @@@ / /|,,,,,|\ \
| | @@@ /_// /^\ \\_\
@x@@x@ | | |/ WW( ( ) )WW
\||||/ | | \| __\,,\ /,,/__
\||/ | | | (______Y______)
/\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
==================================================================
Ben
------------------------------
Date: Thu, 02 Sep 2010 14:12:49 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Multidimensional array
Message-Id: <m28w3kqaji.fsf@sherm.shermpendley.com>
Ben Morrow <ben@morrow.me.uk> writes:
> Quoth Sherm Pendley <sherm.pendley@gmail.com>:
>> ccc31807 <cartercc@gmail.com> writes:
>>
>> Sigh. And, once again, you're trying to avoid admitting your mistake.
>>
>> Grow up.
>
> +-------------------+ .:\:\:/:/:.
> | PLEASE DO NOT | :.:\:\:/:/:.:
> | FEED THE TROLLS | :=.' - - '.=:
> | | '=(\ 9 9 /)='
> | Thank you, | ( (_) )
> | Management | /`-vvv-'\
> +-------------------+ / \
> | | @@@ / /|,,,,,|\ \
> | | @@@ /_// /^\ \\_\
> @x@@x@ | | |/ WW( ( ) )WW
> \||||/ | | \| __\,,\ /,,/__
> \||/ | | | (______Y______)
> /\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
> ==================================================================
Good advice, but I haven't written off ccc as a troll yet. Stubborn
and resistant to learning, yes - but not intentionally picking fights.
Call it the triumph of hope over experience... :-)
sherm--
--
Sherm Pendley
<http://camelbones.sourceforge.net>
Cocoa Developer
------------------------------
Date: Thu, 2 Sep 2010 19:22:04 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Multidimensional array
Message-Id: <cj65l7-sju1.ln1@osiris.mauzo.dyndns.org>
Quoth Sherm Pendley <sherm.pendley@gmail.com>:
>
> Good advice, but I haven't written off ccc as a troll yet. Stubborn
> and resistant to learning, yes - but not intentionally picking fights.
'Resistant to learning' is the important point here. I don't think
continually correcting him has any chance of improving the S/N ration of
the group.
Ben
------------------------------
Date: Thu, 2 Sep 2010 17:58:44 -0400
From: "Paul E. Schoen" <paul@pstech-inc.com>
Subject: Re: Multidimensional array
Message-Id: <t6Vfo.38787$yr6.11585@newsfe05.iad>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:3h5u76h2b83i0rco063j3165mpehva2k7t@4ax.com...
> "Paul E. Schoen" <paul@pstech-inc.com> wrote:
>>I used the ActivePerl installation as suggested by Sherm and it works
>>well.
>>However, I can't seem to get the proper URL to the Perl script on my local
>>machine to be used by the HTML event submission form.
>
> That depends on how you configurated your web server.
I have a localhost web server that was installed by DotCMS. But it only
displays the default home page and items linked to it. There is a place for
"Vanity URLs" that supposedly redirect an arbitrary URL to another location,
but I can't seem to get that to work. I think it needs to redirect to the
files in the local website, rather than other files on the local machine
hard drive. The files in the DotCMS directory are very confusing and I can't
find folder names that work in a URL, such as http://localhost/news-events.
The only place news-events appears is deep into a path:
C:\dotcms\dotcms\dotsecure\dotcache\livecache.fdb\9\0\7\2\livecache48190c8c-42c4-46af-8d1a-0cd5db894797_colon__forward_news-events_forward_.fdb
Maybe I should uninstall the DotCMS host and install an Apache server?
>>And I also need to add the path to the C:\Perl\bin folder. I can do it
>>from
>>the command line by using:
>>
>> set path=%path%;C:\Perl\bin
>>
>>but it is only temporary.
>
> Start menu -> right-click on "Computer" -> Properties -> Advanced System
> Settings -> Environment Variables
>
> But normally ActiveState will add the directory to your path
> automatically upon installation.
I may have missed that checkbox when I installed it. Thanks for the clue.
Now I can run Perl from the command line anywhere.
I'm stuck once again. I want to be able to store a hash of events sorted by
Date (or perhaps DateTime) in a text file, and read back into the hash where
I can add new events or delete old ones. The hash is defines as:
my %Event_DB = (
$E_Date => {
Date => $E_Date, #This was previously an array
Time => $E_Time,
Title => $E_Title,
Descr => $E_Descr,
},
);
I am storing the data received from the HTML form as follows:
my $filename = "events.txt";
#*** Can't create file in cgi-bin; must create empty file and chmod 777
#unless (-e $filename) { #check for exist
open (EventFile, '>>', $filename)
or HTMLdie ("File write error: $!");
for my $event (map $Event_DB{$_}, sort keys %Event_DB) {
print (EventFile $event->{Title});
print (EventFile $event->{Date});
print (EventFile $event->{Time});
print (EventFile $event->{Descr});
}
close (EventFile);
# }
This seems to work, although there are no field or record separators. The
Descr record may contain newlines, so I may need to use other characters for
separators.
I am reading the stored Events like this (which must be wrong);
# Read the existing text file of events
open (EventFile, '<', $filename)
or HTMLdie ("File read error: $!");
my $Event_DB = <EventFile>;
close (EventFile);
I am writing to the HTML file as follows:
# Print to the HTML file (write, append, create)
open (DATA1, '>', "output.htm")
or HTMLdie ("File error: $!");
print DATA1 <<EOF ;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>iframe - Events - Greater Baltimore Group Sierra Club Web
Site</title>
</head>
<body>
<h1>Events</h1><hr>
EOF
foreach my $key (sort keys %Event_DB) {
print DATA1 "<p><h3>$Event_DB{$key}->{Title}</h3>";
print DATA1 "<h4>Date: $Event_DB{$key}->{Date} Time:
$Event_DB{$key}->{Time}</h4>";
print DATA1 "$Event_DB{$key}->{Descr}</p><hr>";
}
print DATA1 <<EOF ;
</body>
</html>
EOF
close (DATA1);
I think my main problem is the saving and reading of the events.txt file.
The here-doc and the print loop print the fields of the last record, but
there is only one execution of the loop.
Surely something like this has been done before, but I don't know how to
find a well-written Perl script for this. I found this, which uses a
database file, and may be the best option:
http://docstore.mik.ua/orelly/perl/cookbook/ch11_15.htm
use MLDBM qw(DB_File);
use Fcntl;
tie(%hash, 'MLDBM', 'testfile.db', O_CREAT|O_RDWR, 0666)
or die "can't open tie to testfile.db: $!";
# ... act on %hash
# this doesn't work!
$hash{"some key"}[4] = "fred";
# RIGHT
$aref = $hash{"some key"};
$aref->[4] = "fred";
$hash{"some key"} = $aref;
untie %hash;
I think I'll try that, but I'd appreciate a few more tips on how to do what
I need in the "best" way.
Thanks muchly,
Paul
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 3111
***************************************