[22219] in Perl-Users-Digest
Perl-Users Digest, Issue: 4440 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 21 14:06:02 2003
Date: Tue, 21 Jan 2003 11:05:11 -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: 4440
Today's topics:
Re: ActivePerl 5.8 / MySQL / Apache Problem (Randy Kobes)
Re: APL's relation to perl <uri@stemsystems.com>
Re: APL's relation to perl <uri@stemsystems.com>
Re: avoid chaos -or- "protected" writing <little_tux@gmx.net>
Blank line in perlpod? (Michael Becker)
Re: Blank line in perlpod? (Anno Siegel)
Re: Blank line in perlpod? <tassilo.parseval@post.rwth-aachen.de>
Re: CGI.pm aligning radio buttons with pick-lists <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Re: CGI.pm aligning radio buttons with pick-lists (Sam Holden)
Re: CGI.pm aligning radio buttons with pick-lists <cingram@pjocsNOSPAMORHAM.demon.co.uk>
GD::Graph get_hotspot() (RR)
Re: got me foxed <david@morgmein.tk>
Re: OO perl : object containing ref to other object (tî'pô)
open file for reading a part of it <nospam@nospam.org>
Re: open file for reading a part of it (Tad McClellan)
Re: open file for reading a part of it (Anno Siegel)
Re: open file for reading a part of it (Ben Morrow)
Re: open file for reading a part of it <nospam@nospam.org>
Re: open file for reading a part of it <nospam@nospam.org>
Re: Paragraph Mode <sjcole@no_spam.hotmail.com>
Re: Paragraph Mode (Tad McClellan)
Re: Reverse Inheritance? <uri@stemsystems.com>
Re: Reverse Inheritance? (Ben Morrow)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Jan 2003 16:37:17 GMT
From: randy@theoryx5.uwinnipeg.ca (Randy Kobes)
Subject: Re: ActivePerl 5.8 / MySQL / Apache Problem
Message-Id: <slrnb2qtfp.j3l.randy@theoryx5.uwinnipeg.ca>
On Tue, 21 Jan 2003 12:04:29 -0000, Alex Banks <alex@alexbanks.com> wrote:
>I used to run ActivePerl 5.6 with Apache on my Windows XP box just fine -
>but since I installed ActivePerl 5.8 my old database scripts don't work.
>They come back with this error:
>
>[Tue Jan 21 11:51:24 2003] [error] [client 192.168.1.15]
>install_driver(mysql) failed: Can't load
>'C:/Perl/site/lib/auto/DBD/mysql/mysql.dll' for module DBD::mysql:
>load_file:The specified module could not be found at
>C:/Perl/lib/DynaLoader.pm line 229.
[ ... ]
>The file c:\perl\site\lib\auto\DBD\mysql\mysql.dll exists. All other my Perl
>scripts work fine except those that invoke a database connection. Apache
>works fine - the webpages are served normally.
>
>In case it helps, here's what I did to install:
>
>- Download the ActivePerl 5.8 and Apache bundle from
>http://theoryx5.uwinnipeg.ca/pub/other/.
>- Stop and uninstall the old Apache service (apache -n apache -k stop THEN
>apache -n apache -k uninstall)
>- Rename my old directories C:\Apache --> C:\OldApache and C:\Perl -->
>C:\OldPerl.
>- Unpack the download and move directories to root - C:\Apache2 and C:\Perl
>- Run the Perl configuration utility - c:\Perl\bin\perl configure.pl -
>selecting all the default options.
>- Modify the httpd.conf to point to my desired web and scripts folders.
>- Install the new apache service (c:\apache2\bin\apache -n apache2 -k
>install THEN c:\apache2\bin\apache -n apache2 -k start)
>- Install the database modules ('c:\perl\bin\ppm' then 'install DBI' then
>'install DBD-mysql')
>- Quit all the programmes then restart my PC
I'm not quite sure why this seems necessary, but try putting
the path to your mysql installation dlls (eg, C:\mysql\lib\opt,
where libmySQL.dll resides) in your PATH environment variable.
--
best regards,
randy kobes
------------------------------
Date: Tue, 21 Jan 2003 16:19:32 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: APL's relation to perl
Message-Id: <x7smvmtqzx.fsf@mail.sysarch.com>
>>>>> "MD" == Michele Dondi <bik.mido@tiscalinet.it> writes:
MD> On Fri, 17 Jan 2003 19:11:54 GMT, Uri Guttman <uri@stemsystems.com>
MD> wrote:
>> you should take a peek at the perl 6 world. many of the apl vector
>> flavored ops are getting into perl. you will be able to convert most
>> common ops to a vector form, e.g. a scalar can be added to all elements
MD> To your knowledge, will Perl 6 support cartesian products and the
MD> possibilty of iterating over them, e.g. with a syntax roughly of the
MD> kind of:
MD> for my ($x,$y) ((1..3)*(1..5)) {
MD> # do something...
MD> }
that has been discussed but i don't recall any resolution about full
cartesian products. in any case that will be much easier (if not built
in) in perl6. read the rfc's and see if it was proposed. i don't think
larry has covered that topic yet.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Tue, 21 Jan 2003 16:21:47 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: APL's relation to perl
Message-Id: <x7of6atqw4.fsf@mail.sysarch.com>
>>>>> "MD" == Michele Dondi <bik.mido@tiscalinet.it> writes:
MD> On 17 Jan 2003 11:07:57 -0800, genericax@hotmail.com (Sara) wrote:
>> I WISH! APL is (was) one of the best linear variable programming
>> languages in existence. Imagine a primitive function (domino) to
>> invert an arbitry matrix (of ANY number of dimensions even!). How many
MD> ^^^^^^^^^^
MD> <OT>
MD> I don't know APL, I am only a beginner in Perl, and OTOH I'm not an
MD> expert in (multi)linear algebra either, but AFAIK there's no (+ I
MD> can't devise a) generally accepted/acceptable notion of multiplication
MD> (and thus inversion) of "ANY number of dimension"-al matrices, while
MD> such a notion is natural for "2-dimensional" (that is, ordinary)
MD> matrices (that is rank 2 tensors). But maybe you meant something
MD> completely different...
MD> </OT>
the OP meant a 2 dimensional matrix but with any size. apl can handle
true N-dimensional matrices very easily but IIRC (and i am VERY rusty)
the inversion and related ops only work on 2-dim matrices. i could be
wrong but who cares as no one uses apl much these days.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Tue, 21 Jan 2003 19:10:39 +0100
From: Lorenz Blum <little_tux@gmx.net>
Subject: Re: avoid chaos -or- "protected" writing
Message-Id: <b0k2do$pr4e4$1@ID-68250.news.dfncis.de>
Michael Budash wrote:
>
> this really has nothing to do with perl, but i'll bite...
>
> - looong explanation -
that tells me it would be simplier if everyone sends "hidden" e.g. his
birthday which will be checked. So at least no one writes _accidentally_
writes into anoter one....
If it's not perl what else? JavaScript? HTML? f'up to? :)
thanks
lori
------------------------------
Date: 21 Jan 2003 09:52:49 -0800
From: mdbecker@acm.org (Michael Becker)
Subject: Blank line in perlpod?
Message-Id: <4b47df0.0301210952.2cda1489@posting.google.com>
Does anyone know how to create a single blank line in perlpod? If I
leave just one line break it sometimes will not leave a line break
when I use pod2text. If I leave 2 line breaks (i.e. seperate 2 things
by 1 blank line) my text is seperated by 1 blank line. How do I get
just a line break in this case?
------------------------------
Date: 21 Jan 2003 18:29:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Blank line in perlpod?
Message-Id: <b0k3ht$4nh$6@mamenchi.zrz.TU-Berlin.DE>
Michael Becker <mdbecker@acm.org> wrote in comp.lang.perl.misc:
> Does anyone know how to create a single blank line in perlpod? If I
> leave just one line break it sometimes will not leave a line break
> when I use pod2text. If I leave 2 line breaks (i.e. seperate 2 things
> by 1 blank line) my text is seperated by 1 blank line. How do I get
> just a line break in this case?
Only with literal (i.e. indented) text, afaik. Otherwise, it's markup
and speaks paragraphs. Lines (including empty lines) are its business,
not yours.
Anno
------------------------------
Date: 21 Jan 2003 19:03:04 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Blank line in perlpod?
Message-Id: <b0k5h8$2tj$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Anno Siegel:
> Michael Becker <mdbecker@acm.org> wrote in comp.lang.perl.misc:
>> Does anyone know how to create a single blank line in perlpod? If I
>> leave just one line break it sometimes will not leave a line break
>> when I use pod2text. If I leave 2 line breaks (i.e. seperate 2 things
>> by 1 blank line) my text is seperated by 1 blank line. How do I get
>> just a line break in this case?
>
> Only with literal (i.e. indented) text, afaik. Otherwise, it's markup
> and speaks paragraphs. Lines (including empty lines) are its business,
> not yours.
Perhaps the magical zero-width character Z<> might be worth a try. I had
to use it once for nested =over paragraphs to get proper newlines
between the inner =items.
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Tue, 21 Jan 2003 16:38:02 -0000
From: "Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Subject: Re: CGI.pm aligning radio buttons with pick-lists
Message-Id: <b0jssk$6iu$1$8300dec7@news.demon.co.uk>
Ben,
"Ben Morrow" <mauzo@ux-ma160-6.csv.warwick.ac.uk> wrote in message
news: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
<SNIP>
> This is an HTML problem, not a Perl problem.
Correction. This is a Perl problem, not an HTML problem.
I talked about using CGI.pm, the well known Perl Module.
This would have been clearer if I had posted some code.
IIRC my Perl code to use the radio_group() function went something like:
print $q->radio_group(
-name => 'Frequency',
'values' => [ qw/ Monthly Weekly Daily / ],
'default' => 'Weekly,
'linebreak => 1 # This stacks the
buttons vertically
);
Note: all Perl there - not a shred of HTML.
Page 247 of Lincoln Stein's "Official Guide to Programming with CGI.pm"
assures me:
"The radio_group() function creates a set of radio buttons all linked by a
common name. In a scalar context, the function returns a string containing
the properly formatted HTML tags. In an array context, the function returns
a list of radio button elements which you can then manipulate in whatever
way you like (such as incorporating it into a table in order to control the
layout)."
I do not understand the part about "array context" returning a "list of
radio button elements". (What is a "radio button element" in Perl?) But I
believe I should I should "manipulate . . . incorporating it into a table in
order to control the layout". The clues are all there. I just don't
follow them.
Regards,
Clyde
------------------------------
Date: 21 Jan 2003 16:54:54 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: CGI.pm aligning radio buttons with pick-lists
Message-Id: <slrnb2quqt.5ik.sholden@flexal.cs.usyd.edu.au>
On Tue, 21 Jan 2003 16:38:02 -0000,
Clyde Ingram <cingram@pjocsNOSPAMORHAM.demon.co.uk> wrote:
> Ben,
>
> "Ben Morrow" <mauzo@ux-ma160-6.csv.warwick.ac.uk> wrote in message
> news: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
><SNIP>
>> This is an HTML problem, not a Perl problem.
>
> Correction. This is a Perl problem, not an HTML problem.
>
> I talked about using CGI.pm, the well known Perl Module.
> This would have been clearer if I had posted some code.
> IIRC my Perl code to use the radio_group() function went something like:
>
> print $q->radio_group(
> -name => 'Frequency',
> 'values' => [ qw/ Monthly Weekly Daily / ],
> 'default' => 'Weekly,
> 'linebreak => 1 # This stacks the
> buttons vertically
> );
It's far better to copy and paste, rather than retypng and introducing
errors (such as the two missing 's above).
>
> Note: all Perl there - not a shred of HTML.
>
> Page 247 of Lincoln Stein's "Official Guide to Programming with CGI.pm"
> assures me:
>
> "The radio_group() function creates a set of radio buttons all linked by a
> common name. In a scalar context, the function returns a string containing
> the properly formatted HTML tags. In an array context, the function returns
> a list of radio button elements which you can then manipulate in whatever
> way you like (such as incorporating it into a table in order to control the
> layout)."
>
> I do not understand the part about "array context" returning a "list of
> radio button elements". (What is a "radio button element" in Perl?) But I
> believe I should I should "manipulate . . . incorporating it into a table in
> order to control the layout". The clues are all there. I just don't
> follow them.
An array context occurs when a lst is expected by perl, the above code,
for example has radio_group being used in an array context since print
takes a list and hence creates an array context. Print joins them all together
to make a string.
If you want to manipulate them you could do something like:
my @radios = $q->radio_group(
# code goes here
);
Each radio box is now an element in @radios.
Or you could do it inline such as:
print '<table><tr><td>', join('</td><td>', $q->radio_group(
#insert radio group arguments
)),'</td></tr></table>'
Note, that the CGI.pm documentation says radio_group can do the tables bit
itself anyway...
--
Sam Holden
------------------------------
Date: Tue, 21 Jan 2003 17:14:29 -0000
From: "Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Subject: Re: CGI.pm aligning radio buttons with pick-lists
Message-Id: <b0jv0v$77t$1$8300dec7@news.demon.co.uk>
Sam,
"Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
news:slrnb2quqt.5ik.sholden@flexal.cs.usyd.edu.au...
<SNIP>
> It's far better to copy and paste, rather than retypng and introducing
> errors (such as the two missing 's above).
Fair comment. (My Perl dev machine is remote from this Internet machine,
with an air gap. Hence my (unreliable) reliance on memory.)
<SNIP>
> An array context occurs when a lst is expected by perl, the above code,
> for example has radio_group being used in an array context since print
> takes a list and hence creates an array context. Print joins them all
together
> to make a string.
>
> If you want to manipulate them you could do something like:
>
> my @radios = $q->radio_group(
> # code goes here
> );
>
> Each radio box is now an element in @radios.
Quite right. I've just tried this, plus a call to Data::Dumper, which shows
a nice 3-element array. Which I now understand is ready for me to
manipulate as I choose. I'll try munging it with map() to append a
pick-list to the row containing each of the first 2 buttons.
> Or you could do it inline such as:
>
> print '<table><tr><td>', join('</td><td>', $q->radio_group(
> #insert radio group arguments
> )),'</td></tr></table>'
>
>
> Note, that the CGI.pm documentation says radio_group can do the tables bit
> itself anyway...
Then I'd better dig deeper . . .
Many thanks,
Clyde
------------------------------
Date: 21 Jan 2003 08:43:37 -0800
From: rickraster@hotmail.com (RR)
Subject: GD::Graph get_hotspot()
Message-Id: <97b4acf3.0301210843.43dd6072@posting.google.com>
Hi all,
Can anyone tell me how the get_hotspot method works for GD::Graph (or
illustrate with some sample code)? I am generating imagemaps for my
graphs, which work fine, but so far I've only been able to hard-code
the coords for the map. I think get_hotspot() will do what I need (get
the dynamic column coords), but I haven't been able to get it to
return any results for me.
Thanks for any help or advice.
Cheers,
Rick
------------------------------
Date: Tue, 21 Jan 2003 18:03:42 +0000
From: David Sparkmunster <david@morgmein.tk>
Subject: Re: got me foxed
Message-Id: <rrsq2v0vltpct1f64a5l1n9b507afiptpp@4ax.com>
On Sun, 19 Jan 2003 18:26:01 +0100, "Harald H.-J. Bongartz"
<bongie@gmx.net> wrote:
>Ah, so your Perl script should just return the user to this .shtml page?
>So, just tell the browser to do that: After everything is finished
>(i.e. after the call to writedata()) insert this:
> print redirect('http://url/of/your/shtml/file');
>where the URL must be changed appropriately.
>
>This generates a redirection header that tells the browser not to wait
>for any data but to go to the given URL.
Harald
aha! I've used your suggestion for a 'data changed' message page. But
this seems a yet more elegant solution.
I'll try this and use whichever seems to look best. One problem, 2
solutions!
Thanks
David
------------------------------------
David Thorpe
See my photo portfolio of royalty free pictures:
http://www.rebelartist.com/seller/dthorpe
See my theatre
The Surrey Stick Figure Theatre Of Death at:
http://www.c-cat.demon.co.uk/theatre/
------------------------------
Date: Tue, 21 Jan 2003 18:32:08 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: OO perl : object containing ref to other object
Message-Id: <2atq2vkvmfc6vi1sri42esokgsgi23nri8@4ax.com>
Harald H.-J. Bongartz bravely attempted to attach 22 electrodes of
knowledge
to the nipples of comp.lang.perl.misc by saying:
>Koos Pol wrote:
>> 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'. ;-) )
% perldoc perlstyle | grep -v ^$ | tail -3
o Be consistent.
o Be nice.
Page 5 (printed 1/21/03)
Be nice? damn! Must I?
------------------------------
Date: Tue, 21 Jan 2003 11:22:27 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: open file for reading a part of it
Message-Id: <b0js43$bi46@nrn2.NRCan.gc.ca>
Hi all,
I just want to open a file and read between $search and "EOF".
The file would look like:
somename
blabla
blabla
EOF
somename1
blabla
blabla
EOF
...
If $search would be "somename", I would like to output only:
somename
blabla
blabla
I tried different loops (foreach, while, etc. but I only get the "somename"
line...
#!/usr/local/bin/perl
use CGI qw(param);
use strict;
my $file = param("file");
my $search = param("search");
# define some static variables
my $absolute_output_path = "/www/netman/domains/outputs";
if (-e "$absolute_output_path/$file") {
&header;
open(TEMP, "< $absolute_output_path/$file") or die "Couldn't open $file for
reading: $!\n";
while (<TEMP>) {
if (/^$search/) {
print;
next unless /^EOF$/;
}
}
close(TEMP);
}
I believe the next statement hits the condition and never meet again, so
that's why it prints only the first line...
Any idea?
Christian
------------------------------
Date: Tue, 21 Jan 2003 11:00:04 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: open file for reading a part of it
Message-Id: <slrnb2qv4k.3an.tadmc@magna.augustmail.com>
Christian Caron <nospam@nospam.org> wrote:
> I just want to open a file and read between $search and "EOF".
^^^^^^^
^^^^^^^
perldoc -q between
"How can I pull out lines between two patterns that are
themselves on different lines?"
> The file would look like:
>
> somename
> blabla
> blabla
> EOF
> If $search would be "somename", I would like to output only:
>
> somename
> blabla
> blabla
> #!/usr/local/bin/perl
#!/usr/local/bin/perl -T
> my $file = param("file");
> open(TEMP, "< $absolute_output_path/$file") or die "Couldn't open $file for
> reading: $!\n";
Beware the crackers!
You better use taint checking if you are working with forms.
perldoc perlsec
> Any idea?
One idea would be to check the Perl FAQ *before* posting to
the Perl newsgroup!
print if /^$search$/ .. /^EOF$/;
But that outputs the line that matches the final pattern, if
you don't want that then:
--------------------------
#!/usr/bin/perl
use strict;
use warnings;
my $search = 'somename';
while ( <DATA> ) {
if ( /^$search$/ ) {
print;
last;
}
}
while ( <DATA> ) {
last if /^EOF$/;
print;
}
__DATA__
no name
bleble
bleble
EOF
somename
blabla
blabla
EOF
somenameNOT
foobar
barfoo
EOF
--------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Jan 2003 18:10:19 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: open file for reading a part of it
Message-Id: <b0k2eb$4nh$4@mamenchi.zrz.TU-Berlin.DE>
Christian Caron <nospam@nospam.org> wrote in comp.lang.perl.misc:
> Hi all,
>
> I just want to open a file and read between $search and "EOF".
>
> The file would look like:
>
> somename
> blabla
> blabla
> EOF
>
> somename1
> blabla
> blabla
> EOF
> ...
>
> If $search would be "somename", I would like to output only:
>
> somename
> blabla
> blabla
>
> I tried different loops (foreach, while, etc. but I only get the "somename"
> line...
>
> #!/usr/local/bin/perl
>
> use CGI qw(param);
> use strict;
>
> my $file = param("file");
> my $search = param("search");
>
> # define some static variables
> my $absolute_output_path = "/www/netman/domains/outputs";
>
> if (-e "$absolute_output_path/$file") {
> &header;
> open(TEMP, "< $absolute_output_path/$file") or die "Couldn't open $file for
> reading: $!\n";
> while (<TEMP>) {
> if (/^$search/) {
> print;
> next unless /^EOF$/;
> }
> }
> close(TEMP);
> }
>
> I believe the next statement hits the condition and never meet again, so
> that's why it prints only the first line...
>
> Any idea?
That's a case for the flip-flop operator, scalar "..", which is described
in, umm... perlop, I guess. It makes it quite easy:
while ( <DATA> ) {
print if /$search/ .. /^EOF/;
}
Oh, that prints "EOF" too. "print if /$search/ .. /^EOF/ and not /^EOF/",
then. Though I wonder if you actually need the EOF-line.
Anno
------------------------------
Date: Tue, 21 Jan 2003 18:35:10 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: open file for reading a part of it
Message-Id: <b0k3su$j0v$1@wisteria.csv.warwick.ac.uk>
tadmc@augustmail.com wrote:
> print if /^$search$/ .. /^EOF$/;
Oh, so _that's_ what it's for! I read the description of scalar .. in perlop a
while ago, and couldn't for the life of me work out when you would use it or
why .. was a suitable name...
Thank you for that piece of enlightenment.
Ben
------------------------------
Date: Tue, 21 Jan 2003 13:34:25 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: Re: open file for reading a part of it
Message-Id: <b0k3rh$bi47@nrn2.NRCan.gc.ca>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnb2qv4k.3an.tadmc@magna.augustmail.com...
> Christian Caron <nospam@nospam.org> wrote:
>
>
> > I just want to open a file and read between $search and "EOF".
> ^^^^^^^
> ^^^^^^^
> perldoc -q between
>
> "How can I pull out lines between two patterns that are
> themselves on different lines?"
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> my $search = 'somename';
>
> while ( <DATA> ) {
> if ( /^$search$/ ) {
> print;
> last;
> }
> }
>
> while ( <DATA> ) {
> last if /^EOF$/;
> print;
> }
Thanks for the hint... Next time, I'll definitely search through perldoc
first.
Christian
------------------------------
Date: Tue, 21 Jan 2003 13:35:26 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: Re: open file for reading a part of it
Message-Id: <b0k3te$bj68@nrn2.NRCan.gc.ca>
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:b0k2eb$4nh$4@mamenchi.zrz.TU-Berlin.DE...
> Christian Caron <nospam@nospam.org> wrote in comp.lang.perl.misc:
> > Hi all,
> >
> > I just want to open a file and read between $search and "EOF".
> >
> That's a case for the flip-flop operator, scalar "..", which is described
> in, umm... perlop, I guess. It makes it quite easy:
>
> while ( <DATA> ) {
> print if /$search/ .. /^EOF/;
> }
>
> Oh, that prints "EOF" too. "print if /$search/ .. /^EOF/ and not /^EOF/",
> then. Though I wonder if you actually need the EOF-line.
>
> Anno
>
I just can't believe it's that simple...
Thanks!
Christian
------------------------------
Date: Tue, 21 Jan 2003 16:33:55 -0000
From: "Steve C" <sjcole@no_spam.hotmail.com>
Subject: Re: Paragraph Mode
Message-Id: <v2qti9phh229bb@corp.supernews.com>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnb2qos3.2s8.tadmc@magna.augustmail.com...
> You are misusing the Llama.
>
> The Llama book is a _tutorial_, not a reference.
>
I agree with you.
I recently purchased the Llama with the intention to 'learn' Perl (which is
what I've been doing).
My intention is to purchase the Camel book once I've completed the Llama
book.
I merely thought I would just see if it covered Paragraph Mode as it was to
hand on my desk; which is why I mentioned I checked in the Llama !
I should also add that I personally find it a *very* good tutorial.
Regards
Steve.
------------------------------
Date: Tue, 21 Jan 2003 11:08:28 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Paragraph Mode
Message-Id: <slrnb2qvkc.3eg.tadmc@magna.augustmail.com>
[ I tried to send email after removing the "no_spam."
(demunging is something I am almost never inclined to do...)
It bounced.
You should make it clear that your address in non-deliverable,
not just munged: sjcole@no_spam.hotmail.com.invalid or something.
]
Steve C <sjcole@no_spam.hotmail.com> wrote:
> I recently purchased the Llama with the intention to 'learn' Perl
> I should also add that I personally find it a *very* good tutorial.
You are preaching to the choir there. :-)
(check the "Acknowledgments")
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 16:27:12 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Reverse Inheritance?
Message-Id: <x7k7gytqn3.fsf@mail.sysarch.com>
>>>>> "BM" == Ben Morrow <mauzo@ux-ma160-6.csv.warwick.ac.uk> writes:
BM> 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.
BM> Hang on, surely if you're about to call back to the compiler
BM> anyway to do the require (which is but a do which is but a string
BM> eval in disguise), then the effect is completely negligible. You
BM> might get problems where either:
BM> 1. you hadn't just set the variable the line before so you weren't
BM> sure what it contained.
so use block eval to catch a bad module name.
BM> 2. There is a significant chance of the module having been loaded
BM> already, which there isn't in the OP's case.
require checks for that so there is no problem.
require works fine at run time and no string eval is needed. for the odd
cases where use is needed at runtime, then string eval is (a poor) solution.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Tue, 21 Jan 2003 19:00:24 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Reverse Inheritance?
Message-Id: <b0k5c8$k27$1@wisteria.csv.warwick.ac.uk>
Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "BM" == Ben Morrow <mauzo@ux-ma160-6.csv.warwick.ac.uk> writes:
> BM> Hang on, surely if you're about to call back to the compiler
> BM> anyway to do the require (which is but a do which is but a string
> BM> eval in disguise), then the effect is completely negligible. You
> BM> might get problems where either:
>
> BM> 1. you hadn't just set the variable the line before so you weren't
> BM> sure what it contained.
>
>so use block eval to catch a bad module name.
I wasn't quite saying that. What I meant (I should have made You might... a
new para) was that _given_ I had (in my answer to the OP) set the variable I
was about to eval the previous line, there was no security risk in evaling it.
>
> BM> 2. There is a significant chance of the module having been loaded
> BM> already, which there isn't in the OP's case.
>
>require checks for that so there is no problem.
No. However, if you do use string eval then there may be an unnecessary
performance hit due to restarting the compiler.
>require works fine at run time and no string eval is needed.
Umm, I am very hesitant to contradict you, but...
$module = "File::Copy";
require $module;
does not work, by which I mean it does not do the same thing as either
require File::Copy;
or
$module = "File::Copy";
eval "require $module";
To make this work is system-dependant: on most systems, yes, you can use
require "File/Copy.pm";
to pull in a module whose name isn't determined till runtime, but tranforming
the "File::Copy" you need to refer to the package therafter into "File/Copy.pm"
is rather a messy operation. The only portable way to do it is to use
File::Spec, and I'm not sure whether a Mac would want
require "File:Copy.pm";
or
require ":File:Copy.pm";
. I guess the latter.
eval is also the answer recommended in perldoc -f require.
> for the odd
>cases where use is needed at runtime, then string eval is (a poor) solution.
I fully agree here. Use is never needed at runtime. The solution I would use
is
$module = "File::Copy";
eval "require $module";
import $module qw/args/;
.
Am I missing something here? Is there a solution that doesn't require eval
(well, except in the sense that a require is a do is an eval)?
Ben
------------------------------
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 4440
***************************************