[28405] in Perl-Users-Digest
Perl-Users Digest, Issue: 9769 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 26 09:10:15 2006
Date: Tue, 26 Sep 2006 06:10:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 26 Sep 2006 Volume: 10 Number: 9769
Today's topics:
Splitting and keeping key/value <mr@sandman.net>
Re: Splitting and keeping key/value <mritty@gmail.com>
Re: Splitting and keeping key/value <mr@sandman.net>
Re: Splitting and keeping key/value <mritty@gmail.com>
Re: Splitting and keeping key/value (reading news)
Re: Tk- getOpenFile sticks on W2K server <zentara@highstream.net>
Tricky subclassing problem: Parent class method uses st don.hosek@gmail.com
Re: Tricky subclassing problem: Parent class method use (reading news)
Re: windows problem with socket write <polka.hanky@virgin.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 26 Sep 2006 12:29:38 +0200
From: Sandman <mr@sandman.net>
Subject: Splitting and keeping key/value
Message-Id: <mr-438F5D.12293826092006@individual.net>
Indata:
-------------------------------------
Date: 2006-04-03
Message: Wonderful! Let's
meet there! I'll call you
later
Sent by: John
-------------------------------------
I want this parsed into:
Array (
[Date] => "2006-04-03",
[Message] => "Wonderful! Let's\nmeet there! ....."
[Sent by] => "John"
)
By defining keywords that data should be split in, in this case
"Date", "Message", "Sent by" and that those should be the first word
on the line and they should be followed by a ":". The Message part in
my actual indata is at no risk of containing any of these keywords.
Any cute ideas on how to solve that? Thanks in advance. :)
--
Sandman[.net]
------------------------------
Date: 26 Sep 2006 03:48:49 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Splitting and keeping key/value
Message-Id: <1159267729.600837.37420@m7g2000cwm.googlegroups.com>
Sandman wrote:
> Indata:
> -------------------------------------
> Date: 2006-04-03
> Message: Wonderful! Let's
> meet there! I'll call you
> later
> Sent by: John
> -------------------------------------
Please speak Perl, not some bizarre pseudo-code. Do you mean:
my $Indata = "Date: 2006-04-03
Message: Wonderful! Let's
meet there! I'll call you
later
Sent by: John";
or do you mean:
my @Indata = (
"Date: 2006-04-03\n",
"Message: Wonderful! Let's\n",
"meet there! I'll call you\n",
"later\n",
"Sent by: John\n"
);
?
The difference is important.
> I want this parsed into:
>
> Array (
> [Date] => "2006-04-03",
> [Message] => "Wonderful! Let's\nmeet there! ....."
> [Sent by] => "John"
> )
Is this some sort of pseudo-PHP? Are you aware you posted to a Perl
newsgroup? Do you mean you want:
my %hash = (
'Date' => '2006-04-03',
'Message' => "Wonderful! Let's\nmeet there! ...",
'Sent by' => John',
);
?
> By defining keywords that data should be split in, in this case
> "Date", "Message", "Sent by" and that those should be the first word
> on the line and they should be followed by a ":". The Message part in
> my actual indata is at no risk of containing any of these keywords.
>
> Any cute ideas on how to solve that?
I don't how cute it is, but yes, I could solve that using regular
expressions. Have you made any attempts to solve it yourself yet? If
you post your best attempt, and describe how that attempt is not
working for you, we can probably help you fix it.
Paul Lalli
------------------------------
Date: Tue, 26 Sep 2006 13:15:13 +0200
From: Sandman <mr@sandman.net>
Subject: Re: Splitting and keeping key/value
Message-Id: <mr-4FB157.13151326092006@individual.net>
In article <1159267729.600837.37420@m7g2000cwm.googlegroups.com>,
"Paul Lalli" <mritty@gmail.com> wrote:
> Sandman wrote:
> > Indata:
> > -------------------------------------
> > Date: 2006-04-03
> > Message: Wonderful! Let's
> > meet there! I'll call you
> > later
> > Sent by: John
> > -------------------------------------
>
> Please speak Perl, not some bizarre pseudo-code. Do you mean:
> my $Indata = "Date: 2006-04-03
> Message: Wonderful! Let's
> meet there! I'll call you
> later
> Sent by: John";
>
> or do you mean:
> my @Indata = (
> "Date: 2006-04-03\n",
> "Message: Wonderful! Let's\n",
> "meet there! I'll call you\n",
> "later\n",
> "Sent by: John\n"
> );
>
> ?
>
> The difference is important.
My indata is a textfile. Sorry.
> > I want this parsed into:
> >
> > Array (
> > [Date] => "2006-04-03",
> > [Message] => "Wonderful! Let's\nmeet there! ....."
> > [Sent by] => "John"
> > )
>
> Is this some sort of pseudo-PHP?
No.
> Are you aware you posted to a Perl newsgroup?
Yes. Did you or did you not understand the array composition I was
looking for? If you didn't, I would be glad to explain it further as
to avoid confusion.
> > By defining keywords that data should be split in, in this case
> > "Date", "Message", "Sent by" and that those should be the first word
> > on the line and they should be followed by a ":". The Message part in
> > my actual indata is at no risk of containing any of these keywords.
> >
> > Any cute ideas on how to solve that?
>
> I don't how cute it is, but yes, I could solve that using regular
> expressions. Have you made any attempts to solve it yourself yet? If
> you post your best attempt, and describe how that attempt is not
> working for you, we can probably help you fix it.
No, I am currently parsing it by:
if ($body=~m/Message: (.*?)\n/){
my $message = $1;
}
But I want a more modular approach.
--
Sandman[.net]
------------------------------
Date: 26 Sep 2006 05:21:32 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Splitting and keeping key/value
Message-Id: <1159273292.373250.51450@b28g2000cwb.googlegroups.com>
Sandman wrote:
> In article <1159267729.600837.37420@m7g2000cwm.googlegroups.com>,
> "Paul Lalli" <mritty@gmail.com> wrote:
>
> > Sandman wrote:
> > > Indata:
> > > -------------------------------------
> > > Date: 2006-04-03
> > > Message: Wonderful! Let's
> > > meet there! I'll call you
> > > later
> > > Sent by: John
> > > -------------------------------------
> >
> > Please speak Perl, not some bizarre pseudo-code. Do you mean:
> > my $Indata = "Date: 2006-04-03
> > Message: Wonderful! Let's
> > meet there! I'll call you
> > later
> > Sent by: John";
> >
> > or do you mean:
> > my @Indata = (
> > "Date: 2006-04-03\n",
> > "Message: Wonderful! Let's\n",
> > "meet there! I'll call you\n",
> > "later\n",
> > "Sent by: John\n"
> > );
> >
> > ?
> >
> > The difference is important.
>
> My indata is a textfile. Sorry.
That completely fails to answer the question. How are you storing this
data *within your program*.
> > > I want this parsed into:
> > >
> > > Array (
> > > [Date] => "2006-04-03",
> > > [Message] => "Wonderful! Let's\nmeet there! ....."
> > > [Sent by] => "John"
> > > )
> >
> > Is this some sort of pseudo-PHP?
>
> No.
>
> > Are you aware you posted to a Perl newsgroup?
>
> Yes. Did you or did you not understand the array composition I was
> looking for?
No, I can only *guess* as to what you meant. My guess may or may not
be correct.
> If you didn't, I would be glad to explain it further as to avoid confusion.
To avoid confusion, just "speak Perl". That way there is no guessing.
Show us an actual Perl data structure that is the result you are
desiring.
> > > By defining keywords that data should be split in, in this case
> > > "Date", "Message", "Sent by" and that those should be the first word
> > > on the line and they should be followed by a ":". The Message part in
> > > my actual indata is at no risk of containing any of these keywords.
> > >
> > > Any cute ideas on how to solve that?
> >
> > I don't how cute it is, but yes, I could solve that using regular
> > expressions. Have you made any attempts to solve it yourself yet? If
> > you post your best attempt, and describe how that attempt is not
> > working for you, we can probably help you fix it.
>
> No, I am currently parsing it by:
>
> if ($body=~m/Message: (.*?)\n/){
> my $message = $1;
> }
>
> But I want a more modular approach.
Presumably, you want an approach that works, too, since the above
doesn't. Even assuming you have more in your if() statement, which
adds the message to your structure, that would stop $1 at the first
line of the Message, rather than where the message actually ends.
Consider matching all non-colons up to an internal end-of-line (take a
look at the /m modifier for RegExps)
Code the attempt, and let us know if it doesn't work.
Paul Lalli
------------------------------
Date: Tue, 26 Sep 2006 12:44:47 GMT
From: "Mumia W. (reading news)" <paduille.4058.mumia.w@earthlink.net>
Subject: Re: Splitting and keeping key/value
Message-Id: <3h9Sg.6492$UG4.1495@newsread2.news.pas.earthlink.net>
On 09/26/2006 05:29 AM, Sandman wrote:
> Indata:
> -------------------------------------
> Date: 2006-04-03
> Message: Wonderful! Let's
> meet there! I'll call you
> later
> Sent by: John
> -------------------------------------
>
> I want this parsed into:
>
> Array (
> [Date] => "2006-04-03",
> [Message] => "Wonderful! Let's\nmeet there! ....."
> [Sent by] => "John"
> )
>
> By defining keywords that data should be split in, in this case
> "Date", "Message", "Sent by" and that those should be the first word
> on the line and they should be followed by a ":". The Message part in
> my actual indata is at no risk of containing any of these keywords.
>
> Any cute ideas on how to solve that? Thanks in advance. :)
>
>
I would use the substitution operator s/// to repeatedly suck off
keyword and value segments and place them in a hash. The /e option to
s/// allows you execute complicated expressions, and that's what I would
use here.
Try it yourself.
--
paduille.4058.mumia.w@earthlink.net
------------------------------
Date: Tue, 26 Sep 2006 10:20:05 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Tk- getOpenFile sticks on W2K server
Message-Id: <qgvhh29573ohcjjfua2lkcqjsgb81opss1@4ax.com>
On 25 Sep 2006 22:42:00 -0700, "MoshiachNow" <lev.weissman@creo.com>
wrote:
># The initial directory
>my $initial_dir = '/';
>
>
>How do I cause the browser to see all disks from the top,not only my
>current disk ?
>Thanks
Well I use linux, and '/' is the top. All other disks have to be mounted
somewhere on /.
If you are using Windows, I don't know how they do it.
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: 26 Sep 2006 01:45:31 -0700
From: don.hosek@gmail.com
Subject: Tricky subclassing problem: Parent class method uses static value from child class
Message-Id: <1159260330.991629.15980@k70g2000cwa.googlegroups.com>
I want to be able to do something along the lines of:
package A;
@ISA = ('B');
use Class::Std;
my $foo='this';
package C;
@ISA = ('B');
use Class::Std;
my $foo='this';
package B;
use Class::Std;
sub method {
do something with $foo
}
(obviously, there's a bit more to this, but I'm trying to abstract
things as much as possible).
But I can't seem to find anyway to make $bar->method(); see the
appropriate value of $foo depending on whether $bar is an object of
type A or C. Am I going to have to have a method (or AUTOMETHOD) to
copy $foo into the B namespace when method is called? Or is there a
more elegant way of handling this? [As a note, in actuality, I'm
dealing with a %foo rather than a $foo].
------------------------------
Date: Tue, 26 Sep 2006 10:37:40 GMT
From: "Mumia W. (reading news)" <paduille.4058.mumia.w@earthlink.net>
Subject: Re: Tricky subclassing problem: Parent class method uses static value from child class
Message-Id: <Up7Sg.6450$UG4.731@newsread2.news.pas.earthlink.net>
On 09/26/2006 03:45 AM, don.hosek@gmail.com wrote:
> I want to be able to do something along the lines of:
>
> package A;
> @ISA = ('B');
> use Class::Std;
>
> my $foo='this';
>
> package C;
> @ISA = ('B');
> use Class::Std;
>
> my $foo='this';
>
> package B;
> use Class::Std;
>
> sub method {
> do something with $foo
> }
>
> (obviously, there's a bit more to this, but I'm trying to abstract
> things as much as possible).
>
> But I can't seem to find anyway to make $bar->method(); see the
> appropriate value of $foo depending on whether $bar is an object of
> type A or C. Am I going to have to have a method (or AUTOMETHOD) to
> copy $foo into the B namespace when method is called? Or is there a
> more elegant way of handling this? [As a note, in actuality, I'm
> dealing with a %foo rather than a $foo].
>
Read "perldoc perltoot"; look at the "Class Data" section. Store a
reference to the static data in the object and use only that reference
to examine or manipulate the data.
--
paduille.4058.mumia.w@earthlink.net
------------------------------
Date: 26 Sep 2006 04:30:56 -0700
From: "mastermagrath" <polka.hanky@virgin.net>
Subject: Re: windows problem with socket write
Message-Id: <1159270256.172752.36080@i3g2000cwc.googlegroups.com>
Hi Rob,
Thanks so much...this works a treat!!!
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9769
***************************************