[16822] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4234 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 6 09:10:28 2000

Date: Wed, 6 Sep 2000 06:10:17 -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: <968245817-v9-i4234@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 6 Sep 2000     Volume: 9 Number: 4234

Today's topics:
        newbie: redirect problem <hmacdonald@europarl.eu.int>
    Re: newbie: redirect problem <godzilla@stomp.stomp.tokyo>
    Re: newbie: redirect problem gumbygumbygumby@my-deja.com
    Re: newbie: redirect problem <hmacdonald@europarl.eu.int>
    Re: newbie: redirect problem <mindless@ihug.co.nz.nospam>
    Re: newbie: redirect problem (Martien Verbruggen)
    Re: newbie: redirect problem nobull@mail.com
    Re: Perl Newbie: Stipping Absolute Paths from *.html fi (Daniel Chetlin)
        Perl path. jimmy_mcnamara@my-deja.com
    Re: Perl path. nobull@mail.com
        Re-learn Perl <haf@autra.noXX>
    Re: Remove carriage returns from input <flavell@mail.cern.ch>
        Test if array which was returned as a reference has som (Brian Lavender)
    Re: Troubles with Async.pm pedjav@my-deja.com
    Re: Troubles with dbd::oracle installation <solivares@alamo-online.es>
    Re: UDP Broadcast does not work <Peter.Dintelmann@dresdner-bank.com>
    Re: UDP Broadcast does not work <kiwi@kiwinet.de>
    Re: UDP Broadcast does not work <kiwi@kiwinet.de>
    Re: UDP Broadcast does not work (Martien Verbruggen)
    Re: weird behavior of _ file handle <qchen@snet.net>
    Re: weird behavior of _ file handle (Martien Verbruggen)
    Re: weird behavior of _ file handle (Martien Verbruggen)
        why does foreach iterate on an undef variable? <johnston.p@worldnet.att.net>
    Re: why does foreach iterate on an undef variable? <johnston.p@worldnet.att.net>
    Re: why does foreach iterate on an undef variable? <louise.davis@breathemail.net>
    Re: why does foreach iterate on an undef variable? (Martien Verbruggen)
    Re: why does foreach iterate on an undef variable? (Martien Verbruggen)
    Re: why does foreach iterate on an undef variable? <louise.davis@breathemail.net>
        XML::Parser and DTD? marvin42_98@yahoo.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 06 Sep 2000 09:51:22 +0200
From: harry <hmacdonald@europarl.eu.int>
Subject: newbie: redirect problem
Message-Id: <39B5F77A.5BC53D45@europarl.eu.int>

Can anyone please sort me out.

I'm browsing a perl script which is served up by an IIS server.
(http://site/my.pl)
And from within the perl script I want to jump to another URL.

I think what I need is a redirect -
so I've tried the redirect syntax from CGI.pm :-
$query->redirect(-uri=>'http://site/page.htm',     -nph=>1);
But this just displays in the browser the following message :-
"HTTP/1.0 302 Moved Status: 302 Moved Location: http://site/page.htm "

Also the syntax from http://stein.cshl.org/~lstein/talks/marjorie/
        print redirect('http://site/page.htm');
But this does nothing

Thanks in advance
Harry



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

Date: Wed, 06 Sep 2000 01:30:56 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: newbie: redirect problem
Message-Id: <39B600C0.3258073E@stomp.stomp.tokyo>

harry wrote:
 
> Can anyone please sort me out.

@Me = sort (@Me);

How's that?

If you like, I can screw your head on backwards.

@Me = reverse (@Me)

Neat huh? Just like Linda Blair in Exorcist.

* speaks in tongues *

MUUUUHAHAHAHHAAAAAA!

 
 
> I think what I need is a redirect -
> so I've tried the redirect syntax from CGI.pm :-
> $query->redirect(-uri=>'http://site/page.htm',     -nph=>1);
> But this just displays in the browser the following message :-
> "HTTP/1.0 302 Moved Status: 302 Moved Location: http://site/page.htm "
 
> Also the syntax from http://stein.cshl.org/~lstein/talks/marjorie/
> print redirect('http://site/page.htm');
> But this does nothing


Sure reading this question often, how odd. * laughs *

Why the jumping jelly beans are you using cgi-poopmaker ?!?!

GAK!!!! This is a guarantee of problems!

*spins her head around thirteen times*

MUUUUUHAAAAHAHAHAHAAAAAA!


Just do this:

print "Location: http://site/page.htm\n\n";

All done! No need for a non-parsed header call,
which is rather odd, much like myself. No need
for calling in six-thousand-five-hundred plus
lines of cgi-poopmaker which bloats your memory
usage by more computer memory available aboard 
Kirk's Enterprise and slows your script down
to a pace of a snail on ice.

Just print a location! Wallah! No mule manure
splattered all over your script by Perl 5 Cargo
Cult cgi-poopmaker!!!!

Oh yeah, you don't need to print a content type either.

* snaps her fingers over her head, vanishes *

Godzilla!
-- 
Shazama Fatima Alabimbo, Internet Mind Reader.
  http://la.znet.com/~callgirl/mindread.cgi


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

Date: Wed, 06 Sep 2000 08:44:30 GMT
From: gumbygumbygumby@my-deja.com
Subject: Re: newbie: redirect problem
Message-Id: <8p505b$rq9$1@nnrp1.deja.com>

In article <39B5F77A.5BC53D45@europarl.eu.int>,
  harry <hmacdonald@europarl.eu.int> wrote:
> Can anyone please sort me out.
>
> I'm browsing a perl script which is served up by an IIS server.
> (http://site/my.pl)
> And from within the perl script I want to jump to another URL.
print "Location: http://www.somewhere.com\n\n";

should do the trick i believe.


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


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

Date: Wed, 06 Sep 2000 11:30:36 +0200
From: macdo <hmacdonald@europarl.eu.int>
Subject: Re: newbie: redirect problem
Message-Id: <39B60EBC.9BF7663A@europarl.eu.int>

No - I'm afraid all this does is display in my browser the string
"Location: http://www.somewhere.com\n\n"



gumbygumbygumby@my-deja.com wrote:

> In article <39B5F77A.5BC53D45@europarl.eu.int>,
>   harry <hmacdonald@europarl.eu.int> wrote:
> > Can anyone please sort me out.
> >
> > I'm browsing a perl script which is served up by an IIS server.
> > (http://site/my.pl)
> > And from within the perl script I want to jump to another URL.
> print "Location: http://www.somewhere.com\n\n";
>
> should do the trick i believe.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



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

Date: Wed, 6 Sep 2000 22:34:46 +1200
From: "[WarLocK]" <mindless@ihug.co.nz.nospam>
Subject: Re: newbie: redirect problem
Message-Id: <8p55mc$erh$1@news.ihug.co.nz>

did you make sure to use double inverted commas (") not single (') as
backslashed characters are not interpreted in single inverted commas.

Damian.


"macdo" <hmacdonald@europarl.eu.int> wrote in message
news:39B60EBC.9BF7663A@europarl.eu.int...
> No - I'm afraid all this does is display in my browser the string
> "Location: http://www.somewhere.com\n\n"
>
>
>
> gumbygumbygumby@my-deja.com wrote:
>
> > In article <39B5F77A.5BC53D45@europarl.eu.int>,
> >   harry <hmacdonald@europarl.eu.int> wrote:
> > > Can anyone please sort me out.
> > >
> > > I'm browsing a perl script which is served up by an IIS server.
> > > (http://site/my.pl)
> > > And from within the perl script I want to jump to another URL.
> > print "Location: http://www.somewhere.com\n\n";
> >
> > should do the trick i believe.
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>




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

Date: Wed, 6 Sep 2000 21:55:08 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: newbie: redirect problem
Message-Id: <slrn8rc8kc.ucf.mgjv@martien.heliotrope.home>

On Wed, 06 Sep 2000 09:51:22 +0200,
	harry <hmacdonald@europarl.eu.int> wrote:
> Can anyone please sort me out.
> 
> I'm browsing a perl script which is served up by an IIS server.
> (http://site/my.pl)
> And from within the perl script I want to jump to another URL.
> 
> I think what I need is a redirect -
> so I've tried the redirect syntax from CGI.pm :-
> $query->redirect(-uri=>'http://site/page.htm',     -nph=>1);
> But this just displays in the browser the following message :-
> "HTTP/1.0 302 Moved Status: 302 Moved Location: http://site/page.htm "

Do you by any chance have a 

print $query->header;

before this? The documentation _clearly_ states:

# perldoc CGI
[snip]
	The redirect() function redirects the browser to a differ­
	ent URL.  If you use redirection like this, you should not
	print out a header as well.
[snip]

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd.   | from a rich salesperson.
NSW, Australia                  | 


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

Date: 06 Sep 2000 12:35:36 +0100
From: nobull@mail.com
Subject: Re: newbie: redirect problem
Message-Id: <u9zoll3g8n.fsf@wcl-l.bham.ac.uk>

macdo <hmacdonald@europarl.eu.int> writes upside down

Stop it.  We don't like it.  We consider it discourteous.  You are
asking us for help here please try not to offend us.

macdo <hmacdonald@europarl.eu.int> writes upside down
> 
> gumbygumbygumby@my-deja.com wrote:

> > print "Location: http://www.somewhere.com\n\n";
> >
> > should do the trick i believe.

> No - I'm afraid all this does is display in my browser the string
> "Location: http://www.somewhere.com\n\n"

Would someone _please_ tell macdo that he does not want to emit the
redirect headers as part of the HTTP response body but rather as HTTP
response headers.  If you are emiting a redirect response you must not
emit a standard set of HTTP response headers first.

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


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

Date: Wed, 06 Sep 2000 12:26:19 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: Perl Newbie: Stipping Absolute Paths from *.html files
Message-Id: <LJqt5.61354$f65.1694116@news-west.usenetserver.com>

On 05 Sep 2000 09:35:05 -0700, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Carl" == Carl DiPasquale <cdipasqu@visteon.com> writes:
>
>Carl> Help!
>Carl> I need to remove a bunch of absolute path strings from all files in a
>Carl> website, (recursively from the site root), where the developers have
>Carl> hardcoded the string value: "http://www.sitename.com/" instead of using
>Carl> relative pathing.  Does anyone have a script that will recursively
>Carl> search all .html/.htm files in a site and change/remove a group of
>Carl> specified string values, (I need to search for 3 particular strings and
>Carl> remove them)?  
>
>While not exactly "ready to run" for your application, you might look at:
>
>        http://www.stonehenge.com/merlyn/WebTechniques/col22.html
>
>for a way to do this easily.

Randal's techniques in this article are excellent and still quite useable, but
it is worthwhile to point out that since this article was written (February
1998), HTML::Parser has added a new API which will make this sort of thing
easier.

It might be a good exercise to translate Randal's code to the version 3 API.

I would also suggest taking a look at URI, HTML::LinkExtor, URI::Find, and a
couple of other modules in that general category. It all depends on exactly
what you really need done.

-dlc




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

Date: Wed, 06 Sep 2000 08:56:40 GMT
From: jimmy_mcnamara@my-deja.com
Subject: Perl path.
Message-Id: <8p50s1$sfq$1@nnrp1.deja.com>

Hi Folks,

I have written some perl scripts to interface to an email web server
about 8 in total. The problem I have is that these scripts need to be
installed on multiple machines. I have no control over the setup of
these machines and some of them have perl installed in /usr/bin and
others in /usr/local/bin. Can I modify my perl script to look for perl
in both places rather than using #!/usr/local/bin/perl in some of the
scripts  and #!/usr/bin/perl in the others.

Regards

Jimmy


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


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

Date: 06 Sep 2000 12:24:50 +0100
From: nobull@mail.com
Subject: Re: Perl path.
Message-Id: <u91yyx4vb1.fsf@wcl-l.bham.ac.uk>

jimmy_mcnamara@my-deja.com writes:

> I have written some perl scripts to interface to an email web server
> about 8 in total. The problem I have is that these scripts need to be
> installed on multiple machines. I have no control over the setup of
> these machines and some of them have perl installed in /usr/bin and
> others in /usr/local/bin. Can I modify my perl script to look for perl
> in both places rather than using #!/usr/local/bin/perl in some of the
> scripts  and #!/usr/bin/perl in the others.

Assuming both directories are in $ENV{PATH} then consider the
following hack (adpted slightly from the example in the perlrun
manpage):

#!/bin/sh -- # -*- perl -*-
eval 'exec perl -wS $0 ${1+"$@"}'
  if $running_under_some_shell;

Basically this uses /bin/sh to search for a program called 'perl' on
the search path.

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


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

Date: Wed, 06 Sep 2000 12:43:14 +0200
From: "P.Eftevik" <haf@autra.noXX>
Subject: Re-learn Perl
Message-Id: <39B61FC2.D70348C7@autra.noXX>

I used to program perl (4.0), but it's some years ago now.
And now it's time to code perl again, so I need to re-learn what I've
spent 6-7 years to forget.

In addition, the language has probably evolved significantly over
this period.

Question: where do I find a 'Quick reference Guide' and some brief
code samples and other hints to freshen up my prior skill ?

All pointers welcome.

PEftie

Navvia,
Norway




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

Date: Wed, 6 Sep 2000 12:03:25 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Remove carriage returns from input
Message-Id: <Pine.GHP.4.21.0009061201060.8800-100000@hpplus03.cern.ch>

On Wed, 6 Sep 2000, Dave Brondsema wrote:

> \r is return (ascii 13)
> \n is newline (ascii 10)

Take a read of perldoc perlport, and some of the useful contributions
to this thread by other usenauts.  I'd say you have something to learn
about portability.

> This simple answer was the result of a ~2 hr frustrating search.

What?  Perl nowadays comes with plenty of documentation.  Familiarise
yourself with it; use it.




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

Date: Wed, 06 Sep 2000 00:16:39 GMT
From: brian@brie.com (Brian Lavender)
Subject: Test if array which was returned as a reference has something in it?
Message-Id: <39b58b4e.138622915@news.pacbell.net>

I have the following code which works for parsing through a csv file
created by saving an Excel spreadsheet to csv format. It uses the
Text::CSV_XS module as you can see. I am wondering if there is another
way to test to see if array reference refers to an array that has
something in it? 

You will notice that I have the "&&"  which will after sucessfully
returning a reference, will test to see if the array it returned has
something in it, but this way seems a bit kludish, so I was wondering
if this is a good way to do this?

#!/usr/local/bin/perl

use Text::CSV_XS;
use IO::File;

$csv = Text::CSV_XS->new();

$fh = new IO::File;
$fh->open("< ./39ac06644517.csv") || die "Unable to create file handle
object $!\n";

while (  ($columns = $csv->getline($fh))  && @$columns ) {
  # Is there another way to do the above test?

  print join " ", @$columns , "\n";
}

brian
--
Brian E. Lavender
http://www.brie.com/brian/

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge. 
                                 --Peter J. Schoenster


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

Date: Wed, 06 Sep 2000 07:04:17 GMT
From: pedjav@my-deja.com
Subject: Re: Troubles with Async.pm
Message-Id: <8p4q9b$kp8$1@nnrp1.deja.com>


> Try to find a small example program that demonstrates the problem.
> Send the example program to the author of the module.  It is not
> likely that anyone can help you unless you provide a more detailed
> report.

I already send two times example to the author, but no response :(
Anyway this is example:

#!/usr/bin/perl -w

use Async;

sub test1 {sleep 1;return "1-OK!";}
sub test2 {sleep 1;return "2-OK!";}
sub test3 {sleep 1;return "3-OK!";}
sub test4 {sleep 1;return "4-OK!";}
sub test5 {sleep 1;return "5-OK!";}

$proc1=Async->new(sub {test1});
$proc2=Async->new(sub {test2});
$proc3=Async->new(sub {test3});
$proc4=Async->new(sub {test4});
$proc5=Async->new(sub {test5});

while (not (($proc1->ready) && ($proc2->ready) && ($proc3->ready) &&
($proc4->ready) && ($proc5->ready))){print "waiting..\n"; sleep 1;}

if ($e = $proc1->error){print "Error1: $e\n";}
       else {print "Result1: ", $proc1->result, "\n";}

if ($e = $proc2->error){print "Error2: $e\n";}
       else {print "Result2: ", $proc2->result, "\n";}

if ($e = $proc3->error){print "Error3: $e\n";}
       else {print "Result3: ", $proc3->result, "\n";}

if ($e = $proc4->error){print "Error4: $e\n";}
       else {print "Result4: ", $proc4->result, "\n";}

if ($e = $proc5->error){print "Error5: $e\n";}
       else {print "Result5: ", $proc5->result, "\n";}


as I already said, somtimes works fine but sometimes I get no result.
Execute this script atleast 5 times.
Thanks


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


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

Date: Wed, 6 Sep 2000 10:10:52 +0200
From: "Sergio Olivares" <solivares@alamo-online.es>
Subject: Re: Troubles with dbd::oracle installation
Message-Id: <8p4u8b$aap$1@lola.ctv.es>


John D Groenveld wrote in message <8p3dge$be4$1@ewok.cse.psu.edu>...
>Does README.help's "Can't find libclntsh.so at run time" apply?
>John
>groenveld@acm.org

thank you. this solved the problem




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

Date: Wed, 6 Sep 2000 10:39:07 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: UDP Broadcast does not work
Message-Id: <8p4vrd$2m1@intranews.bank.dresdner.net>

    Hi,

Michael Kiwaczinski schrieb in Nachricht
<8p4289$q9d$12$1@news.t-online.com>...
>$host="192.168.0.1" will work, but a Broadcast didn`t
(255.255.255.255) --

    have a look at your broadcast address.
    It depends on your netmask and network address
    and is usually the last address in your network.
    I rather expected so see something like
    192.168.0.255 above.

    Best regards,

        Peter Dintelmann





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

Date: Wed, 6 Sep 2000 12:41:06 +0100
From: "Michael Kiwaczinski" <kiwi@kiwinet.de>
Subject: Re: UDP Broadcast does not work
Message-Id: <8p56v1$s8m$17$1@news.t-online.com>

>     have a look at your broadcast address.
>     It depends on your netmask and network address
>     and is usually the last address in your network.
>     I rather expected so see something like
>     192.168.0.255 above

Yes Ok,

My WindowsPC (192.168.0.4), received the Broadcast, but my cute Linux PC
didŽnt. Why? Must i enable Broadcast reiceiving?

Mfg Kwi

--
"It's not easy being green" (Kermit the frog)
Mulzergraben12, 87700 Memmingen
Telefon: +49 8331 490275






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

Date: Wed, 6 Sep 2000 12:56:27 +0100
From: "Michael Kiwaczinski" <kiwi@kiwinet.de>
Subject: Re: UDP Broadcast does not work
Message-Id: <8p57rr$sgv$17$1@news.t-online.com>

Sorry i found the Problem my Shit Firewall!!

Mfg Kwi



--
"It's not easy being green" (Kermit the frog)
Mulzergraben12, 87700 Memmingen
Telefon: +49 8331 490275






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

Date: Wed, 6 Sep 2000 22:35:44 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: UDP Broadcast does not work
Message-Id: <slrn8rcb0g.ucf.mgjv@martien.heliotrope.home>

On Wed, 6 Sep 2000 12:56:27 +0100,
	Michael Kiwaczinski <kiwi@kiwinet.de> wrote:
> Sorry i found the Problem my Shit Firewall!!

You know that nowadays they sell firewalling software solutions, right?
Building your own out of excrement is no longer necessary.  Besides,
ipchains attracts fewer flies.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd.   | password?
NSW, Australia                  | 


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

Date: Wed, 06 Sep 2000 06:47:05 -0400
From: Richard Chen <qchen@snet.net>
Subject: Re: weird behavior of _ file handle
Message-Id: <39B620A8.575852DA@snet.net>

The "reset" or the "mark as invalid" as Uri puts it, is not really
documented.
I isolated the problem by debugging a complicated cgi script which shows
wrong info for a tiny fractions of files some times.

The perldoc actually suggestes using '-f _ && -T _'. This is apparently
not enough and will still lead to "reset" or "mark as invalid". If this
step
is unavoidable, then the docs should be modified to suggest that
        always use '-r _ && -T _'
or the _ file handle will not behave as you expect. Similarly for -B
checking.

Richard

Martien Verbruggen wrote:

> On Tue, 05 Sep 2000 23:57:04 -0400,
>         Richard Chen <qchen@snet.net> wrote:
> > According to perldoc -f -s, once a stat is applied to a file, one can
> > find
> > other stat attributes by querying _ file handle, saving system calls.
> >
> > But the following shows that this is not the case if the file has the
> > permission mode 111:
>
> It isn't because the file permissions are 111, but because you have no
> read permission on the file. To use some of those magical -X
> operators, you need to have read permission. The -T is one of them. As
> soon as you do something that fails, the _ filehandle gets reset or
> something. Many of these things do not require read access, watch:
>
> $ cat foo.pl
> #!/usr/local/bin/perl -w
> use strict;
>
> my $file = 'gobble';
> my @s;
>
> open(F, ">$file") or die $!;
> print F "garbage\n";
> close F;
>
> chmod 0777, $file or die $!;
> @s = stat($file);
> print "@s\n";
> printf "%d %d %d %d\n", -s _, -T _, -s _, -s $file;
>
> chmod 0177, $file or die $!;
> @s = stat($file);
> print "@s\n";
> printf "%d %d %d %d\n", -s _, -T _, -s _, -s $file;
>
> chmod 0600, $file or die $!;
> unlink $file or die $!;
>
> $ ./foo.pl
> 2097 234602 33279 1 146 100 14158 8 968214104 968214104 968214104 4096 8
> 8 1 8 8
> 2097 234602 32895 1 146 100 14158 8 968214104 968214104 968214104 4096 8
> Use of uninitialized value in printf at ./foo.pl line 19.
> Use of uninitialized value in printf at ./foo.pl line 19.
> 8 0 0 8
>
> As you can see, both stats succeed, and the first -s succeeds in both
> cases. After using -T, however, it will _not_ succeed, if you don't
> have read permissions.
>
> Martien
> --
> Martien Verbruggen              |
> Interactive Media Division      | You can't have everything, where
> Commercial Dynamics Pty. Ltd.   | would you put it?
> NSW, Australia                  |



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

Date: Wed, 6 Sep 2000 22:15:40 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: weird behavior of _ file handle
Message-Id: <slrn8rc9qs.ucf.mgjv@martien.heliotrope.home>

[Please, in the future, put your reply _after_ the text you reply to. It
makes more sense, since that is also how the arrow of time runs, and it
makes multiply quoted posts much easier to read]

On Wed, 06 Sep 2000 06:47:05 -0400,
	Richard Chen <qchen@snet.net> wrote:
> The "reset" or the "mark as invalid" as Uri puts it, is not really
> documented.

I cancelled my article about 10 seconds after I posted it. For the
following reason: I had not read the original post well enough, and was
rehashing half of what was stated in it.

I wanted to post almost exactly what Uri said, but when I refreshed the
group list, his reply was already there, so I didn't have to.

I wish the fscking spam wars hadn't made Usenet such a mess that cancels
don't even get honoured correctly anymore.

> I isolated the problem by debugging a complicated cgi script which shows
> wrong info for a tiny fractions of files some times.
> 
> The perldoc actually suggestes using '-f _ && -T _'. This is apparently
> not enough and will still lead to "reset" or "mark as invalid". If this
> step
> is unavoidable, then the docs should be modified to suggest that
>         always use '-r _ && -T _'
> or the _ file handle will not behave as you expect. Similarly for -B
> checking.

I agree, but I'd like to see the following, in order of preference:

1) perl is adapted to not invalidate the handle on an error that is not
related to stat information, but to other file accesses. -T  and -B are
abominations anyway :). But seriously, they're different, tackons. They
could be treated differently for this particular case as well. They are
the only -X operators that this applies to anyway. Documentation could
be simpkly adapted to state that these two require read access to the
file itself.

1) the documentation should be adapted to state that any invalid use of
_ invalidates further use of that handle, INCLUDING the use of -B and
-T. This means that you'd have to explain, in the documentation, that -B
and -T require file read access (as under 1), but also that any use of
them on the _ handle without read access would invalidate them,
requiring you to use them in a certain order (as suggested). In other
words, you'd have to write quite a bit of potentially confusing
documentation to work around broken behaviour in the first place.

[Jeopardectomy performed]

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Begin at the beginning and go on
Commercial Dynamics Pty. Ltd.   | till you come to the end; then stop.
NSW, Australia                  | 


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

Date: Wed, 6 Sep 2000 22:32:54 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: weird behavior of _ file handle
Message-Id: <slrn8rcar6.ucf.mgjv@martien.heliotrope.home>

On Wed, 6 Sep 2000 22:15:40 +1100,
	Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> 
> 1) perl is adapted to not invalidate the handle on an error that is not
> related to stat information, but to other file accesses. -T  and -B are
> abominations anyway :).

bug report submitted

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Little girls, like butterflies, need
Commercial Dynamics Pty. Ltd.   | no excuse - Lazarus Long
NSW, Australia                  | 


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

Date: Wed, 06 Sep 2000 09:07:25 GMT
From: "Paul Johnston" <johnston.p@worldnet.att.net>
Subject: why does foreach iterate on an undef variable?
Message-Id: <hPnt5.1223$5E3.62197@bgtnsc06-news.ops.worldnet.att.net>

I'm confused as to the logic of why a foreach loop block *is* entered when
the LIST is undef (NOT expected), but *is not* when the LIST is an empty
array (expected behavior):

#==========================
# Case 1: foreach over an empty array results
# in no output (seems normal).
#==========================
print "CASE 1:\n";
# empty list
@array = ();

# iterate list
foreach my $scalar (@array) { print "foo\n"; }

#==========================
# Case 2: foreach over an undef value yields
# a single 'foo' (seems bizarre)
#==========================
print "CASE 2:\n";
# empty list
@array = undef;

# iterate list
foreach my $scalar (@array) { print "foo\n"; }





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

Date: Wed, 06 Sep 2000 09:10:44 GMT
From: "Paul Johnston" <johnston.p@worldnet.att.net>
Subject: Re: why does foreach iterate on an undef variable?
Message-Id: <oSnt5.1229$5E3.61259@bgtnsc06-news.ops.worldnet.att.net>

I think I realized what is happening:  in CASE 2 I'm actually making a list
with one element which is the undef value, so the array actually looks like
( undef ).

Paul Johnston wrote in message ...
>I'm confused as to the logic of why a foreach loop block *is* entered when
>the LIST is undef (NOT expected), but *is not* when the LIST is an empty
>array (expected behavior):
>
>#==========================
># Case 1: foreach over an empty array results
># in no output (seems normal).
>#==========================
>print "CASE 1:\n";
># empty list
>@array = ();
>
># iterate list
>foreach my $scalar (@array) { print "foo\n"; }
>
>#==========================
># Case 2: foreach over an undef value yields
># a single 'foo' (seems bizarre)
>#==========================
>print "CASE 2:\n";
># empty list
>@array = undef;
>
># iterate list
>foreach my $scalar (@array) { print "foo\n"; }
>
>
>




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

Date: Wed, 6 Sep 2000 11:36:54 +0100
From: "Louise Davis" <louise.davis@breathemail.net>
Subject: Re: why does foreach iterate on an undef variable?
Message-Id: <39b61d83$1_1@news1.vip.uk.com>

I'm sure someone will put me right on this if I'm wrong but I think in your
second case, undef is being assigned as the first element of the array and
not undefining the array as a whole.

eg:

@array = 1;
foreach my $scalar (@array) { print "$scalar\n"; }

gives output:
1

use     undef @array;      instead.

Hope this has been some help

Lou


Paul Johnston <johnston.p@worldnet.att.net> wrote in message
news:hPnt5.1223$5E3.62197@bgtnsc06-news.ops.worldnet.att.net...
> I'm confused as to the logic of why a foreach loop block *is* entered when
> the LIST is undef (NOT expected), but *is not* when the LIST is an empty
> array (expected behavior):
>
> #==========================
> # Case 1: foreach over an empty array results
> # in no output (seems normal).
> #==========================
> print "CASE 1:\n";
> # empty list
> @array = ();
>
> # iterate list
> foreach my $scalar (@array) { print "foo\n"; }
>
> #==========================
> # Case 2: foreach over an undef value yields
> # a single 'foo' (seems bizarre)
> #==========================
> print "CASE 2:\n";
> # empty list
> @array = undef;
>
> # iterate list
> foreach my $scalar (@array) { print "foo\n"; }
>
>
>




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

Date: Wed, 6 Sep 2000 21:52:51 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: why does foreach iterate on an undef variable?
Message-Id: <slrn8rc8g3.ucf.mgjv@martien.heliotrope.home>

[reordered post to respect the natural flow of time, which makes it a
bit easier to follow]

On Wed, 06 Sep 2000 09:10:44 GMT,
	Paul Johnston <johnston.p@worldnet.att.net> wrote:
> Paul Johnston wrote in message ...
> >I'm confused as to the logic of why a foreach loop block *is* entered when
> >the LIST is undef (NOT expected), but *is not* when the LIST is an empty
> >array (expected behavior):

I think this is where the confusion starts. A list cannot be undefined,
it can only be empty. People keep spreading this nonsense about
assigning undef to arrays to empty them. it's plainly wrong. Assign the
empty list to empty an array. Apart from that, lists and arrays are not
the same beastie.

A list either has elements, or it's empty.
An array has elements, or it's empty.
A scalar has a value, or it's undefined.

Anything more magical than that you don't need to know at this moment.

> >#==========================
> ># Case 1: foreach over an empty array results
> ># in no output (seems normal).
> >#==========================
> >print "CASE 1:\n";
> ># empty list
> >@array = ();

Assignment of an empty list to an array, resulting in an array with no
elements.

> ># iterate list
> >foreach my $scalar (@array) { print "foo\n"; }

Won't do a thing.

> >#==========================
> ># Case 2: foreach over an undef value yields
> ># a single 'foo' (seems bizarre)
> >#==========================
> >print "CASE 2:\n";
> ># empty list
> >@array = undef;

Assignment of an undefined value to an array, resulting in an array with
one element, with an undefined value.

> ># iterate list
> >foreach my $scalar (@array) { print "foo\n"; }

Will print "foo\n" _and_ a warning, if you use -w. You did, didn't you?

> I think I realized what is happening:  in CASE 2 I'm actually making a list
> with one element which is the undef value, so the array actually looks like
> ( undef ).

That's correct. I'm glad you figured it out. My post is mainly as an
asddition to that. If you now next time test these sorts of things with
_all_ the help Perl gives you (-w flag, the strict pragma), you will
probably figure it out before you need to post :)

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 
Commercial Dynamics Pty. Ltd.   | "Mr Kaplan. Paging Mr Kaplan..."
NSW, Australia                  | 


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

Date: Wed, 6 Sep 2000 22:01:37 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: why does foreach iterate on an undef variable?
Message-Id: <slrn8rc90h.ucf.mgjv@martien.heliotrope.home>

[please, in the future, put your followup text AFTER the text you
respond to. Also, don't respond twice to your own message. Rather: think
the problem through a bit better before posting, so you don't have to
post as much. One followup to yourself is acceptable, two is a bit much]

On Wed, 6 Sep 2000 11:36:54 +0100,
	Louise Davis <louise.davis@breathemail.net> wrote:
[Also see my other reply]
> 
> use     undef @array;      instead.

No, no, no, no!

Use

@array = ();

instead. Don't 'undefine' an array, whatever that should mean. Do what
you mean.

Shouldn't this become an FAQ by now?

[Jeopardectomy performed]

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | I took an IQ test and the results
Commercial Dynamics Pty. Ltd.   | were negative.
NSW, Australia                  | 


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

Date: Wed, 6 Sep 2000 13:44:45 +0100
From: "Louise Davis" <louise.davis@breathemail.net>
Subject: Re: why does foreach iterate on an undef variable?
Message-Id: <39b63b7d$1_2@news2.vip.uk.com>


Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message
news:slrn8rc90h.ucf.mgjv@martien.heliotrope.home...
> [please, in the future, put your followup text AFTER the text you
> respond to. Also, don't respond twice to your own message.

I'll remember that but I don't think I will be posting again - not after
this !

> Rather: think
> the problem through a bit better before posting, so you don't have to
> post as much. One followup to yourself is acceptable, two is a bit much]

Sorry - I don't understand this - I only posted once and this is my only
follow up.

>
> On Wed, 6 Sep 2000 11:36:54 +0100,
> Louise Davis <louise.davis@breathemail.net> wrote:
> [Also see my other reply]
> >
> > use     undef @array;      instead.
>
> No, no, no, no!
>
> Use
>
> @array = ();
>
> instead. Don't 'undefine' an array, whatever that should mean. Do what
> you mean.

That is the terminology used in "Programming Perl 2nd Edition chapter 3.2"
on the use of undef which, according to the book, can be used as a unary
operator on an array. Is there is any reason I shouldn't be using undef in
this way?





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

Date: Wed, 06 Sep 2000 11:45:27 GMT
From: marvin42_98@yahoo.com
Subject: XML::Parser and DTD?
Message-Id: <8p5aok$6s0$1@nnrp1.deja.com>

Hi, i wonder if anyone has example of a xml-parser and DTD?
More specifically i want to read in files in the NITF-format
(http://www.nitf.org/dtd.html),
any code as example would help a lot,

cheers.


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


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