[17811] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5231 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 4 16:56:21 2001

Date: Thu, 4 Jan 2001 13:56:03 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <978645362-v9-i5231@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 4 Jan 2001     Volume: 9 Number: 5231

Today's topics:
        Help with syntax of tokens for Parse::Lex (Stan Brown)
    Re: Help with syntax of tokens for Parse::Lex (Colin Watson)
    Re: Help with syntax of tokens for Parse::Lex (Stan Brown)
        How do You attach a file from a web form and email it?  <dradulescu@carolina.rr.com>
        How to exclude a character being substituted? lynton@iname.com
    Re: How to exclude a character being substituted? <montuori@arrakisplanet.com>
    Re: How to exclude a character being substituted? (Tad McClellan)
        how to parse multi lines into array variable <berndt.zeitler@tu-berlin.de>
    Re: how to parse multi lines into array variable (Rafael Garcia-Suarez)
    Re: how to parse multi lines into array variable (Tad McClellan)
        How to post an message in an newsgroup with Perl? <f.boerefijn@sententia.nl>
    Re: How to post an message in an newsgroup with Perl? (Richard Zilavec)
        how to send html mail <jramberg@looksmart.net>
        INDEPENDENT EXEC WIN32 <angenent@kabelfoon.nl>
    Re: INDEPENDENT EXEC WIN32 <Hans.de.Bruin@chello.nl>
    Re: INDEPENDENT EXEC WIN32 (Martien Verbruggen)
    Re: INDEPENDENT EXEC WIN32 <jhelman@wsb.com>
        Installing dbi dbd on linux ljunquera@my-deja.com
    Re: Instance vars in an object - Solved <rudymoore@hotmail.com>
    Re: Instance vars in an object - Solved (Tad McClellan)
    Re: Instance vars in an object - Solved <rudymoore@hotmail.com>
        Instance vars in an object <rudymoore@hotmail.com>
    Re: Instance vars in an object (Tad McClellan)
        Is it possible to parse a spreadsheet on a unix machine <wstsoi@netvigator.com>
    Re: Is it possible to parse a spreadsheet on a unix mac rbfitzpa@my-deja.com
    Re: Is it possible to parse a spreadsheet on a unix mac (Abigail)
    Re: Is it possible to parse a spreadsheet on a unix mac <mjcarman@home.com>
    Re: Is it possible to parse a spreadsheet on a unix mac <joe+usenet@sunstarsys.com>
    Re: Is it possible to parse a spreadsheet on a unix mac <mischief@velma.motion.net>
    Re: Is it possible to parse a spreadsheet on a unix mac <peter.sundstrom@eds.com>
    Re: Is it possible to parse a spreadsheet on a unix mac (Ben Okopnik)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 31 Dec 2000 09:53:30 -0500
From: stanb@panix.com (Stan Brown)
Subject: Help with syntax of tokens for Parse::Lex
Message-Id: <92nh9a$t12$1@panix3.panix.com>

I am trying to set up to use the Pasre:Lex module to scan a stream of
incoming characters. I sort of have it working but I need to declare a
regex for a patter tnat contains a space, and nothing I am doing seems to
work.

Could some kind soul educate me ont e proper syntax?

Heres is what I have:

$lexer = Parse::Lex->new (
          qw(
	DATE ^\d+-\d+-\d+
	TIME \d+:\d+:\d+
	REMAINDER .+
			 ));


Which works fine, but I really need to declare soemthing like:

	DATETIME ^\d+-\d+-\d+ \d+:\d+:\d+

But that creates a runtime error in Parse::Lex, so I must be doing
something wrong.

How can I make this work?


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

Date: 31 Dec 2000 17:31:58 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: Help with syntax of tokens for Parse::Lex
Message-Id: <92nqie$ph6$1@riva.ucam.org>

Stan Brown <stanb@panix.com> wrote:
>Heres is what I have:
>
>$lexer = Parse::Lex->new (
>          qw(
>	DATE ^\d+-\d+-\d+
>	TIME \d+:\d+:\d+
>	REMAINDER .+
>			 ));
>
>Which works fine, but I really need to declare soemthing like:
>
>	DATETIME ^\d+-\d+-\d+ \d+:\d+:\d+
>
>But that creates a runtime error in Parse::Lex, so I must be doing
>something wrong.

It's actually qw() that's getting confused when you do that. Since it
splits on spaces rather than newlines, you can see where the difficulty
arises. You could try writing the list out by hand:

my $lexer = Parse::Lex->new (
        DATETIME  => '^\d+-\d+-\d+ \d+:\d+:\d+',
        REMAINDER => '.+',
);

Notes: I don't have the Parse::Lex module handy, so I haven't tested
this. If the left-hand side of each pair isn't a single word (hyphens
are a frequent culprit) then you'll need to quote that too.

-- 
Colin Watson                                     [cjw44@flatline.org.uk]
"It's always September, *somewhere* on the net ..."


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

Date: 31 Dec 2000 16:25:33 -0500
From: stanb@panix.com (Stan Brown)
Subject: Re: Help with syntax of tokens for Parse::Lex
Message-Id: <92o88d$p3l$1@panix3.panix.com>

In <92nqie$ph6$1@riva.ucam.org> cjw44@flatline.org.uk (Colin Watson) writes:

>Stan Brown <stanb@panix.com> wrote:
>>Heres is what I have:
>>
>>$lexer = Parse::Lex->new (
>>          qw(
>>	DATE ^\d+-\d+-\d+
>>	TIME \d+:\d+:\d+
>>	REMAINDER .+
>>			 ));
>>
>>Which works fine, but I really need to declare soemthing like:
>>
>>	DATETIME ^\d+-\d+-\d+ \d+:\d+:\d+
>>
>>But that creates a runtime error in Parse::Lex, so I must be doing
>>something wrong.

>It's actually qw() that's getting confused when you do that. Since it
>splits on spaces rather than newlines, you can see where the difficulty
>arises. You could try writing the list out by hand:

>my $lexer = Parse::Lex->new (
>        DATETIME  => '^\d+-\d+-\d+ \d+:\d+:\d+',
>        REMAINDER => '.+',
>);

>Notes: I don't have the Parse::Lex module handy, so I haven't tested
>this. If the left-hand side of each pair isn't a single word (hyphens
>are a frequent culprit) then you'll need to quote that too.

	Ah, thnaks for educating me.


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

Date: Thu, 04 Jan 2001 16:39:06 GMT
From: "Daniel Radulescu" <dradulescu@carolina.rr.com>
Subject: How do You attach a file from a web form and email it? 
Message-Id: <KG156.196524$4K4.31551340@typhoon.southeast.rr.com>

Help Please!!!! Does any kind soul have a script that would allow a user to
hit a website and possibly using the <INPUT TYPE="file"....> tag to browse
and attach a file, then have it sent via perl t an email address as an
atachment? I have been looking for a couple of days now... and no luck.
Please help!!!  Thanks so much!

Daniel R.




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

Date: Fri, 29 Dec 2000 18:28:35 GMT
From: lynton@iname.com
Subject: How to exclude a character being substituted?
Message-Id: <92il4a$nte$1@nnrp1.deja.com>

s/\W+/_/g;
This substitutes all 'special characters'.
How to modify it so - (hypen) character is not substituted?

I did read the regex faq at perl.com and can solve most regex problems
but this seemingly simple one baffles me. Thank you for any help.


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 29 Dec 2000 13:49:49 -0500
From: kevin montuori <montuori@arrakisplanet.com>
Subject: Re: How to exclude a character being substituted?
Message-Id: <ydypuibnjul.fsf@kulon.arrakisplanet.com>

>>> lynton  writes:

  l> s/\W+/_/g; This substitutes all 'special characters'.  How to
  l> modify it so - (hypen) character is not substituted?

        s/[^\w-]+/_/g

     cheers,
     k.


-- 
kevin montuori

support independent booksellers -- http://www.booksense.com



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

Date: Fri, 29 Dec 2000 12:08:31 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How to exclude a character being substituted?
Message-Id: <slrn94ph8f.vv.tadmc@magna.metronet.com>

lynton@iname.com <lynton@iname.com> wrote:

>s/\W+/_/g;

>How to modify it so - (hypen) character is not substituted?


    s/[^\w-]+/_/g;


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


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

Date: Thu, 4 Jan 2001 11:31:14 +0100
From: "berndt zeitler" <berndt.zeitler@tu-berlin.de>
Subject: how to parse multi lines into array variable
Message-Id: <931j13$t4n$1@mamenchi.zrz.TU-Berlin.DE>

happy new year!

i'm quite new to perl and am wondering if there is an easy way to assign a
multi line text to an array variable. to explain better here is an example
of what i want to do.

i have a file "parse_text.txt" that looks like this:

# some comments
<title>this is the title of the paper</title>
<body>this is a multi
line abstract that
i would like to
have in a variable </body>

<title>this is the title of a second paper</title>
<body>this is another multi
line abstract that
i would like to
have in a variable </body>


the tags <title></title> and <body></body> can be anything else too.
i got it to work for the single line titles with:

$first1 = '<title>';
$last1 = '</title>';
$test_file = "parse_text.txt";

$i = 0;

open(TESTFILE,"$test_file") || die "can't open $test_file";

while (<TESTFILE>) { if (!/^#/){
  if (/$first1(.*)$last1/){
  $titles[$i] = $1;
  $i++;}
} }

print "$titles[0]\n$titles[1]";

is there as easy a way for the multi line bodies too.

thanks a lot in advance.
ciao for now,
berndt




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

Date: Thu, 04 Jan 2001 10:44:43 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: how to parse multi lines into array variable
Message-Id: <slrn958l0v.bol.rgarciasuarez@rafael.kazibao.net>

berndt zeitler wrote in comp.lang.perl.misc:
> happy new year!
> 
> i'm quite new to perl and am wondering if there is an easy way to assign a
> multi line text to an array variable. to explain better here is an example
> of what i want to do.
> 
> i have a file "parse_text.txt" that looks like this:
> 
> # some comments
> <title>this is the title of the paper</title>
> <body>this is a multi
> line abstract that
> i would like to
> have in a variable </body>
> 
> <title>this is the title of a second paper</title>
> <body>this is another multi
> line abstract that
> i would like to
> have in a variable </body>
> 
> 
> the tags <title></title> and <body></body> can be anything else too.

If your files will always be as simple as that, you can use the
flip-flop operator as in the following example (described in the perlop
manual page):

  my @lines_title = ();
  my @lines_body = ();
  while (<FILE>) {
    push @lines_title, $_ if /<title>/ .. /<\/title>/;
    push @lines_body, $_ if /<body>/ .. /<\/body>/;
  }

You should then remove the </?\w+> tags.
An improvement would be to use a hash %lines that contains references to
arrays of lines ($lines{body} and $lines{title}).

For anything more complex, (nested tags, tags in the middle of a line),
it's probably better to use a parser module such as XML::Parser.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Thu, 4 Jan 2001 09:35:19 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how to parse multi lines into array variable
Message-Id: <slrn9592h7.mil.tadmc@magna.metronet.com>

berndt zeitler <berndt.zeitler@tu-berlin.de> wrote:
>
>wondering if there is an easy way to assign a
>multi line text to an array variable.

>i have a file "parse_text.txt" that looks like this:
>
># some comments
><title>this is the title of the paper</title>
><body>this is a multi
>line abstract that
>i would like to
>have in a variable </body>
>
><title>this is the title of a second paper</title>
><body>this is another multi
>line abstract that
>i would like to
>have in a variable </body>
>
>
>the tags <title></title> and <body></body> can be anything else too.


That part may be a problem.


>i got it to work for the single line titles with:
>
>$first1 = '<title>';
>$last1 = '</title>';
>$test_file = "parse_text.txt";
>
>$i = 0;
>
>open(TESTFILE,"$test_file") || die "can't open $test_file";
>
>while (<TESTFILE>) { if (!/^#/){
>  if (/$first1(.*)$last1/){
>  $titles[$i] = $1;
>  $i++;}
>} }
>
>print "$titles[0]\n$titles[1]";
>
>is there as easy a way for the multi line bodies too.


If your data is a simple as shown above, you can read a "record"
at a time instead of a "line" at a time by using the $/ variable
(described in perlvar.pod):


{ local $/ = "</body>\n";

  while (<TESTFILE>) {
     # do stuff with multiline record in $_
  }
}


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


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

Date: Tue, 02 Jan 2001 23:30:43 +0100
From: Frans Boerefijn <f.boerefijn@sententia.nl>
Subject: How to post an message in an newsgroup with Perl?
Message-Id: <3A525693.DECA472A@sententia.nl>

Hi there,

We want to post automatically via cron, messages in our intranet
newsgroup. The script should read the message from an file. The first
line in the file is the subject, the rest of the file is the body of the
message. the news server is news.in-nederland.com. The news group is
"dagaanbieding.in-nederland".

I know that I can use Net::NNTP for this, but i'm looking for an example
of how to use it.

Can someone redirect me to an example or maybe provide me with an
working example from another site.

Thanks in advance,

Frans.






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

Date: Tue, 02 Jan 2001 23:17:11 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: How to post an message in an newsgroup with Perl?
Message-Id: <3a5360cb.4471700@news.tcn.net>

On Tue, 02 Jan 2001 23:30:43 +0100, Frans Boerefijn
<f.boerefijn@sententia.nl> wrote:

>I know that I can use Net::NNTP for this, but i'm looking for an example
>of how to use it.

What have tried so far?

>Can someone redirect me to an example or maybe provide me with an
>working example from another site.

perldoc News::NNTPClient

This contains examples...  

--
 Richard Zilavec
 rzilavec@tcn.net


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

Date: Wed, 03 Jan 2001 21:11:16 -0800
From: Jim Ramberg <jramberg@looksmart.net>
Subject: how to send html mail
Message-Id: <3A5405F4.856B75B0@looksmart.net>

I have perl program that outputs html. I want to be able to mail this
out to people and to have the content type register correctly as
HTML so that the HTML will be rendered.

I have tried using the Mail:Send module and I have yet to get the syntax
correct such that the resulting mail has the correct content-type
header.


I would appreciate if someone can show me the correct syntax.
#!/usr/bin/perl

$rec='jramberg@nospammailmail.looksmart.net';
@output=`/home/jramberg/qa/logtools_frozen/doweberrs_test.sh`;

require Mail::Send;

         $msg = new Mail::Send;
         $msg->to($rec);
         $msg->subject($subject);
         $msg->add("Content-Type","text/html; charset=ISO-8859-1");

# Launch mailer and set headers. The filehandle returned
# by open() is an instance of the Mail::Mailer class.

         $fh = $msg->open;

         print $fh @output;

         $fh->close;         # complete the message and send it

Thanks
Jim




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

Date: Tue, 2 Jan 2001 18:28:23 -0800
From: "GOGAR" <angenent@kabelfoon.nl>
Subject: INDEPENDENT EXEC WIN32
Message-Id: <92t30i$1eh9$1@news.kabelfoon.nl>

Anybody knows how to execute a series of applications from perl

something like this

for (0 .. 10){
exec("perl somescript.pl");
}

i was hoping it would i could open the scripts in seperate windows running
independently
but it doesn't seem to work..  each script runs after another and the parent
script gets halted while the childs run
isn't there any way around this problem?






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

Date: Tue, 02 Jan 2001 19:16:09 GMT
From: "Hans de Bruin" <Hans.de.Bruin@chello.nl>
Subject: Re: INDEPENDENT EXEC WIN32
Message-Id: <ZNp46.360562$%C1.4345544@Flipper>


"GOGAR" <angenent@kabelfoon.nl> wrote in message
news:92t30i$1eh9$1@news.kabelfoon.nl...
> Anybody knows how to execute a series of applications from perl
>
> something like this
>
> for (0 .. 10){
 exec("cmd.exe /c start perl somescript.pl");
> }
>

try start/? for more info

Hans




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

Date: Wed, 3 Jan 2001 09:52:56 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: INDEPENDENT EXEC WIN32
Message-Id: <slrn954mu8.edk.mgjv@martien.heliotrope.home>

On Tue, 02 Jan 2001 19:16:09 GMT,
	Hans de Bruin <Hans.de.Bruin@chello.nl> wrote:
> 
> "GOGAR" <angenent@kabelfoon.nl> wrote in message
> news:92t30i$1eh9$1@news.kabelfoon.nl...
>> Anybody knows how to execute a series of applications from perl
>>
>> something like this
>>
>> for (0 .. 10){
>  exec("cmd.exe /c start perl somescript.pl");
>> }

Can anyone explain what happens to the original running program during
the first iteration of the loop, more precisely, when the first exec()
gets executed? [1]

To the OP:

You need to be more specific about what you want, but before asking
again, read the entries for exec and system in the perlfunc
documentation, and the entry for qx// (or backticks) in the perlop
documentation. Once you have done that, you may also want to read about
fork (in perlfunc), and since you're on win32, the perlfork
documentation.

Together, those texts would most certainly be able to tell you what to
do. If you have problems implementing it all, post again, and include
code with what you have tried until then.

Martien

[1] Read the documentation for the exec() function, in perfunc, to find
out why the above will not work:

       exec LIST
       exec PROGRAM LIST
               The "exec" function executes a system command and
               never returns-- use "system" instead of "exec" if
               you want it to return.  

In the original the phrase 'and never returns' is emphasised. 

-- 
Martien Verbruggen              | 
Interactive Media Division      | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd.   | make up 3/4 of the population.
NSW, Australia                  | 


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

Date: Wed, 03 Jan 2001 01:47:29 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: INDEPENDENT EXEC WIN32
Message-Id: <d2155to6kc2c2qkadnnu3nhjd2kvak5oo4@4ax.com>

On Tue, 2 Jan 2001 18:28:23 -0800, "GOGAR" <angenent@kabelfoon.nl>
wrote:

>Anybody knows how to execute a series of applications from perl

Under Win32 (or, at least under NT -- I can't vouch for Win9x or 2000,
but I would assume that this would work under them as well), use the
Win32::Process module.  To launch your multiple apps, just use the
Win32::Process::Spawn method, which you can then choose to wait on,
suspend, etc.

Hope this helps,
JH



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

Date: Thu, 04 Jan 2001 16:23:26 GMT
From: ljunquera@my-deja.com
Subject: Installing dbi dbd on linux
Message-Id: <93281i$fsu$1@nnrp1.deja.com>

Does anybody know where I can find a step by step guide to installing
dbi and dbd for oracle on linux red hat 6+.

Thanks,
Leo


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 29 Dec 2000 22:24:44 -0800
From: Rudy Moore <rudymoore@hotmail.com>
Subject: Re: Instance vars in an object - Solved
Message-Id: <MPG.14b71f8694793130989696@news.megapath.net>


Tad,

Thanks for your help, you were right.  Sorry about the paraphrased error 
messages, I just assumed I wasn't declaring my vars correctly and 
thought the error msgs would therefore be useless to you.

Thanks for the `testArray => []` tip as well as the `perldiag.pod` tip!

I'll watch those spaces!

Rudy

In article <slrn94qive.2e3.tadmc@magna.metronet.com>, tadmc@metronet.com 
says...
> Rudy Moore <rudymoore@hotmail.com> wrote:
> >
> >I'm new to perl.  I created an object (called 'deck') with instance 
> >variables $index and @cards.
> >
> 
> >I soon found out that every instance of the Deck class shares these same 
> >variables! 
> 
> >Question: How do I create an array instance variable for my package?  I 
> >have tried a few things, let me share my latest:
> 
> 
> You already know how (I peeked ahead).
> 
> 
> >sub new() {
>         ^^
> >     my $proto = shift;
>                   ^^^^^
> 
> 
> You have a no-arg prototype, and then try to shift args...
> 
> 
> >     my @cards;
> >     my $self  = {index=>0, testArray=>\@cards};
> 
> That looks fine to me.
> 
>       my $self  = {index => 0, testArray => [] };
> 
> should work too, without a temporary array.
> 
> Space characters are not a scarce resource, feel free to use
> as many as you like to make your code easier to read.
> 
> >push(@{$self->{testArray}}, $card);
> >
> >That doesn't work. (undefined value, modification of non-creatable 
> >array, etc.)  What's up?
> 
> 
> I dunno. And paraphrased messages are useless, just cut and paste
> the real messages into your post.
> 
> Have you looked up the messages in perldiag.pod?
> 
> There is something you are not telling us.
> 


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

Date: Sat, 30 Dec 2000 07:00:26 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Instance vars in an object - Solved
Message-Id: <slrn94rjiq.36l.tadmc@magna.metronet.com>

Rudy Moore <rudymoore@hotmail.com> wrote:
>
>Tad,
>
>Thanks for your help, you were right.  Sorry about the paraphrased error 
>messages, I just assumed I wasn't declaring my vars correctly and 
>thought the error msgs would therefore be useless to you.


The verbatim text of messages is never useless in diagnosing
problems (given good decisions by the language implementor(s)).


>Thanks for the `testArray => []` tip as well as the `perldiag.pod` tip!


You are welcome.

I ask that you do something for me in return.

Please put your comments *following* the quoted text that you
are commenting on.

Please do not quote an entire article, trim stuff that is not
needed to establish the context for your comments.

For more information on how to properly followup to a Usenet post, see:

   http://www.geocities.com/nnqweb/nquote.html


Thanks.



[ snip 50 lines of Jeopardy-quoted text ]


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


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

Date: Sat, 30 Dec 2000 09:42:06 -0800
From: Rudy Moore <rudymoore@hotmail.com>
Subject: Re: Instance vars in an object - Solved
Message-Id: <MPG.14b7be2ee72bddb0989698@news.megapath.net>

In article <slrn94rjiq.36l.tadmc@magna.metronet.com>, tadmc@metronet.com 
says...
> Please do not quote an entire article, trim stuff that is not
> needed to establish the context for your comments.
> 

Sounds good.  I know realize that I forgot to post what I was originally 
doing wrong:  I was calling a member function load() from within my 
constructor.  load(), just like all my other member functions, was 
expecting $self to be stored in $_[0], which it wasn't, because of the 
way I called load().

Rudy


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

Date: Fri, 29 Dec 2000 20:08:31 -0800
From: Rudy Moore <rudymoore@hotmail.com>
Subject: Instance vars in an object
Message-Id: <MPG.14b6ff9bcfe189d989695@news.megapath.net>

Hi all,

I'm new to perl.  I created an object (called 'deck') with instance 
variables $index and @cards.

I originally declared it like so:

package Deck;
my $index;
my @cards;
sub new() {
 .
 . 
 . 

I soon found out that every instance of the Deck class shares these same 
variables!  So I moved to this implementation (promising to only 
instanciate one Deck and saving the array for later):

package Deck;
my @cards
sub new() {
     my $proto = shift;
     my $class = ref($proto) || $proto;
     my $self  = {index=>0};
     bless ($self, $class);
     load();
     return $self;
}

Worked great!  Of course, now to reference index I use:
sub test() {
	my $self=$_[0];
	$self->{index}=1;
}

-----
Question: How do I create an array instance variable for my package?  I 
have tried a few things, let me share my latest:
-----

sub new() {
     my $proto = shift;
     my $class = ref($proto) || $proto;
     my @cards;
     my $self  = {index=>0, testArray=>\@cards};
     bless ($self, $class);
     load();
     return $self;
}

 ... 
push(@{$self->{testArray}}, $card);
 ...

That doesn't work. (undefined value, modification of non-creatable 
array, etc.)  What's up?

Thanks for your help!

Rudy


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

Date: Fri, 29 Dec 2000 21:43:58 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Instance vars in an object
Message-Id: <slrn94qive.2e3.tadmc@magna.metronet.com>

Rudy Moore <rudymoore@hotmail.com> wrote:
>
>I'm new to perl.  I created an object (called 'deck') with instance 
>variables $index and @cards.
>

>I soon found out that every instance of the Deck class shares these same 
>variables! 

>Question: How do I create an array instance variable for my package?  I 
>have tried a few things, let me share my latest:


You already know how (I peeked ahead).


>sub new() {
        ^^
>     my $proto = shift;
                  ^^^^^


You have a no-arg prototype, and then try to shift args...


>     my @cards;
>     my $self  = {index=>0, testArray=>\@cards};

That looks fine to me.

      my $self  = {index => 0, testArray => [] };

should work too, without a temporary array.

Space characters are not a scarce resource, feel free to use
as many as you like to make your code easier to read.

>push(@{$self->{testArray}}, $card);
>
>That doesn't work. (undefined value, modification of non-creatable 
>array, etc.)  What's up?


I dunno. And paraphrased messages are useless, just cut and paste
the real messages into your post.

Have you looked up the messages in perldiag.pod?

There is something you are not telling us.

------------------------
#!/usr/bin/perl -w
use strict;

sub new {
     my $proto = shift;
     my $class = ref($proto) || $proto;
     my @cards;
     my $self  = {index=>0, testArray=>\@cards};
     bless ($self, $class);
     return $self;
}

my $obj = new('OBJ');
my $card = 'card value';
push(@{$obj->{testArray}}, $card);

print "@{$obj->{testArray}}\n";
------------------------

Works fine for me...


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


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

Date: Thu, 4 Jan 2001 03:01:56 +0800
From: "Lucas" <wstsoi@netvigator.com>
Subject: Is it possible to parse a spreadsheet on a unix machine?
Message-Id: <92vsb1$co84@imsp212.netvigator.com>

Hi all,

Is it possible to parse a excel file on a unix machine?

Thanks a lot




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

Date: Wed, 03 Jan 2001 19:25:14 GMT
From: rbfitzpa@my-deja.com
Subject: Re: Is it possible to parse a spreadsheet on a unix machine?
Message-Id: <92vuae$j3l$1@nnrp1.deja.com>

Simple, piece of cake. I can tell you 5 different ways to do it
depending on how you want the resulting file.

Any of the following can do it for you:
sed
awk
perl
c
vi

Just make sure you 'delimit' your file with something unique (csv -
comma delimited usually does the trick).

It is also helpful to learn 'Regular Expressions', pick up the OReilly
book on awk.


In article <92vsb1$co84@imsp212.netvigator.com>,
  "Lucas" <wstsoi@netvigator.com> wrote:
> Hi all,
>
> Is it possible to parse a excel file on a unix machine?
>
> Thanks a lot
>
>


Sent via Deja.com
http://www.deja.com/


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

Date: 3 Jan 2001 20:10:47 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Is it possible to parse a spreadsheet on a unix machine?
Message-Id: <slrn9571q7.nmu.abigail@tsathoggua.rlyeh.net>

Lucas (wstsoi@netvigator.com) wrote on MMDCLXXXII September MCMXCIII in
<URL:news:92vsb1$co84@imsp212.netvigator.com>:
}} Hi all,
}} 
}} Is it possible to parse a excel file on a unix machine?


Of course. You'd think electrons generated by MS are incompatible with
UNIX machines?



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: Wed, 03 Jan 2001 14:42:49 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Is it possible to parse a spreadsheet on a unix machine?
Message-Id: <3A538EC9.DD2E7C69@home.com>

Abigail wrote:
> 
> Lucas wrote:
> }}
> }} Is it possible to parse a excel file on a unix machine?
> 
> Of course. You'd think electrons generated by MS are incompatible with
> UNIX machines?

I've no doubt that M$ would do just that if they could only figure out
how. Then they'd herald their new proprietary electrons (dubbed
Active-E, or maybe Visual E-) as superior to standard electrons.

-mjc


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

Date: 03 Jan 2001 16:46:11 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Is it possible to parse a spreadsheet on a unix machine?
Message-Id: <m38zos5mxo.fsf@mumonkan.sunstarsys.com>

Michael Carman <mjcarman@home.com> writes:

> Abigail wrote:
> > 
> > Lucas wrote:
> > }}
> > }} Is it possible to parse a excel file on a unix machine?
> > 
> > Of course. You'd think electrons generated by MS are incompatible with
> > UNIX machines?
> 
> I've no doubt that M$ would do just that if they could only figure out
> how. Then they'd herald their new proprietary electrons (dubbed
> Active-E, or maybe Visual E-) as superior to standard electrons.

Of course, this is entirely possible by making the file format
dependent on the spin polarity of the underlying carrier electrons.
I think what you'd see is M$'s proprietary extension of the OSI
model, and hence giving birth to a whole new concept of 
file-sharing. No doubt Redmond would triumpantly declare it 
"tightly integrated into Windows 2010- Odyssey II edition".

So long as you didn't ever look at the file, everything would 
work peachy.  Thus naming it "Visual E" would be a poor choice.

-- 
Joe Schaefer



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

Date: Wed, 03 Jan 2001 22:28:21 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Is it possible to parse a spreadsheet on a unix machine?
Message-Id: <t579s53un7oq22@corp.supernews.com>

[Jeopardectomy performed. Please post responses in reasonable
reading order.]

rbfitzpa@my-deja.com wrote:

> In article <92vsb1$co84@imsp212.netvigator.com>,
>   "Lucas" <wstsoi@netvigator.com> wrote:
>> Hi all,
>>
>> Is it possible to parse a excel file on a unix machine?
>>
>> Thanks a lot
>>
>>

> Simple, piece of cake. I can tell you 5 different ways to do it
> depending on how you want the resulting file.

> Any of the following can do it for you:
> sed
> awk
> perl
> c
> vi

Or StarOffice, yes? And Applixware Office/Anyware Office?

This is not a Perl question. It is a general platform question,
unless it just wasn't worded specifically enough.

If the question is "can I parse an Excel file in Perl on a
Unix machine" then there seems to be a misunderstanding of how
portable Perl is. If you can parse an Excel spreadsheet in
Perl on Windows, then you can do so in Unix - especially since
Windows is the port and Unix is the home of Perl.

If the question, OTOH, is "can I make use of an Excel spreadsheet
on a Unix-like OS", then you can read up on StarOffice, Anyware
Office, sed, awk, Perl, or many other options, which is far too
general for this group. If the question is "Can I make an
Excel-compatible spreadsheet application for Unix variants",
then you need to take a look at the existing projects that are
mostly compatible with Excel file formats and see a) if they are
supported on your specific flavor of Unix clone, b) if you can
build and run them on your specific flavor of Unix clone, or
c) if you can modify them to run on your specific flavor of
Unix clone (and hopefully submit the patches so that the project
benefits from that).

> Just make sure you 'delimit' your file with something unique (csv -
> comma delimited usually does the trick).

Comma delimited and CSV have slight differences in connotation, but
the idea is the same. There are Perl modules for dealing with CSV.

> It is also helpful to learn 'Regular Expressions', pick up the OReilly
> book on awk.

Or the O'Reilly book on Regular Expressions. Or one on Perl.

Chris

-- 
Christopher E. Stith

Even in the worst of times, there is always someone who's never had it better.
Even in the best of times, there is always someone who's never had it worse.



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

Date: Thu, 4 Jan 2001 11:28:10 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Is it possible to parse a spreadsheet on a unix machine?
Message-Id: <93091r$bvp$1@hermes.nz.eds.com>


Lucas <wstsoi@netvigator.com> wrote in message
news:92vsb1$co84@imsp212.netvigator.com...
> Hi all,
>
> Is it possible to parse a excel file on a unix machine?

Have you seen http://search.cpan.org/search?dist=Spreadsheet-ParseExcel




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

Date: 4 Jan 2001 04:38:12 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: Is it possible to parse a spreadsheet on a unix machine?
Message-Id: <slrn957vkb.3vv.ben-fuzzybear@Odin.Thor>

The ancient archives of 03 Jan 2001 16:46:11 -0500 showed
Joe Schaefer of comp.lang.perl.misc speaking thus:
>Michael Carman <mjcarman@home.com> writes:
>
>> I've no doubt that M$ would do just that if they could only figure out
>> how. Then they'd herald their new proprietary electrons (dubbed
>> Active-E, or maybe Visual E-) as superior to standard electrons.
>
>Of course, this is entirely possible by making the file format
>dependent on the spin polarity of the underlying carrier electrons.


Don't go giving them any ideas!

Sheesh, some people... :)


Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
perl -we '$perl=0;JsP $perl "perl";$perl->perl(0)' \
2>&1 | perl -ne '{print ((split//)[19,29,20,4,5,1,2,
15,13,14,12,52,5,21,12,52,8,5,14,1,6,37,12,52,75])}'


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

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


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