[15500] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2910 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 30 14:10:18 2000

Date: Sun, 30 Apr 2000 11:10:11 -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: <957118211-v9-i2910@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 30 Apr 2000     Volume: 9 Number: 2910

Today's topics:
    Re: Order of evaluation (Was: Re: regex) (Ilya Zakharevich)
        Passing variables with do <ppi@searchy.net>
    Re: Passing variables with do <rick.delaney@home.com>
        Please Explain ... print "Location: http:etc."; <rwilkins1@home.com>
    Re: Please Explain ... print "Location: http:etc."; <care227@attglobal.net>
        Retrieving the name of a variable <makau@multimania.com>
    Re: Retrieving the name of a variable (Tad McClellan)
    Re: Something isn't working, and I can't figure it out (Tad McClellan)
    Re: Something isn't working, and I can't figure it out <care227@attglobal.net>
    Re: undefined value as a symbol reference gene01@smalltime.com
    Re: undefined value as a symbol reference gene01@smalltime.com
    Re: undefined value as a symbol reference gene01@smalltime.com
    Re: undefined value as a symbol reference <jeff@vpservices.com>
        Unicode in Perl 5.6 - broken? <bertilow@hem.passagen.se>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 30 Apr 2000 00:20:08 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Order of evaluation (Was: Re: regex)
Message-Id: <8efu7o$h4p$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler 
<lr@hpl.hp.com>],
who wrote in article <MPG.1374a95e311095a998a9b5@nntp.hpl.hp.com>:
> [Note:  Sometimes Perl does specify things that C does not.  For 
> example, the order of evaluation of the arguments to a C subroutine is 
> unspecified; the order of evaluation of the arguments to a Perl 
> subroutine is explicitly left-to-right, because that is specified as the 
> order of evaluation of the elements of a LIST.]

This is worse than this.  There is evaluation, and there is access.

It is quite believable that elements of LIST are always evaluated
left-to-right (though I would not like to *guarantie* this), but they
may be *accessed* in a different order:

  tie $bar, ...; sub bar { $bar }
  tie $baz, ...; sub baz { $baz }
  foo(bar(), baz())

bar() may be called before baz(), but (tied$bar)->FETCH can be called
after (tied$baz)->FETCH.

Ilya


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

Date: Sun, 30 Apr 2000 14:44:08 +0200
From: Penpal International <ppi@searchy.net>
Subject: Passing variables with do
Message-Id: <390C2A98.10D27E79@searchy.net>

Is there a way to pass data to another script which is called with 'do'?
I've already tried with a querystring and @argv, but both won't work.


-- 
Penpal International
http://ppi.searchy.net/
ppi@searchy.net


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

Date: Sun, 30 Apr 2000 16:05:23 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Passing variables with do
Message-Id: <390C5A86.70FDEBA2@home.com>

[posted & mailed]

Penpal International wrote:
> 
> Is there a way to pass data to another script which is called with 'do'?
> I've already tried with a querystring and @argv, but both won't work.
  ^^^^^^^^^^^^^^^^^^

I don't see what you tried.  Maybe you should try @ARGV instead of
@argv.

perldoc perlvar

rick $ cat > one
@ARGV = $0;
do 'two';
rick $ cat > two
print while <>;
rick $ perl one
@ARGV = $0;
do 'two';

Or maybe you just want to run external programs.

perldoc -f system

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sun, 30 Apr 2000 15:51:34 GMT
From: Robert Wilkins <rwilkins1@home.com>
Subject: Please Explain ... print "Location: http:etc.";
Message-Id: <390C595F.EDB6636B@home.com>

Greetings:

I am a Perl newbie and am copying someone else's cgi script that works.
After the input data from an HTML FORM  (POST) is processed and the MAIL is sent back,
the following line "successfully" returns the correct web page to the client.

   print  "Location: http://www.xxx/index.htm\n\n";

Please explain what the <Location:> part is. I can find no reference to it in any books or on
deja...

Also..... and this is the most important part.

I have included a "hidden" field in my form named "nextpage"
   and it has a value of  "http://www.xxx/index.htm\n\n"

I have successfully parsed this field into a Perl variable named $NEXTPAGE
(I know it is there because I can get the field to print back as part of my returning e-mail)

Why does the following not work ???

   print  "Location: $NEXTPAGE";

This would allow me to change my "next page" from the html file and not have to revise the cgi
script.

Thanks in advance for your advice
Best Regards
Bob Wilkins
Burlington, Ontario, Canada






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

Date: Sun, 30 Apr 2000 12:00:26 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Please Explain ... print "Location: http:etc.";
Message-Id: <390C589A.C3D8E0B6@attglobal.net>



Robert Wilkins wrote:

> I am a Perl newbie and am copying someone else's cgi script that works.

The magic word is CGI...  Your best bet is to try this
question in a newsgroup dedicated to CGI, specifically
comp.infosystems.www.authoring.cgi

Good group.  I would recomend, though, that before 
you post you double check the faq's at www.perl.com.

Do a search on that site for CGI and you should get alot
of reading.

p.s (location: tells the browser which... erm.. location to load.)


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

Date: Sun, 30 Apr 2000 14:37:23 GMT
From: Makau Divangamene <makau@multimania.com>
Subject: Retrieving the name of a variable
Message-Id: <8ehgf1$erp$1@nnrp1.deja.com>

How do you retrieve the name of a variable?

For example the follwing code :

--
($var1,$var2,$var3) = ('value1','value2','value3');

foreach ($var1,$var2,$var3) {
        print NameOfVar($_)."\n";
};
--

should return:

--
var1
var2
var3
--

Thanks in advance!


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


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

Date: Sun, 30 Apr 2000 10:28:56 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Retrieving the name of a variable
Message-Id: <slrn8gogp8.7bt.tadmc@magna.metronet.com>

On Sun, 30 Apr 2000 14:37:23 GMT, Makau Divangamene <makau@multimania.com> wrote:
>How do you retrieve the name of a variable?


Why do you (really) want to do this?

There is likely a better way to do what you want, but you
have to tell us what you want (not how you think you can
_get_ what you want, but what you ultimately want).


>For example the follwing code :
>
>--
>($var1,$var2,$var3) = ('value1','value2','value3');
>
>foreach ($var1,$var2,$var3) {
>        print NameOfVar($_)."\n";
>};
>--
>
>should return:
        ^^^^^^

"return" and "output" mean very different things.

You do not mean "return" there, you mean "output".

>--
>var1
>var2
>var3
>--


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


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

Date: Sun, 30 Apr 2000 10:18:56 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Something isn't working, and I can't figure it out
Message-Id: <slrn8gog6g.72l.tadmc@magna.metronet.com>

On Sat, 29 Apr 2000 23:55:33 -0700, Larry Rosler <lr@hpl.hp.com> wrote:

>Who would conceive that they hijacked the Perl camel?  

>Is nothing 
>sacred?


   I think cows are...


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


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

Date: Sun, 30 Apr 2000 11:18:12 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Something isn't working, and I can't figure it out
Message-Id: <390C4EB4.B1BDC525@attglobal.net>

Hmm...  While you guys are still reading this thread, I think I'll
sneak in my last question.  That being (drumRoll) <- camel notation =)

Why does this file:

$ cat spanky.data
  4:spec_num
  5:spec_proc
  1:price_plan
  3:css_queue
$

which was created by this command: print DATA map $_ . "\n" => @$page;

get read into an array, using either of these methods:

chomp(@page_array = <DATA>);  -or-

while (<DATA>){
	chomp;
	push(@page_array,$_);	
}

all as $page_array[0]???  why doesn't it populate the array 
with one index per line of the file??  If _anyone_ can shed 
some light on that, I will think kind thoughts about them for
weeks on end.


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

Date: Sun, 30 Apr 2000 15:24:07 GMT
From: gene01@smalltime.com
Subject: Re: undefined value as a symbol reference
Message-Id: <8ehj6d$his$1@nnrp1.deja.com>

In article
<Pine.GSO.4.10.10004251031570.25963-100000@user2.teleport.com>,
  Tom Phoenix <rootbeer@redcat.com> wrote:
> On 24 Apr 2000, gene wrote:
>
> > Can't use an undefined value as a symbol reference at
HTMLTemplate.pm
> > line 31
>
> >     if (eof($fh)) {  # <--- error here
>
> If $fh is anything but undef here, it looks as if you've found a bug
in
> perl. If $fh is undefined, that's your problem. (Or maybe your problem
is
> to step through your code in the debugger to learn why it's undef.)
>
> Can it really be that easy? :-)
>

But...

It works fine with a different version of perl and

The error comes up on a syntax check (perl -c).  The file handle
definitely is defined at the point where that code is encountered,
if this version of perl would allow me to actually run the co


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


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

Date: Sun, 30 Apr 2000 15:24:34 GMT
From: gene01@smalltime.com
Subject: Re: undefined value as a symbol reference
Message-Id: <8ehj77$hpc$1@nnrp1.deja.com>

In article
<Pine.GSO.4.10.10004251031570.25963-100000@user2.teleport.com>,
  Tom Phoenix <rootbeer@redcat.com> wrote:
> On 24 Apr 2000, gene wrote:
>
> > Can't use an undefined value as a symbol reference at
HTMLTemplate.pm
> > line 31
>
> >     if (eof($fh)) {  # <--- error here
>
> If $fh is anything but undef here, it looks as if you've found a bug
in
> perl. If $fh is undefined, that's your problem. (Or maybe your problem
is
> to step through your code in the debugger to learn why it's undef.)
>
> Can it really be that easy? :-)
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>


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


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

Date: Sun, 30 Apr 2000 15:26:04 GMT
From: gene01@smalltime.com
Subject: Re: undefined value as a symbol reference
Message-Id: <8ehja1$hrk$1@nnrp1.deja.com>

In article
<Pine.GSO.4.10.10004251031570.25963-100000@user2.teleport.com>,
  Tom Phoenix <rootbeer@redcat.com> wrote:
> On 24 Apr 2000, gene wrote:
>
> > Can't use an undefined value as a symbol reference at
HTMLTemplate.pm
> > line 31
>
> >     if (eof($fh)) {  # <--- error here
>
> If $fh is anything but undef here, it looks as if you've found a bug
in
> perl. If $fh is undefined, that's your problem. (Or maybe your problem
is
> to step through your code in the debugger to learn why it's undef.)
>
> Can it really be that easy? :-)
>

It's not that easy.

This works fine in a different version of perl.

This error comes up on a syntax check (-c) before anything even
gets run, so I don't see how perl can be deciding that $fh is
undefined (which it certainly is not when the code is actually ru


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


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

Date: Sun, 30 Apr 2000 08:45:35 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: undefined value as a symbol reference
Message-Id: <390C551F.57364154@vpservices.com>

gene wrote:

> sub start {
>     my $this = shift;
>     $TXT_FILE = shift or return 0;
>     open ( FH, $TXT_FILE )or return 0;
>     $fh = \*FH;
>     return 1;
> }

Since you allow the script to keep running after you attempt to open a
file and you don't show us what happens if the start() method returns
false, it's hard to say what else happens in your script that depends on
$fh actually being defined.  
-- 
Jeff


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

Date: Sun, 30 Apr 2000 19:29:00 +0200
From: "Bertilo Wennergren" <bertilow@hem.passagen.se>
Subject: Unicode in Perl 5.6 - broken?
Message-Id: <8ehqat$92hv7$1@fu-berlin.de>

I just started experimentng with the new Unicode features
of Perl 5.6 using the ActiveState Perl 5.6 in a Windows 98
environment. I found some serious problems. Either my
understanding of a few things is severly broken, or else
Perl 5.6 is.

My main problem concerns upper/lower case translation.
Things just don't behave in an understandable way, and
some things seem seriously broken.

To summarize the problems I've met I concocted the following
CGI-script. The result is meant to be read with at browser
that can deal with UTF-8, and that can show the necessary
glyphs for characters from Latin-1 Supplement and Latin
Extended A.

The code uses UTF-8 and won't make much sense if your
reader can't interpret UTF-8.

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

#!/usr/bin/perl

use strict;
use utf8;

my ($string, $upper_string1, $upper_string2);

$string = "abc ABC åäö ÅÄÖ ĉĝĥĵŝŭ ĈĜĤĴŜŬ";

$upper_string1 = $string;
$upper_string1 =~ s/(\w)/\U$1\E/g;

$upper_string2 = $string;
$upper_string2 = uc($upper_string2);

my ($read_string, $upper_read_string1, $upper_read_string2);

# THE FILE "read_string.txt" SHOULD CONTAIN THE SAME
# LINE OF CHARACTERS AS "$string" ABOVE - ENCODED IN UTF-8.
open(READ,"read_string.txt");
$read_string = <READ>;
close READ;

$upper_read_string1 = $read_string;
$upper_read_string1 =~ s/(\w)/\U$1\E/g;

$upper_read_string2 = $read_string;
$upper_read_string2 = uc($upper_read_string2);

print qq(Content-type: text/html; charset=utf-8\n\n);

print qq(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n);
print qq(    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n);
print qq(<html xmlns="http://www.w3.org/1999/xhtml">\n);
print qq(<head>\n);
print qq(<title>Test</title>\n);
print qq(</head>\n);
print qq(<body>\n);

print qq(<p>STRING: $string</p\n>);
print qq(<p>UPPERCASED STRING 1:  $upper_string1</p>\n);
print qq(<p>UPPERCASED STRING 2:  $upper_string2</p>\n);

print qq(<p>READ STRING: $read_string</p\n>);
print qq(<p>UPPERCASED READ STRING 1:  $upper_read_string1</p>\n);
print qq(<p>UPPERCASED READ STRING 2:  $upper_read_string2</p>\n);

print qq(</body>\n);
print qq(</html>\n);

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

If you manage to get this code to work in a CGI environment,
you'll see that the uppercasing of the string turns out in
several different ways, and that it is correct in only half of the
time. The "\U" method works only for the string that is read from
a file. The "uc()" method works only for the other string (declared
in the perl code.

This is what I get in my broser:

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

STRING: abc ABC åäö ÅÄÖ ĉĝĥĵŝŭ ĈĜĤĴŜŬ

UPPERCASED STRING 1: AFC ABC åÄ1ö 01Ä01 ĉĜ1ĥĴ1ŝŬ1 Ĉ01Ĥ01Ŝ01

UPPERCASED STRING 2: ABC ABC ÅÄÖ ÅÄÖ ĈĜĤĴŜŬ ĈĜĤĴŜŬ

READ STRING: abc ABC åäö ÅÄÖ ĉĝĥĵŝŭ ĈĜĤĴŜŬ

UPPERCASED READ STRING 1: ABC ABC ÅÄÖ ÅÄÖ ĈĜĤĴŜŬ ĈĜĤĴŜŬ

UPPERCASED READ STRING 2: ABC ABC åäö ÅÄÖ ĉĝĥĵŝŭ ĈĜĤĴŜŬ

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

The second line is particulary horrible. Note that "b" is
uppercased to "F"! What is going on here?

If the line "use utf8" is removed things look a bit less broken at
first glance, but actually uppercasing of non-ASCII characters
doesn't work at all without the utf8 pragma.

Is it me or is it perl?

My Perl version says:

  This is perl, v5.6.0 built for MSWin32-x86-multi-thread
  (with 1 registered patch, see perl -V for more detail)

  Copyright 1987-2000, Larry Wall

  Binary build 613 provided by ActiveState Tool Corp.
  http://www.ActiveState.com
  Built 12:36:25 Mar 24 2000

--
#####################################################################
                         Bertilo Wennergren
                 <http://purl.oclc.org/net/bertilo>
                     <bertilow@hem.passagen.se>
#####################################################################



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

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


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