[22218] in Perl-Users-Digest
Perl-Users Digest, Issue: 4439 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 21 11:06:50 2003
Date: Tue, 21 Jan 2003 08:05:10 -0800 (PST)
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, 21 Jan 2003 Volume: 10 Number: 4439
Today's topics:
CGI.pm aligning radio buttons with pick-lists <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Re: CGI.pm aligning radio buttons with pick-lists (Ben Morrow)
Re: Couple of Perl CGI problems (Tad McClellan)
Re: Newbie - "Nobody" in sender heading? <netscapeonly@fusionplant.com>
Re: Newbie - "Nobody" in sender heading? (Tad McClellan)
Re: newbie perl pattern processing question (Tad McClellan)
Re: newbie perl pattern processing question <bongie@gmx.net>
Re: newbie perl pattern processing question <mbudash@sonic.net>
Re: OO perl : object containing ref to other object <bongie@gmx.net>
Re: Paragraph Mode (Anno Siegel)
Re: Paragraph Mode <sjcole@hotmail.com>
Re: Paragraph Mode <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: Paragraph Mode <sjcole@hotmail.com>
Re: Paragraph Mode <flavell@mail.cern.ch>
Re: Paragraph Mode (Ben Morrow)
Re: Paragraph Mode <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Re: Paragraph Mode (Tad McClellan)
Re: Paragraph Mode (Tad McClellan)
Problem in 'split' function (Vibhav Agarwal)
Re: Problem in 'split' function (Ben Morrow)
Re: Problem with WMI (Tad McClellan)
Re: Regex to find all words containing a single vowel? <bigj@kamelfreund.de>
Re: Reverse Inheritance? (Ben Morrow)
Search array and return element? (jim ryan)
Re: Search array and return element? (Anno Siegel)
Re: Search array and return element? (Tad McClellan)
Re: Search array and return element? <camerond@mail.uca.edu>
Re: Starting with Perl (Tad McClellan)
Re: Starting with Perl <brian.smart@blueyonder.co.uk>
Re: Starting with Perl <brian.smart@blueyonder.co.uk>
Re: Still a little variable trouble. (Ben Morrow)
Re: Text manipulation <lou.moran@gellerandwind.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 21 Jan 2003 14:12:22 -0000
From: "Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Subject: CGI.pm aligning radio buttons with pick-lists
Message-Id: <b0jkbd$i84$1$830fa78d@news.demon.co.uk>
Using CGI.pm, I can generate a vertical panel of radio buttons to select one
of 3 types of frequency using the radio_griup() method:
Frequency:
O Monthly
@ Weekly
O Daily
And I can generate 2 separate pick-lists using calls to the popup_menu()
method:
Day of month: [ 31 ]
Day of week: [ Monday ]
My problem is how to horizontally align the "Day of month" pick-list with
the "Monthly" radio button, and the "Day of week" pick-list with the
"Weekly" radio button.
(The "Daily" radio button has no associated "Day of something" pick-list, of
course.)
Like this:
Frequency:
O Monthly Day of month: [ 31 ]
@ Weekly Day of week: [ Monday ]
O Daily
Is there any way to force each radio button into the same row as a pick-list
in a table?
Regards,
Clyde
------------------------------
Date: Tue, 21 Jan 2003 14:46:04 +0000 (UTC)
From: mauzo@ux-ma160-6.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: CGI.pm aligning radio buttons with pick-lists
Message-Id: <b0jmfc$b95$1@wisteria.csv.warwick.ac.uk>
"Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk> wrote:
>Using CGI.pm, I can generate a vertical panel of radio buttons to select one
>of 3 types of frequency using the radio_griup() method:
>
>Frequency:
> O Monthly
> @ Weekly
> O Daily
>
>And I can generate 2 separate pick-lists using calls to the popup_menu()
>method:
> Day of month: [ 31 ]
> Day of week: [ Monday ]
>
>My problem is how to horizontally align the "Day of month" pick-list with
>the "Monthly" radio button, and the "Day of week" pick-list with the
>"Weekly" radio button.
>(The "Daily" radio button has no associated "Day of something" pick-list, of
>course.)
>Like this:
>Frequency:
> O Monthly Day of month: [ 31 ]
> @ Weekly Day of week: [ Monday ]
> O Daily
>
>
>Is there any way to force each radio button into the same row as a pick-list
>in a table?
This is an HTML problem, not a Perl problem.
Partial answer: yes, you do need to use a <table>.
I would suggest you mock-up the page you want in HTML by hand before trying
to generate it.
Ben
------------------------------
Date: Tue, 21 Jan 2003 08:37:13 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Couple of Perl CGI problems
Message-Id: <slrnb2qmop.2l4.tadmc@magna.augustmail.com>
Michael Budash <mbudash@sonic.net> wrote:
> In article <751924de.0301201911.5a7c6f42@posting.google.com>,
> kedaran0504@yahoo.com.au (UmanS) wrote:
>> But the problem is I am
>> using
>> $string = ~/\'/\"/;
>
> i doubt it - you prolly mean:
>
> $string =~ s/\'/\"/;
I doubt _that_. :-)
He probably meant:
$string =~ s/'/"/;
or
$string =~ s/'/"/g;
Since quotes are not meta in regexes[1].
>> but this changes only the first occurance only.
So the 2nd one above was what he was looking for then.
But what he was looking for was not the Best Tool for job.
The best tool for replacing single characters would be:
$string =~ tr/'/"/;
[1] You might still need to escape a single quote in some
circumstances, but that is due to it being meta in
"double quotish" strings, not in regex patterns themselves.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 09:20:02 -0500
From: Netscape User Only <netscapeonly@fusionplant.com>
To: CAMERADO <camerado@camerado.com>
Subject: Re: Newbie - "Nobody" in sender heading?
Message-Id: <Pine.LNX.4.44.0301210919340.19968-100000@fusionplant.com>
nobody is the user
nobody is the group
On Mon, 20 Jan 2003, CAMERADO wrote:
> Hi--
>
> I bet you've heard this one before, but I 'm not a big perl wizard, all
> I know is that my mailing list manager uses Perl and whenever I send out
> an automated mailing it says "Nobody"/ in the sender heading...
>
> Can anybody tell me where / how to fix this in the script?
>
> Thanks a lot,
>
> JR
> Camerado
>
>
>
------------------------------
Date: Tue, 21 Jan 2003 08:57:09 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newbie - "Nobody" in sender heading?
Message-Id: <slrnb2qnu5.2l4.tadmc@magna.augustmail.com>
[ Jeopardectomy performed ]
CAMERADO <camerado@camerado.com> wrote:
> "Jürgen Exner" wrote:
>> CAMERADO wrote:
>> > Can anybody tell me where / how to fix this in the script?
>>
>> I just answered your question in "the other NG".
>> If you do mulit-posts then please see for yourself how to collect all the
>> replies.
> What are you talking about?
You posted the same question to the de.comp.lang.perl.misc newsgroup.
You should have done this instead:
http://www.tuxedo.org/~esr/jargon/html/entry/cross-post.html
See also:
http://www.tuxedo.org/~esr/jargon/html/entry/TOFU.html
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 08:08:30 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie perl pattern processing question
Message-Id: <slrnb2ql2u.2l4.tadmc@magna.augustmail.com>
Sol Linderstein <slinderstein@yahoo.com> wrote:
> I'm not new to programming but I am new to perl. Here's what I want to
> do.
Do you want to do it as nothing more than a "learning experience"?
Or are you working on something that can eventually be called "production"?
> I have a text file with lines of HTML with special embedded tags in
> it. I want to parse each line of the file and process the tags.
If the former, then the "right way" to process HTML is to use
a module that understand HTML. For some insights into some
of the "gotchas" involved, see:
perldoc -q HTML
"How do I remove HTML from a string?"
If the latter, then what you want to do is called "templating".
There are boatloads of already designed and tested templating
systems. You should probably use one of them rather than
inventing your own.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 16:14:02 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: newbie perl pattern processing question
Message-Id: <1348509.YJQ9Gs0Glo@nyoga.dubu.de>
Anno Siegel wrote:
> Sol Linderstein <slinderstein@yahoo.com> wrote in comp.lang.perl.misc:
>> I have a text file with lines of HTML with special embedded tags in
>> it. I want to parse each line of the file and process the tags. A
>> line of the input file might look like this:
>>
>> <A HREF="blahblahblah?id=<<var id>>">blah</A>
[...]
>
> Simple pattern matching is not enough to parse HTML, except under
> the most restrictive circumstances. Use HTML::Parser to parse
> HTML.
In general, I agree with you. But when handling a template like above,
the text might not even be valid HTML before parsing. For example,
<a href="<<link foo>>"><<text foo>></a>
could be valid template code, but it's not valid HTML, so the
HTML::Parser module may get into trouble (I haven't tested, though).
Anyway, a template pattern has to be defined in a way that makes the
template clearly distinguishable from the surrounding text, and so
should be easy to parse with regexes. OTOH, the code snippet above
looks like these templates might occur in every semantic position, what
makes them even harder to parse with a strictly hierarchical parser.
I think this kind of template should be well parseable with a regex like
$text =~ s/<<([\w\s]+?)>>/$template{$1}/g;
but for details, the exact syntax of the template pattern should be
known.
Ciao,
Harald
--
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Pride is what we have. Vanity is what others have.
------------------------------
Date: Tue, 21 Jan 2003 15:19:20 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: newbie perl pattern processing question
Message-Id: <mbudash-623013.07192021012003@typhoon.sonic.net>
In article <e435b329.0301202226.10900559@posting.google.com>,
slinderstein@yahoo.com (Sol Linderstein) wrote:
> Hi,
>
> I'm not new to programming but I am new to perl. Here's what I want to
> do.
> I have a text file with lines of HTML with special embedded tags in
> it. I want to parse each line of the file and process the tags. A line
> of the input file might look like this:
>
> <A HREF="blahblahblah?id=<<var id>>">blah</A>
>
> or like this:
>
> <INPUT TYPE="HIDDEN" NAME="<<var foo>>" VALUE="<<var bar>>">
>
> So, what I want to do is find the chunks of text surrounded by << >>
> and then process the stuff inside of the double angle brackets,
> replacing the << >> and the stuff inside of it with what my code will
> compute then printing out the processed line. There might be multiple
> of these patterns on each line.
>
> In essence I want to write an HTML pre-processor. "Var" isn't the only
> tag I'm planning to process, by the way.
>
> I think the approach/answer has to do with the split function but I'm
> not sure how to do this.
>
> I'd appreciate a simple example that takes a string and outputs the
> processed string. For simplicity, you can have the "var" tag replace
> the value with a random number. That should illustrate for me how to
> do what I want to do.
>
> Thanks very much.
>
> Sol
in tightly controlled HTML, this can be done with regular expressions
and minimal code, but it appears that you would be reinventing the
wheel. try using the fine perl module Text::Template. if you want to
live dangerously, this can be a starting point:
$html =~ s/<<(.+?)>>/process($1)/eg;
sub process {
my $stuff_to_process = shift;
...
}
hth-
------------------------------
Date: Tue, 21 Jan 2003 15:19:58 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: OO perl : object containing ref to other object
Message-Id: <6119982.VKTRIDiggd@nyoga.dubu.de>
Koos Pol wrote:
> Teh (tî'pô) wrote (Monday 20 January 2003 17:35):
>> Says who? it's a matter of taste and has nothing to do with the OP
>> problem.
>
> To be honest, I can't point the exact location. But it is hidden
> somewhere in the docs.
Yes, see perldoc perlstyle.
(I agree with most of the recommendations, although I think I'll never
do without 'cuddled elses'. ;-) )
Ciao,
Harald
--
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
We are Sinatra of Borg: Start spreading the news...
We`re assimilating today... You want to be a part
of it... the Borg... the Borg...
------------------------------
Date: 21 Jan 2003 14:06:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Paragraph Mode
Message-Id: <b0jk5g$om2$1@mamenchi.zrz.TU-Berlin.DE>
Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in comp.lang.perl.misc:
[...]
> To the OP - paragraph mode is when the special variable $/ is set to
> "\n\n". For example, if the input is:
>
>
> aaa
> bbb
> ccc
> ddd
>
> eee
> fff
> ggg
> hhh
>
>
> then in paragraph mode ($/ = "\n\n") there are 2 records while in the
> default mode ($/ = "\n") there are 9 (each line being a record).
This is still not quite the generic paragraph mode, which is attained
by setting $/ = ''. This will use any number of empty lines as a
paragraph separator, while $/ = "\n\n" uses exactly one empty line.
Anno
------------------------------
Date: Tue, 21 Jan 2003 14:14:25 -0000
From: "Steve C" <sjcole@hotmail.com>
Subject: Re: Paragraph Mode
Message-Id: <1043158187.734900@ananke.eclipse.net.uk>
"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
message news:b0jhds$9h2$1@nets3.rz.RWTH-Aachen.DE...
>
> I thought it would be mentioned in perlvar, under $/, but it's not very
> clear there either.
Yes. it confused me !!
>
> The difference is that "\n\n" will take one blank line as the delimiter
for
> paragraphs and anything following this blank line (including blank
> lines) up to the next empty line is a paragraph. In case of "" one or
> more consecutive empty lines are the separators for paragraphs and they
> wont show up in the data returned.
Thank you very much indeed for your comprehensive explanation. This makes
sense because the original author of the Perl script was manipulating
message headers, and the $/ = "" mode was used in his example, in order to
separate the headers from the message body.
Excellent - thanks again.
Steve.
------------------------------
Date: Tue, 21 Jan 2003 15:18:34 +0100
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Paragraph Mode
Message-Id: <5ilq2v4hv177l6nhtfssgv4mou24viha4s@4ax.com>
On 21 Jan 2003 14:06:40 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:
>Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in comp.lang.perl.misc:
>
>[...]
>
>> To the OP - paragraph mode is when the special variable $/ is set to
>> "\n\n". For example, if the input is:
>>
>>
>> aaa
>> bbb
>> ccc
>> ddd
>>
>> eee
>> fff
>> ggg
>> hhh
>>
>>
>> then in paragraph mode ($/ = "\n\n") there are 2 records while in the
>> default mode ($/ = "\n") there are 9 (each line being a record).
>
>This is still not quite the generic paragraph mode, which is attained
>by setting $/ = ''. This will use any number of empty lines as a
>paragraph separator, while $/ = "\n\n" uses exactly one empty line.
You're quite correct. $/ = "\n\n" is what I personally usually
consider "paragraph mode". I should have been clearer about that.
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Tue, 21 Jan 2003 14:32:17 -0000
From: "Steve C" <sjcole@hotmail.com>
Subject: Re: Paragraph Mode
Message-Id: <1043159259.520727@ananke.eclipse.net.uk>
"Koos Pol" <koos_pol@NO.nl.JUNK.compuware.MAIL.com> wrote in message
news:newscache$4wg29h$7ld$1@news.emea.compuware.com...
>
> May be the OP could clarify if he's interested in alinegraphs or perhaps
> parections? :-)
>
I'm particularly interested in what appears to be $/=""
I am trying to separate a message header from message body, make changes to
the header and then write the whole lot back. Instead of using a blank
sheet, I started by using a sample script provided by Philip Hazel (the Exim
author) where he refers to 'paragraph mode'. (If anyone is interested it
ships with Exim and is called transport_filter.pl)
Given that the end of the message headers section is identified by an "empty
line" - I need to read in everything before that blank line. So by setting
$/="" looks as though this is the correct way of achieving that task. This
is also what Philip Hazel had done - but of course I don't like just using
code without fully understanding what it's doing - for the reason that I
need to learn, NOT because I don't trust Philip Hazel !!!
The confusion arose when there was no reference to this $/ in the Llama book
that I could see, and perlvar was also confusing.
Thank you to everyone who's contributed.
Steve.
------------------------------
Date: Tue, 21 Jan 2003 14:47:48 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Paragraph Mode
Message-Id: <Pine.LNX.4.40.0301211437560.26821-100000@lxplus072.cern.ch>
On Jan 21, Koos Pol inscribed on the eternal scroll, apparently at
13:47:05:
> Steve C wrote (Tuesday 21 January 2003 13:39):
> > He talks about reading <STDIN> in 'Paragraph Mode'
> My guess is it is the standard mode.
My guess it that if you're unsure, then waiting to see if one of the
regulars answers would be a useful strategy. If, after a reasonable
delay, no-one has offered any answer, then it might be time to step up
to the plate.
Another possible approach, if Perl's own documentation and FAQs
don't help (which apparently was the case here), would be
http://www.google.com/search?q=perl+paragraph.mode
which I see successfully delivers the answer to this particular issue.
(Sure: when interpreting such search results it's useful to have the
bogosity detector fully operational, no arguments about that.)
No offence meant. We all make mistakes, but occasionally it can be
useful to review what we can learn from them, IMHO.
------------------------------
Date: Tue, 21 Jan 2003 14:43:13 +0000 (UTC)
From: mauzo@ux-ma160-6.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Paragraph Mode
Message-Id: <b0jma1$b60$1@wisteria.csv.warwick.ac.uk>
"Steve C" <sjcole@hotmail.com> wrote:
>
>"Koos Pol" <koos_pol@NO.nl.JUNK.compuware.MAIL.com> wrote in message
>news:newscache$4wg29h$7ld$1@news.emea.compuware.com...
>>
>> May be the OP could clarify if he's interested in alinegraphs or perhaps
>> parections? :-)
>>
>I'm particularly interested in what appears to be $/=""
Read Anno's post (or perldoc perlvar).
Ben
------------------------------
Date: Tue, 21 Jan 2003 16:06:24 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: Paragraph Mode
Message-Id: <newscache$omk29h$zld$1@news.emea.compuware.com>
Alan J. Flavell wrote (Tuesday 21 January 2003 14:47):
> On Jan 21, Koos Pol inscribed on the eternal scroll, apparently at
> 13:47:05:
>
>> My guess is it is the standard mode.
>
> My guess it that if you're unsure, then waiting to see if one of the
> regulars answers would be a useful strategy. If, after a reasonable
> delay, no-one has offered any answer, then it might be time to step up
> to the plate.
Don't patronize me. After my explaination (there seems to be a
linguistic/I18N issue according to my Dutch/English dictionary), it seems
perfectly valid to offer my guess especially when it is said to be a guess
from the start and not as a fact. And the OP is free to migrate my
suggestion to /dev/null if my paragraph is not the same as his.
Enough said.
--
KP
------------------------------
Date: Tue, 21 Jan 2003 09:13:07 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Paragraph Mode
Message-Id: <slrnb2qos3.2s8.tadmc@magna.augustmail.com>
Steve C <sjcole@hotmail.com> wrote:
> I'm particularly interested in what appears to be $/=""
> The confusion arose when there was no reference to this $/ in the Llama book
> that I could see, and perlvar was also confusing.
You are misusing the Llama.
The Llama book is a _tutorial_, not a reference.
If you want a reference, that would be (in this order):
Perl's std docs
"Programming Perl" (Camel book)
But I agree the description in perlvar could be made better...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 09:27:08 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Paragraph Mode
Message-Id: <slrnb2qpmc.2s8.tadmc@magna.augustmail.com>
Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
> Also sprach Steve C:
>> is
>> there a more "technically correct" term for this 'paragraph mode' ??
>
> I thought it would be mentioned in perlvar, under $/, but it's not very
> clear there either.
The description in perlvar.pod is indeed sub-optimal.
The resourceful Perl programmer will eventually turn to grepping
the *.pod files when perldoc'ing with several terms doesn't work:
grep 'paragraph mode' *.pod
It finds 2 hits (5.8.0), neither of which describes what it is.
The docs use the term twice, but never define it!
There is definitely room for improvement there...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Jan 2003 06:13:39 -0800
From: vibhav@gdit.iiit.net (Vibhav Agarwal)
Subject: Problem in 'split' function
Message-Id: <e61c9f4e.0301210613.45a52abc@posting.google.com>
Hi all,
I have a problem.
I have written a perl program, which is running well on Red Hat Linux
7.2
But when i am running that program on Red Hat Linux 8.0, i am having
errors in 'split' function.
In my program split function has been written as:
@arr = split(/"/,$in); #$in is a string which contains '"'
It is executing well on Linux 7.2
But when i am running it on Linux 8.0, it is giving this error-
Split loop at "file_name"
Now i wrote split function as
($a, $b) = split(/"/,$in);
Now it is working well.
Please tell me what is the problem in first 'split' function?
All advices and sugegstions are welcome.
Thank you in advance.
Please reply soon.
regards--
Vibhav Agarwal -- vibhav@gdit.iiit.net
------------------------------
Date: Tue, 21 Jan 2003 14:58:33 +0000 (UTC)
From: mauzo@ux-ma160-6.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Problem in 'split' function
Message-Id: <b0jn6p$bk0$1@wisteria.csv.warwick.ac.uk>
vibhav@gdit.iiit.net (Vibhav Agarwal) wrote:
>Hi all,
> I have a problem.
>
>I have written a perl program, which is running well on Red Hat Linux
>7.2
>But when i am running that program on Red Hat Linux 8.0, i am having
>errors in 'split' function.
>
>In my program split function has been written as:
>
>@arr = split(/"/,$in); #$in is a string which contains '"'
>
>It is executing well on Linux 7.2
I believe the current version of linux is 2.5.something. Please be more careful
about what you mean. Also, in this case, a far more important question is what
the versions of perl involved are.
>But when i am running it on Linux 8.0, it is giving this error-
>Split loop at "file_name"
And how are we supposed to help if we don't know what $in contains? A quick
test with $in='a"b' works fine for me with perl5.8.
However, perldoc perldiag (do you know about that? You should) says that
'Split loop' is an internal error you should never see...
Again, which version of Perl are you using and where did it come from?
>Now i wrote split function as
>
>($a, $b) = split(/"/,$in);
Yes, this (I would guess) is likely to fix the problem as then split is only
trying to produce three strings. However, the real problem is more fundamental
than that.
>Now it is working well.
>
>Please tell me what is the problem in first 'split' function?
Nothing, as far as I can see. Can you post a full (SHORT) program which
demonstrates the problem, together with the full output and the perl version?
>All advices and sugegstions are welcome.
>
>Thank you in advance.
>
>Please reply soon.
Don't ever say this. Usenet is not a helpdesk. People will reply in their own
time or not at all, and this make the latter rather more likely.
Ben
------------------------------
Date: Tue, 21 Jan 2003 08:47:48 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem with WMI
Message-Id: <slrnb2qnck.2l4.tadmc@magna.augustmail.com>
John <a@a.com> wrote:
> How can I use WMI
What is WMI?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 13:54:54 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
To: mrennix@totalise.co.uk (Martin)
Subject: Re: Regex to find all words containing a single vowel?
Message-Id: <pan.2003.01.21.12.54.47.794815@kamelfreund.de>
On Tue, 21 Jan 2003 02:56:21 +0000, Martin wrote:
>> As TMTWTDI, here's another solution:
>>
>> print join "\n",
>> ($string =~ /(\b [^aeiou\s]* [aeiou] [^aeiou\s]* \b)/gix);
^ ^ ^ ^
>
> This works great, and I actually understand it! But, why does it need to
> be given the x modifier (for extended regexes)? Which features are
> available only when the x modifier is used?
I just used the x modifier only to increase the readability. I only
inserted some spaces to seperate the different part of the regexp. The x
modifier has the effect that spaces are ignored by the regexp.
There's no other magix reason for the using of the x modifier in this case
:-) (Well, but you should read perldoc perlre to understand it completely)
Cheerio,
Janek
------------------------------
Date: Tue, 21 Jan 2003 15:06:14 +0000 (UTC)
From: mauzo@ux-ma160-6.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Reverse Inheritance?
Message-Id: <b0jnl6$btp$1@wisteria.csv.warwick.ac.uk>
Malte Ubl <ubl@schaffhausen.de> wrote:
>Anno Siegel wrote:
>> Well, string eval is a potentially dangerous operation and requires
>> careful checking of the string(s) involved. So it's a stumbling block
>> in the way of anyone reading the program.
>>
>> Also, it is huge overkill to start another interpreter run just
>> to load a module. While efficiency is no concern in this case,
>> it is good engineering to do things with as little expenditure
>> as possible.
>
>While I think string eval is OK if the value comes from a lookup table
>or something similar, the efficiency is a good point. I have written a
>big mod_perl based MVC system that does 2 evals on every request to load
>the required Views/Models on demand, because I figured it'd come for
>free. Gotta change that.
Hang on, surely if you're about to call back to the compiler anyway to do the
require (which is but a do which is but a string eval in disguise), then the
effect is completely negligible. You might get problems where either:
1. you hadn't just set the variable the line before so you weren't sure what
it contained.
or
2. There is a significant chance of the module having been loaded already,
which there isn't in the OP's case.
I do think this is a problem though: I have very icky feelings about string
eval (and I don't really like block eval being called eval, either). I think
perl6 is much better about treating class/package/module names as more
things-in-themselves and less as a platform-independant way to specify a
filename. I would say that require should not accept a string such as
"File/Copy.pm", ever...
Ben
------------------------------
Date: 21 Jan 2003 06:41:14 -0800
From: ryan@jimryan.com (jim ryan)
Subject: Search array and return element?
Message-Id: <d220d0c9.0301210641.60417626@posting.google.com>
If I issue a system command that returns multple lines into an array,
how do I subsequently search through that array for a string and
return all the element numbers where that string occurs?
Thank you,
Jim
------------------------------
Date: 21 Jan 2003 14:56:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Search array and return element?
Message-Id: <b0jn33$qem$1@mamenchi.zrz.TU-Berlin.DE>
jim ryan <ryan@jimryan.com> wrote in comp.lang.perl.misc:
> If I issue a system command that returns multple lines into an array,
> how do I subsequently search through that array for a string and
> return all the element numbers where that string occurs?
grep 1 + index( $_, $string), @array;
Oh, you said element numbers. Is that the same as line numbers?
If so:
grep 1 + index( $array[ $_], $string), 0 .. @array - 1;
Anno
------------------------------
Date: Tue, 21 Jan 2003 09:34:08 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Search array and return element?
Message-Id: <slrnb2qq3g.2s8.tadmc@magna.augustmail.com>
jim ryan <ryan@jimryan.com> wrote:
> If I issue a system command that returns multple lines into an array,
You can't issue a system() command that returns multiple lines...
> how do I subsequently search through that array for a string and
perldoc -f grep
my @matches = grep /a string/, @array;
> return all the element numbers where that string occurs?
my @match_indexes = grep $array[$_] =~ /a string/, 0..$#array;
But if you need the indexes, rather than the values of the elements,
you've probably made a mistake in the design of your code.
You seldom need to do explicit indexing in idiomatic Perl.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 09:59:40 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Search array and return element?
Message-Id: <3E2D6E6C.5050902@mail.uca.edu>
Anno Siegel wrote:
> jim ryan <ryan@jimryan.com> wrote in comp.lang.perl.misc:
>
>>If I issue a system command that returns multple lines into an array,
>>how do I subsequently search through that array for a string and
>>return all the element numbers where that string occurs?
>>
>
> grep 1 + index( $_, $string), @array;
>
> Oh, you said element numbers. Is that the same as line numbers?
> If so:
>
> grep 1 + index( $array[ $_], $string), 0 .. @array - 1;
There's always the less elegant solution for those of us who did not
grow up with grep (it does the same thing AFAIK, but I can get my mind
around it easier):
for ($int=0; $int<@ary; ++$int) {
if ($ary[$int] =~ /$string/) {
print "$int, $ary[$int]\n";
}
}
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: Tue, 21 Jan 2003 08:45:27 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Starting with Perl
Message-Id: <slrnb2qn87.2l4.tadmc@magna.augustmail.com>
Brian Smart <brian.smart@blueyonder.co.uk> wrote:
> Any comments on how to move forward with learning the language would be
> appreciated.
If you have programmed in other languages before, the usual
recommendation is:
"Learning Perl" by Randal Schwartz and Tom Phoenix
If Perl is your first progamming language, then the usual
recommendation is:
"Elements of Programming with Perl" by Andrew Johnson
But you should keep in mind that books are NOT the best Perl
resource.
The best Perl resource are the std docs that get installed
along with perl itself.
[snip TOFU, please see the Posting Guidelines that are posted here weekly]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 15:47:40 -0000
From: "Brian Smart" <brian.smart@blueyonder.co.uk>
Subject: Re: Starting with Perl
Message-Id: <uQdX9.8865$pW3.1986@news-binary.blueyonder.co.uk>
Hi,
Thanks
Brian Smart
"Jens Hoehne" <hazelbigfoot@gmx.net> wrote in message
news:3E2D39F8.FBE164ED@gmx.net...
> Hello Brian,
>
> Brian Smart wrote:
> >
> > Hello All,
> > Thanks for comments, I am now over the first hurdle. I have installed
Perl
> > on my computer and can run my script from the command line and get the
> > desired result.
> Thats good.
> > Any comments on how to move forward with learning the language would be
> > appreciated.
>
> Learning Perl? Or cgi programming? For the first I would recommend a
> look at "Learning Perl" by Randal L. Schwartz and Tom Phoenix -
> sometimes referred as Llama book. Note that by now you have the
> complete and definite documentation on your harddrive - type 'perldoc -q
> book' and see what I mean.
> Your tofu style posting indicates, that you should also take a look at
> the excellent "posting guidelines" which are posted here weekly. It
> takes a few minutes to read them but this can save you hours of
> embarrassment and worse.
>
> Regards,
> Jens
------------------------------
Date: Tue, 21 Jan 2003 15:48:06 -0000
From: "Brian Smart" <brian.smart@blueyonder.co.uk>
Subject: Re: Starting with Perl
Message-Id: <UQdX9.8874$pW3.2211@news-binary.blueyonder.co.uk>
Hi,
Thanks
Brian Smart
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnb2qn87.2l4.tadmc@magna.augustmail.com...
> Brian Smart <brian.smart@blueyonder.co.uk> wrote:
>
> > Any comments on how to move forward with learning the language would be
> > appreciated.
>
>
> If you have programmed in other languages before, the usual
> recommendation is:
>
> "Learning Perl" by Randal Schwartz and Tom Phoenix
>
> If Perl is your first progamming language, then the usual
> recommendation is:
>
> "Elements of Programming with Perl" by Andrew Johnson
>
>
> But you should keep in mind that books are NOT the best Perl
> resource.
>
> The best Perl resource are the std docs that get installed
> along with perl itself.
>
>
>
> [snip TOFU, please see the Posting Guidelines that are posted here weekly]
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 14:39:39 +0000 (UTC)
From: mauzo@ux-ma160-6.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Still a little variable trouble.
Message-Id: <b0jm3b$b1k$1@wisteria.csv.warwick.ac.uk>
"Richard S Beckett" <spikey-wan@bigfoot.com> wrote:
>Hello World!
>
>I'm still having a little trouble with variables.
>
>My script uses Tk.
>When you click on the 'Help' menu item, it invokes the help subroutine.
>
>In the help subroutine, I define the main help window, with...
>
>my $help_window = $main_window -> Toplevel (etc...
>
>Into this window I put some buttons, that call subroutines, and a ROText
>widget, again defined with my.
>
>my $text_area = $help_window -> ROText (etc...
>
>When you press a button, it calls another subroutine, that should put text
>into the ROText widget, but because I've defined the ROText widget inside
>the help sub, with my, when the text insertion routines get called, I get an
>error:
>
>Global symbol "$text_area" requires explicit package name...
>
>The easy way would be to replace 'my $text_area =...' in the subroutine with
>'$text_area = ...', and put a 'my $text;' at the beginning of my script, but
>surely that defeats the object of the way that variables work in perl?
And every other decent programming language :)
Yes, you could do that, and solutions of this form are not always wrong.
However, in this case it's hardly necessary.
>I suppose I could define my buttons as -command => \&text_sub ($text_area),
>but again, I think that's messy.
I don't think that would work. You can't take a reference to a subroutine
call, only to the sub itself.
>How should I do this, properly?
Two ways (and if you think the above is messy, you'll probably think the same
of these, but I'm afraid I'll have to tell you're wrong here :):
-command => sub {
$text_area->insert(blah...);
whatever else...
}
or, if the sub is too long to inline or you want to set several callbacks to
call the same thing,
-command => sub { text_sub($text_area) }
This _is_ the right answer. Closures (the subs above, which 'trap' the value
of $text_area even though they may be called at any time) are a very good way
to deal with getting lexicals (my variables) to places they otherwise couldn't
be. Adn passing arguments to a sub is nearly always better than using globals.
Ben
------------------------------
Date: Tue, 21 Jan 2003 09:13:16 -0500
From: Lou Moran <lou.moran@gellerandwind.com>
Subject: Re: Text manipulation
Message-Id: <a8lq2vci5klvh1pi8r116aa54hvptffd87@4ax.com>
On Tue, 21 Jan 2003 12:31:04 +1100, Martien Verbruggen
<mgjv@tradingpost.com.au> wrote:
>Are you sure you have that right? Your example data doesn't have double
>quotes,
Sorry I had already "fixed" that
>perldoc -q duplicate
>You should know by now how to search the FAQ, right?
A fair question. I got tangled in my own words and missed the obvious
search string.
>That is too vague. Both of them have 4 fields. Is the presence of an
>empty last field enough to trigger this knowledge? How are we supposed
>to figure out whether or not there is a second address line without
>knowing how this thing got populated in the first place?
Regrettably this (and 13,000 more lines just like them) is what they
handed me. The come from Crystal Reports saved as .csv.
I thank you for the example code.
--
There's more than one way to do it, but only some of them work
------------------------------
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 4439
***************************************