[18938] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1133 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 14 11:10:32 2001

Date: Thu, 14 Jun 2001 08:10:16 -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: <992531416-v10-i1133@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 14 Jun 2001     Volume: 10 Number: 1133

Today's topics:
        initialising multi-dimensional array <m.grimshaw@salford.ac.uk>
    Re: initialising multi-dimensional array <m.grimshaw@salford.ac.uk>
    Re: initialising multi-dimensional array <pne-news-20010614@newton.digitalspace.net>
    Re: initialising multi-dimensional array (Anno Siegel)
    Re: initialising multi-dimensional array <m.grimshaw@salford.ac.uk>
    Re: initialising multi-dimensional array <m.grimshaw@salford.ac.uk>
    Re: Negative lookahead not working <morgan@hahaha.org>
    Re: Perl switch -w (Harri Haataja)
    Re: Premature end of srcipt headers? (David Efflandt)
    Re: Problems with Threads and Signal handlers <arbman@dhmail.net>
    Re: Which C compiler to use for modules? <john.imrie@pa.press.net>
    Re: Win32::OLE Question <keng@spinalfluid.com>
    Re: Win32::OLE Question <bart.lateur@skynet.be>
    Re: Win32::OLE Question (isterin)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 14 Jun 2001 15:13:48 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: initialising multi-dimensional array
Message-Id: <3B28C69C.42AC0CEB@salford.ac.uk>

Hi,

How do I initialise everything in a multi-dimensional array to 0 (or any
variable for that matter)?  Currently, all rows/column elements are
undef.


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

Date: Thu, 14 Jun 2001 15:15:56 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: initialising multi-dimensional array
Message-Id: <3B28C71C.2F995DCD@salford.ac.uk>



Mark Grimshaw wrote:
> 
> Hi,
> 
> How do I initialise everything in a multi-dimensional array to 0 (or any
> variable for that matter)?  Currently, all rows/column elements are
> undef.

Forgot to add, I don't know the number of rows/columns beforehand.


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

Date: Thu, 14 Jun 2001 16:34:06 +0200
From: Philip Newton <pne-news-20010614@newton.digitalspace.net>
Subject: Re: initialising multi-dimensional array
Message-Id: <onihit8nbqut140crtce59qk1ua4m7k94h@4ax.com>

On Thu, 14 Jun 2001 15:15:56 +0100, Mark Grimshaw
<m.grimshaw@salford.ac.uk> wrote:

> Mark Grimshaw wrote:
> > 
> > How do I initialise everything in a multi-dimensional array to 0 (or any
> > variable for that matter)?  Currently, all rows/column elements are
> > undef.
> 
> Forgot to add, I don't know the number of rows/columns beforehand.

How are you going to find out, then?

The "problem" here is that Perl data structures are dynamic; they can be
any length and grow and shrink at run time. So if you always initialise,
say, 10 rows and 30 columns, it might be too much or too little later
on.

So if you don't know at the time of initialisation how many rows and
columns you'll need, you can't do it.

Maybe you can delay the initialisation until you know how many rows and
columns you have? Or initialise each row when you know how many columns
that row will have, if not all rows will have the same number of
columns?

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 14 Jun 2001 14:37:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: initialising multi-dimensional array
Message-Id: <9gai7v$lp2$1@mamenchi.zrz.TU-Berlin.DE>

According to Mark Grimshaw  <m.grimshaw@salford.ac.uk>:
> 
> 
> Mark Grimshaw wrote:
> > 
> > Hi,
> > 
> > How do I initialise everything in a multi-dimensional array to 0 (or any
> > variable for that matter)?  Currently, all rows/column elements are
> > undef.
> 
> Forgot to add, I don't know the number of rows/columns beforehand.

In that case the word "everything" in your question makes no sense.
You can't initialize an array of unknown size.

You should acquaint yourself with the way Perl treats an undefined
value in numeric context, and its interaction with warnings.  You will
probably find you don't have to initialize the array after all.

Anno


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

Date: Thu, 14 Jun 2001 15:47:27 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: initialising multi-dimensional array
Message-Id: <3B28CE7F.B2341D8C@salford.ac.uk>



Philip Newton wrote:
> 
> On Thu, 14 Jun 2001 15:15:56 +0100, Mark Grimshaw
> <m.grimshaw@salford.ac.uk> wrote:
> 
> > Mark Grimshaw wrote:
> > >
> > > How do I initialise everything in a multi-dimensional array to 0 (or any
> > > variable for that matter)?  Currently, all rows/column elements are
> > > undef.
> >
> > Forgot to add, I don't know the number of rows/columns beforehand.
> 
> How are you going to find out, then?

Merely mentioned because this array grows within the script not as a
problem requiring an answer.

> 
> The "problem" here is that Perl data structures are dynamic; they can be
> any length and grow and shrink at run time. So if you always initialise,
> say, 10 rows and 30 columns, it might be too much or too little later
> on.
> 
> So if you don't know at the time of initialisation how many rows and
> columns you'll need, you can't do it.
> 
> Maybe you can delay the initialisation until you know how many rows and
> columns you have? Or initialise each row when you know how many columns
> that row will have, if not all rows will have the same number of
> columns?

I'm currently setting all columns to 0 (if they're undef) _after_ I've
populated (parts of) the array.  It works but is a loop within a loop. 
This being perl, I thought there might be a faster/simpler/more
efficient way to do it.  i.e. something like a special variable (like
the $INPUT_RECORD SEPARATOR - $/) which I can set to 0 meaning that all
unpopulated array elements (that have been skipped during the population
process) will be 0 instead of the default undef.


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

Date: Thu, 14 Jun 2001 15:57:19 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: initialising multi-dimensional array
Message-Id: <3B28D0CF.9878E9B2@salford.ac.uk>



Anno Siegel wrote:
> 
> According to Mark Grimshaw  <m.grimshaw@salford.ac.uk>:
> >
> >
> > Mark Grimshaw wrote:
> > >
> > > Hi,
> > >
> > > How do I initialise everything in a multi-dimensional array to 0 (or any
> > > variable for that matter)?  Currently, all rows/column elements are
> > > undef.
> >
> > Forgot to add, I don't know the number of rows/columns beforehand.
> 
> In that case the word "everything" in your question makes no sense.
> You can't initialize an array of unknown size.
> 
> You should acquaint yourself with the way Perl treats an undefined
> value in numeric context, and its interaction with warnings.  You will
> probably find you don't have to initialize the array after all.
> 
> Anno

It's not exactly a numeric context.  I simply print the element value
back to a browser.  If it's undef it prints nothing.  I want it to print
0.  I can do this one of several ways but it's likely to involve a loop
(or loop within that) hunting out and checking each element for undef.

I was wondering if there was a special variable to do this for me as
mentioned in my 3rd post.

Perhaps I shouldn't have used the words 'initialise everything' but the
words 'override the default undef setting for empty array slots'.


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

Date: Thu, 14 Jun 2001 14:53:41 GMT
From: Morgan Fletcher <morgan@hahaha.org>
Subject: Re: Negative lookahead not working
Message-Id: <87snh3ru2x.fsf@hahaha.org>

"Peter Søgaard" <peter.sogaard@tjgroup.com> writes:
> > I'm printing lines from a file, some of which look like this:
> >
> > @thing \w*XYZ
> >
> > And some look like this:
> >
> > @thing \w*
> >
> > (without "XYZ" at the end)
> >
> > I want to print every line but those that look like @thing \w*, i.e. those
> > without the XYZ on the end.
> >
> > I tried:
> >
> > print unless /\@thing\s+\w*(?!XYZ)/;
> 
> What are you trying to do with \w* ? Match zero or more word(\w)-characters?
> or a word character followed by a * ?
> In the first case it should be /\@thing\s+\w*?(?!XYZ)/;
> The other case should be /\@thing\s+\w\*(?!XYZ)/;

That was a typo, I meant to type print unless /\@thing\s+\w+(?!XYZ)/;

If I change it to be print unless /\@thing\s\w*?(?!XYZ)/; I get all @thing
lines, with and without XYZ at the end.

Here is a more literal set of examples:

/* ********************************************************************** */
/*                                                                        */
/*                           Text goes here                               */
/*                                                                        */
/* ********************************************************************** */

@thing  mSysErrGeneral
@thing  mNumErrXYZ
@thing mSysErrWrongKey
@thing mNoRespXYZ

I'd want everything but the mSysErrGeneral an mSysErrWrongKey lines
printed. Some of those pairs are separated by tabs, not spaces.

morgan


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

Date: Thu, 14 Jun 2001 10:36:48 GMT
From: harri@haataja.net (Harri Haataja)
Subject: Re: Perl switch -w
Message-Id: <slrn9ih4h3.moq.harri@tolppa.kotisivupalvelu.fi>

DJ wrote:
>I have been playing --- testing some perl scripts. In response to
>receiving an Internal Server Error, I added the -w.  I expected to see
>warning messages in the log file, but the script would still fail. I
>did see a warning message in the log, but I was surprised because the
>script worked.  If I removed the -w, it did not, if I added it, it
>did.

I've seen this happen with files that have CRLF ending on unixen.
The CR apparently ends up in the filename in the shebang path. Somehow
it doesn't matter after the -w (which is left for /usr/bin/perl to
handle and not the loader anyway).

So run it thru tr or perl =) and remove \r(?)'s and see if it gets better.

(The literal error in errorlog should be "file not found" in this case
because /usr/bin/perl^M or such is not found.)


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

Date: Thu, 14 Jun 2001 11:43:12 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: Premature end of srcipt headers?
Message-Id: <slrn9ih8qg.5ch.see-sig@typhoon.xnet.com>

On Wed, 13 Jun 2001, Jason Mrdeza <mrdeza@phys.ucalgary.ca> wrote:
> I am recieving an error of premature scripture heading every time I
> attempt to run a cgi script written in perl. Now I have tried returning
> a number of different headers, for example..
> 
>                 print "Location: data1.html \n \n";

This has nothing at all to do with Perl.

HTTP headers end with the first blank line (a space may look blank, but is
not), so premature end means that your headers never end.  Also do you
really have a file there called "data1.html " (space at end of filename)?  
Get rid of the extra spaces and it might work:

print "Location: data1.html\n\n";

-- 
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Thu, 14 Jun 2001 14:59:56 +0200
From: Scott Rutherford <arbman@dhmail.net>
Subject: Re: Problems with Threads and Signal handlers
Message-Id: <3B28B54C.C2D4E632@dhmail.net>

Dan Sugalski wrote:

>
>
> Well, the best you can do is read the thread docs for the platforms
> you're working on. Most Unices conform fully to the POSIX thread
> standard at this point (assuming a recent version of them, of
> course) and their docs normally mention where they don't. Non-unix
> platforms might be a bit trickier, but for signals it's not a big
> deal, as signals are a unix thing anyway.
>
>                                         Dan

Ok, I tried the Thread::Signal module but I didn't seem to get anywhere,
but I figure that trying to combine forking, signals and threads is probably

unnecessary and certainly painful. So I've opted for a fully threaded
approach.

However whatever the situation I couldn't get Thread::Signal to work infact
non of
the scripts containing

use Thread::Signal

wouldn't even run!!!
So anyway I don't suppose you have any experience with Threads and LWP,
I know there is this FileGet module that allows multipe downloads but it's
not what I
want. I have altered LWP to take care of the global filehandles, but I still
get random
segmentation errors. Presumably sychronisation issues.
I know I could trawl through it all, or rewrite most of it from a pure
sockets point
of view to be Thread safe, (seems a  shame) but any pointers
to speed that process up would be much appreciated.

Cheers Scott




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

Date: Thu, 14 Jun 2001 14:42:36 +0100
From: "John Imrie" <john.imrie@pa.press.net>
Subject: Re: Which C compiler to use for modules?
Message-Id: <Gc3W6.1421$h45.8569@news.uk.colt.net>


Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
news:3B27C7F0.45A299D4@stomp.stomp.tokyo...
> isterin wrote:
>
> (topic is compiling modules for Win 32)
>
> > On Windows you should have ActiveState and install binary packages
> > through ppm utility that comes with it.  If you ever need to compile a
> > module that is not  available through activestate binaries, you must
> > use VC++, because this is what ActiveState perl is compiled with.  You
> > must compile all packages with the same compiler that you perl was
> > compiled with.
>

If you are going to get the free compiler talked about in this thread then
the first thing you need to do is get the Perl source code and compile it
with your program.

The source will compile for unix and windose




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

Date: Thu, 14 Jun 2001 18:33:14 +0800
From: "keng" <keng@spinalfluid.com>
Subject: Re: Win32::OLE Question
Message-Id: <9ga3rt$eni$1@coco.singnet.com.sg>

thanks homer :)

but i encountered the error
"can't call method "workbooks" on unblessed reference at perlex.pl line 8"

have you encountered this before?
or can you tell me how to debug this?

thanks in advance

regards
isaac


--
regards
isaac
"Homer Simpson" <Homer.Simpson@mindspring.con> wrote in message
news:9g6ta3$nnq$1@216.39.134.39...
> There's nothing wrong (except the # sign which I'm sure you know <G>) with
the
> bit you show here.
>
> Test using the sample code from Microsoft's website
> http://support.microsoft.com/support/kb/articles/Q214/7/97.asp
>
> Which should run fine...
> If it doesn't you have something wrong with Excel and need to troubleshoot
> that.  A quick reinstall/repair using Add/Remove programs should correct
> things.
>
>
> In article <9g4q7k$j81$1@violet.singnet.com.sg>, "keng"
<keng@spinalfluid.com>
> wrote:
> >my script as below
> >
> >use Win32::OLE;
> >#can work
> >$ex = Win32::OLE->new('Word.Application') or die "oops\n";
> >$ex->{Visible}=1;
> >
> >#cannot work
> >#$ex = Win32::OLE->new('Excel.Application') or die "oops\n";
> >#$ex->{Visible}=1;
> >




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

Date: Thu, 14 Jun 2001 11:24:24 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Win32::OLE Question
Message-Id: <2k7hit0h5u4cnmorvnq1q0u9k3ovhik1mk@4ax.com>

keng wrote:

>but i encountered the error
>"can't call method "workbooks" on unblessed reference at perlex.pl line 8"

That means that one of your lines, which is expected to return a
(blessed) reference, returned undef instead. Putting "or die" second
statement halfs in each of those assignments, that should tell you which
one failed. Win32::OLE->LastError() can give you a more detailed error
message.

-- 
	Bart.


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

Date: 14 Jun 2001 07:01:30 -0700
From: isterin@hotmail.com (isterin)
Subject: Re: Win32::OLE Question
Message-Id: <db67a7f3.0106140601.485013e2@posting.google.com>

"keng" <keng@spinalfluid.com> wrote in message news:<9ga3rt$eni$1@coco.singnet.com.sg>...
> thanks homer :)
> 
> but i encountered the error
> "can't call method "workbooks" on unblessed reference at perlex.pl line 8"

Means exactly that.  You are trying to call the method workbooks on an
object that either failed to initialize or was never initialized in
the first place.


> 
> have you encountered this before?
> or can you tell me how to debug this?

Print out the object and see if it points to something.

Ilya


> 
> thanks in advance
> 
> regards
> isaac
> 
> 
> --
> regards
> isaac
> "Homer Simpson" <Homer.Simpson@mindspring.con> wrote in message
> news:9g6ta3$nnq$1@216.39.134.39...
> > There's nothing wrong (except the # sign which I'm sure you know <G>) with
>  the
> > bit you show here.
> >
> > Test using the sample code from Microsoft's website
> > http://support.microsoft.com/support/kb/articles/Q214/7/97.asp
> >
> > Which should run fine...
> > If it doesn't you have something wrong with Excel and need to troubleshoot
> > that.  A quick reinstall/repair using Add/Remove programs should correct
> > things.
> >
> >
> > In article <9g4q7k$j81$1@violet.singnet.com.sg>, "keng"
>  <keng@spinalfluid.com>
> > wrote:
> > >my script as below
> > >
> > >use Win32::OLE;
> > >#can work
> > >$ex = Win32::OLE->new('Word.Application') or die "oops\n";
> > >$ex->{Visible}=1;
> > >
> > >#cannot work
> > >#$ex = Win32::OLE->new('Excel.Application') or die "oops\n";
> > >#$ex->{Visible}=1;
> > >


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

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.  

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


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