[27031] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8949 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 14 00:05:46 2006

Date: Mon, 13 Feb 2006 21:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 13 Feb 2006     Volume: 10 Number: 8949

Today's topics:
    Re: Absolute Novice (Mac Tiger) Needs Help <ben.usenet@bsb.me.uk>
        Arrays <FJRussonc@earthlink.net>
    Re: Arrays <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: Arrays <someone@example.com>
    Re: Perl vs. Python <bart.lateur@pandora.be>
        Why can't JavaScript work when embeded in Perl CGI code <david@nospam.com>
    Re: Why can't JavaScript work when embeded in Perl CGI  (Rick Scott)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 14 Feb 2006 00:28:29 +0000
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: Absolute Novice (Mac Tiger) Needs Help
Message-Id: <pan.2006.02.14.00.28.29.375646@bsb.me.uk>

On Sun, 12 Feb 2006 19:48:56 +0000, James Taylor wrote:

> Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
> 
>> I don't want to argue this point too strongly, but, as an example of
>> what I was thinking about when I said it is a hard problem, how would a
>> CGI program generate (portably) \r\n line endings for HTTP if \n is
>> mapped in the IO subsystem?
> 
> Because you'd have a trait/property on the socket file handle explicitly
> saying that \r\n was the newline sequence for this channel.
> 
>> I don't want to press this point -- I can see a solution as can you, no
>> doubt.  I only wanted to defend my position that the "line end" problem
>> is not as trivial as "map \n when doing IO".
> 
> Isn't it? Surely every file handle can have a different newline property,
> and if necessary these could be changeable at runtime.

Of course, but I quoted the example of a CGI script because these write
to stdout -- an existing pre-opened stream.  Users on a system that has a
line termination different to \n would want the translation on by default
on stdout, but they would not want it on for CGI scripts.  Someone will
get a surprise no matter which default you pick.  That is all I meant by
it not being a trivial problem.

A reasonably surprise-free solution could have come from copying the
DOS/Windows trick.  There, the \n translation happened only if the
preceeding character was not a \r.  This makes examples like the one I
gave "just work" and relatively surprise-free behaviour for most other
programs.  Logically it should also work in reverse (for input) but that
is always harder...  The DOS/Windows Perl port certainly did not try to do
that.

>> I hope this has helped rather than hindered the debate!
> 
> Sure! And just in case it wasn't clear, I agree with *nearly* everything
> you've said. ;-)

And I now think I agree with you (given a-non trivial interpretation of
"map \n in the IO system") ;-)

-- 
Ben.



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

Date: Tue, 14 Feb 2006 03:43:01 GMT
From: "Frank J. Russo" <FJRussonc@earthlink.net>
Subject: Arrays
Message-Id: <9lcIf.15246$rH5.2635@newsread2.news.atl.earthlink.net>

? Does Perl handle multilevel (dimension) arrays?  I am assuming it does.

I am attempting to improve the way data from my program is stored and 
recovered.

If I was working in any other language I would define an array e.g. 
Calendar(12,5,1).

The data I have is 12 months (Jan - Dec) each month can have 4 or 5 dates 
attached and each date has a single note (string).

How would you organize or define this?

Frank 




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

Date: Mon, 13 Feb 2006 20:04:39 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Arrays
Message-Id: <g718c3x8ps.ln2@goaway.wombat.san-francisco.ca.us>

On 2006-02-14, Frank J. Russo <FJRussonc@earthlink.net> wrote:
> ? Does Perl handle multilevel (dimension) arrays?  I am assuming it does.

Yes.  You need references.

> The data I have is 12 months (Jan - Dec) each month can have 4 or 5 dates 
> attached and each date has a single note (string).

One way to do it, using only arrayrefs:

my $events=[];
$events->[0][12]='An event on January 12 (using 0-based array for month)';
$events->[0][22]='An event on January 22 (using 0-based array for month)';
$events->[2][2]='An event on March 2 (using 0-based array for month)';

Another way, using hashrefs:

my $events={};
$events->{'Jan'}[12]='An event using a hashref instead of an arrayref';

As always with Perl, TIMTOWTDI.  Read perldoc perlreftut, perldoc
perldsc, and perldoc perlref for more details.

--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
see X- headers for PGP signature information



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

Date: Tue, 14 Feb 2006 04:37:05 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Arrays
Message-Id: <R7dIf.48$n67.26@edtnps89>

Frank J. Russo wrote:
> ? Does Perl handle multilevel (dimension) arrays?  I am assuming it does.

Yes, see the documentation in:

perldoc perldata
perldoc perldsc
perldoc perllol

> I am attempting to improve the way data from my program is stored and 
> recovered.
> 
> If I was working in any other language I would define an array e.g. 
> Calendar(12,5,1).

In Perl that would be:

$Calendar[12][5][1]



John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 13 Feb 2006 20:52:45 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl vs. Python
Message-Id: <qcs1v1trjqmpce8dp92hltbco518qap5tj@4ax.com>

Anno Siegel wrote:

>> I get the same fully, but then again, I've rejected other languages (and
>
>s/fully/impression/ ?

Eh, yes. 

-- 
	Bart.


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

Date: Mon, 13 Feb 2006 21:30:20 -0500
From: "Dave" <david@nospam.com>
Subject: Why can't JavaScript work when embeded in Perl CGI code?
Message-Id: <dsrfbu$ru0$2@zcars129.ca.nortel.com>

Greetings

I had a working Perl CGI code which generates HTML page based on the
paramaeters.

I want to add a little JavaScript function like
=========================================
<SCRIPT language="JavaScript">
<!--

//Function go_download to pop up confirm window
function go_download()
{
var is_sure = window.confirm("Are you sure you want to download?");

if (is_sure == true)
{
 print "<input type=submit value=\"Get Patches\">";
 print end_html();
}
}

<FORM>
<INPUT type ="button" value = "Click to Get Patches"
onClick = "go_download();">
</FORM>

//-->
</SCRIPT>
=========================================================

But it comes error like this
"500 Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request."





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

Date: Tue, 14 Feb 2006 04:07:39 -0000
From: rick@shadowspar.dyndns.org (Rick Scott)
Subject: Re: Why can't JavaScript work when embeded in Perl CGI code?
Message-Id: <4a67.43f1578b.e3e56@shadowspar>

(Dave <david@nospam.com> uttered:)
> I had a working Perl CGI code which generates HTML page based on the
> paramaeters.
> 

 ... (changes made) ...

> 
> But it comes error like this
> "500 Server Error
> The server encountered an internal error or misconfiguration and was
> unable to complete your request."

This generally means that there is an error with your Perl CGI script
that prevents it from being executed; it usually has nothing to do
with the output the script generates.  If your script was working
before you added the javascript output clause, and isn't now, I'd
humbly suggest that you broke something in the process.   

Have a look in the webserver error logs -- you should be able to get
some idea of what's causing your script not to run.  Alternatively,
run your script from the command line and see what happens.  If you're
using the CGI module, it has debugging tools that'll help you out.

perldoc CGI




Rick
-- 
key CF8F8A75 / print C5C1 F87D 5056 D2C0 D5CE  D58F 970F 04D1 CF8F 8A75 
Every government is run by liars, 
and nothing they say should be believed.
     :I.F. Stone


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

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 8949
***************************************


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