[23936] in Perl-Users-Digest
Perl-Users Digest, Issue: 6137 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 15 18:05:42 2004
Date: Sun, 15 Feb 2004 15:05:09 -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 Sun, 15 Feb 2004 Volume: 10 Number: 6137
Today's topics:
Re: Choosing grouping of split items (Anno Siegel)
Re: configure problem <jwillmore@remove.adelphia.net>
Re: configure problem <alan@asandco.co.uk>
Re: configure problem <usenet@morrow.me.uk>
Re: Environment question <tore@aursand.no>
Re: Environment question <uri@stemsystems.com>
Re: Environment question <jwillmore@remove.adelphia.net>
Re: Environment question <gnari@simnet.is>
Example of web application done right? <glen_ap@NOyahooSPAM.com>
Re: Example of web application done right? <tadmc@augustmail.com>
Re: Example of web application done right? <ceo@nospan.on.net>
Re: Example of web application done right? thumb_42@yahoo.com
how to download part of a pdf file (KK)
Quoting does not work in replace? (Hans Deragon)
Re: Quoting does not work in replace? (Anno Siegel)
Re: Quoting does not work in replace? <kevin@vaildc.net>
Re: Quoting does not work in replace? <matthew.garrish@sympatico.ca>
Re: Quoting does not work in replace? <tadmc@augustmail.com>
Re: Understanding 'scope' (Anno Siegel)
Re: Why is Perl losing ground? (Unknown Poster)
Re: Why is Perl losing ground? <usenet@morrow.me.uk>
Re: XML::Parser Style => Object <bart.lateur@pandora.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Feb 2004 20:55:54 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Choosing grouping of split items
Message-Id: <c0omcq$a0d$1@mamenchi.zrz.TU-Berlin.DE>
Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> >>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
>
> AS> my @tokens = split /-/, $str;
> AS> @tokens = ( "$tokens[ 0]-$tokens[ 1]", @tokens[ 2 .. $#tokens]) if
> AS> @tokens > 3;
>
> blech!
Agreed.
> $tokens[0] .= '-' . splice( @tokens, 1, 1 ) if @tokens > 3;
Much better.
> or
>
> splice( @tokens, 0, 2 ) = join '-', splice( @tokens, 1, 1 )
> if @tokens > 3;
That's splice( @tokens, ...) twice in a single statement.
Anno
------------------------------
Date: Sun, 15 Feb 2004 14:52:32 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: configure problem
Message-Id: <pan.2004.02.15.19.52.30.560363@remove.adelphia.net>
On Sun, 15 Feb 2004 18:54:04 +0000, Alan secker wrote:
> Tony Curtis wrote:
>>>>On Sun, 15 Feb 2004 17:03:56 +0000,
>>>>Alan secker <alan@asandco.co.uk> said:
>>
>>
>>>I am trying to install per 5.8.3 on a Linux Mandrake 9.2
>>>system and failing at the confiuration stage. It seems that
>>>regardless of the options that I select, I end up with the
>>>following:
>>
>>
>>>The command the script builds to run a test file is:
>>
>>
>>>gcc -0 try try.c -lnsl -lndbm -ldb -ldl -lm -lcrypt -lutil
>>>-lc ./try
>>
>>
>> Are you *sure* that's exactly the attempted command?
>>
>> Cut-n-paste it, don't try to copy by hand.
>>
>> OTOH if that *is* the real command, something else is
>> seriously messed up.
> This is the cut 'n paste as generated at the end of configure:
>
> <START>
> I used the command:
>
> gcc -o try -O3 -fno-strict-aliasing -I/usr/local/include
> -L/usr/local/lib try.c -lnsl -lndbm -ldb -ldl -lm -lcrypt -lutil -lc
> ./try
>
> and I got the following output:
>
> /usr/lib/libndbm.so: undefined reference to `errno'
> collect2: ld returned 1 exit status
> I can't compile the test program.
> (The supplied flags or libraries might be incorrect.)
>
> <END>
Just a guess ....
Do you have NDBM installed? Is it the most up to date version? How about
the header (development RPM) files installed?
It seems to me that this is where the problem lies. Some distros of Linux
alter the various db libraries in such a way that it takes something short
of an act of God to set things right (Berkeley DB on SuSE comes to mind -
which I had to jump through hoops to get to work right).
Like I said ... it's just a guess.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Forms follow function, and often obliterate it.
------------------------------
Date: Sun, 15 Feb 2004 22:25:26 +0000
From: Alan secker <alan@asandco.co.uk>
Subject: Re: configure problem
Message-Id: <c0orj4$2bf$1@news.freedom2surf.net>
James Willmore wrote:
<SNIP>
> Just a guess ....
> Do you have NDBM installed? Is it the most up to date version? How about
> the header (development RPM) files installed?
>
> It seems to me that this is where the problem lies. Some distros of Linux
> alter the various db libraries in such a way that it takes something short
> of an act of God to set things right (Berkeley DB on SuSE comes to mind -
> which I had to jump through hoops to get to work right).
>
> Like I said ... it's just a guess.
>
> HTH
<SNIP/>
I certainly didn't have NDBS installed. In facr after shooting through
25 pages of Google I'd be surprtised if anyone has! It certainly is a
mysterious entity to nail down. I found something called NDBM_file.pl.
is that it?
As for the header files.Which header files would they be?
Sorry to be so dense.
Alan
------------------------------
Date: Sun, 15 Feb 2004 22:54:52 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: configure problem
Message-Id: <c0otbs$gfa$1@wisteria.csv.warwick.ac.uk>
Alan secker <alan@asandco.co.uk> wrote:
> James Willmore wrote:
>
> > Just a guess ....
> > Do you have NDBM installed? Is it the most up to date version? How about
> > the header (development RPM) files installed?
> >
> > It seems to me that this is where the problem lies. Some distros of Linux
> > alter the various db libraries in such a way that it takes something short
> > of an act of God to set things right (Berkeley DB on SuSE comes to mind -
> > which I had to jump through hoops to get to work right).
>
> I certainly didn't have NDBS installed.
You do, or at least you have it partly installed. You have
/usr/lib/libndbm.so, which is the NDBM shared library.
> In facr after shooting through
> 25 pages of Google I'd be surprtised if anyone has! It certainly is a
> mysterious entity to nail down. I found something called NDBM_file.pl.
> is that it?
*Please* be precise. It really matters with this sort of thing. You
(almost certainly) found something called NDBM_File.pm. No, that is
not it: that is the Perl module to interface to the ndbm C library.
> As for the header files.Which header files would they be?
The ndbm header files :). Specifically, either /usr/include/ndbm.h or
/usr/include/gdbm/ndbm.h (according to Configure).
1. Do you have either of these files?
2. If you do, is it a symlink to somewhere else? Where?
3. Is /usr/lib/libndbm.so a symlink? Where to?
4. I take it you're using glibc... what do you get if you run
/lib/libc.so.6
(yes, I do mean execute the shared library as an executable)?
5. What do you get from
nm -D /usr/lib/libndbm.so | grep errno
?
6. If you know how, enquire of your package-management system whether
you have ndbm installed... rpm -q ndbm springs to mind, but it's
(thankfully) a long time since I last had to use rpm.
> Sorry to be so dense.
That's fine: these things are not easy to understand. It is important
to be accurate, though.
Ben
--
Razors pain you / Rivers are damp
Acids stain you / And drugs cause cramp. [Dorothy Parker]
Guns aren't lawful / Nooses give
Gas smells awful / You might as well live. ben@morrow.me.uk
------------------------------
Date: Sun, 15 Feb 2004 20:19:45 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Environment question
Message-Id: <pan.2004.02.15.19.19.44.727145@aursand.no>
On Sun, 15 Feb 2004 17:26:05 +0000, Uri Guttman wrote:
> ever heard of the web? or amazon or barnes & noble? how about
> book.perl.org?
Just to get it 100% correct, so the OP doesn't have any excuses for not
finding the site;
<http://books.perl.org/>
--
Tore Aursand <tore@aursand.no>
"A car is not the only thing that can be recalled by its maker." --
Unknown
------------------------------
Date: Sun, 15 Feb 2004 19:21:35 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Environment question
Message-Id: <x74qts87y9.fsf@mail.sysarch.com>
>>>>> "TA" == Tore Aursand <tore@aursand.no> writes:
TA> On Sun, 15 Feb 2004 17:26:05 +0000, Uri Guttman wrote:
>> ever heard of the web? or amazon or barnes & noble? how about
>> book.perl.org?
TA> Just to get it 100% correct, so the OP doesn't have any excuses for not
TA> finding the site;
TA> <http://books.perl.org/>
oop! (sic)
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 15 Feb 2004 14:56:38 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Environment question
Message-Id: <pan.2004.02.15.19.56.36.39348@remove.adelphia.net>
On Sun, 15 Feb 2004 08:25:23 -0600, Bill Staples wrote:
>
>>
>> no include statement? where did you learn perl? perl has at least 3
>> include-like operations and eval which means you can roll your own as
>> well. and do you think all the massive amounts of perl code written is
>> only in large files? and what about cpan?
>>
>> please be learning more perl before making wrong statements like this.
>>
>> uri
>
> I didn't say I "learned' perl. I just said I was using it and I still
> think I am right about the fact that perl has no include statement. Maybe
> I should have said that perl apparently has no "include" statement to make
> it specific.
Hummm .....
jim@maxine:~> perl --help
Usage: perl [switches] [--] [programfile] [arguments]
-0[octal] specify record separator (\0, if no argument)
-a autosplit mode with -n or -p (splits $_ into @F)
-C enable native wide character system interfaces
-c check syntax only (runs BEGIN and CHECK blocks)
-d[:debugger] run program under debugger
-D[number/list] set debugging flags (argument is a bit mask or alphabets)
-e 'command' one line of program (several -e's allowed, omit programfile)
-F/pattern/ split() pattern for -a switch (//'s are optional)
-i[extension] edit <> files in place (makes backup if extension supplied)
-Idirectory specify @INC/#include directory (several -I's allowed)
-l[octal] enable line ending processing, specifies line terminator
-[mM][-]module execute `use/no module...' before executing program
-n assume 'while (<>) { ... }' loop around program
-p assume loop like -n but print line also, like sed
-P run program through C preprocessor before compilation
-s enable rudimentary parsing for switches after programfile
-S look for programfile using PATH environment variable
-T enable tainting checks
-t enable tainting warnings
-u dump core after parsing program
-U allow unsafe operations
-v print version, subversion (includes VERY IMPORTANT perl info)
-V[:variable] print configuration summary (or a single Config.pm variable)
-w enable many useful warnings (RECOMMENDED)
-W enable all warnings
-X disable all warnings
-x[directory] strip off text before #!perl line and perhaps cd to directory
jim@maxine:~>
Pay attention to the '-I' switch. But hey, what do I know :-)
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
If you want to know what god thinks of money, just look at the
people he gave it to. -- Dorthy Parker
------------------------------
Date: Sun, 15 Feb 2004 20:01:57 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Environment question
Message-Id: <c0oj5u$69v$1@news.simnet.is>
"Bill Staples" <none@none.com> wrote in message
news:pan.2004.02.15.01.44.44.642120@none.com...
>
> I am wanting to do a much larger project totally in perl which brings up
> the question. Do heavy perl coders make just one huge source file?
I am sure that some do
[snip about apparent lack of include equivalent]
in addition to other replies on the thread, I might mention
the -P commantline argument to perl that passes the script through cpp,
enabling among other the #include directive. of course cpp must be
available.
actually, I wonder why this feature is supported. does anyone use it?
> It would be easy enough to make a script to merge different sources and
> then hand them to perl but that seems to be a kludge and there must be a
> different answer - or is there?
actually, for someone used to using make, it is simple and natural to
assemble a target bigscript.pl from smaller source files.
for big projects you dont want to be editing the production code
anyways, and a
make
make test
make install
sequence is needed anyways, so why not have the 'make'
cat together your snippets
gnari
------------------------------
Date: Sun, 15 Feb 2004 15:06:50 -0500
From: Glen Pfeiffer <glen_ap@NOyahooSPAM.com>
Subject: Example of web application done right?
Message-Id: <402fd0ff$0$3088$61fed72c@news.rcn.com>
Hi all. I am building a new web application and am evaluating different
technologies. I was wondering if anyone can recommend a large web
application in Perl that was "done right" so I can look at the source
code to evaluate it and determine if I want to use Perl.
This is not a "What is the best language?" question. I merely want to
look at an application that is easy to extend/modify/maintain which
separates logic from display code, and compare it to some other
applications done in other languages. I have experience building large
sites in other languages, but not in Perl. Some thoughts I have had are
WebGUI, YaBB and YAWP.
Thanks,
Glen
------------------------------
Date: Sun, 15 Feb 2004 14:28:20 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Example of web application done right?
Message-Id: <slrnc2vlj4.1o6.tadmc@magna.augustmail.com>
Glen Pfeiffer <glen_ap@NOyahooSPAM.com> wrote:
> Hi all. I am building a new web application and am evaluating different
> technologies. I was wondering if anyone can recommend a large web
> application in Perl that was "done right" so I can look at the source
> code to evaluate it and determine if I want to use Perl.
How about SlashDot?
http://sourceforge.net/projects/slashcode/
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 15 Feb 2004 22:04:28 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: Example of web application done right?
Message-Id: <M1SXb.22625$YY1.11758@newssvr16.news.prodigy.com>
Glen Pfeiffer wrote:
> Hi all. I am building a new web application and am evaluating different
> technologies. I was wondering if anyone can recommend a large web
> application in Perl that was "done right" so I can look at the source
> code to evaluate it and determine if I want to use Perl.
>
> This is not a "What is the best language?" question. I merely want to
> look at an application that is easy to extend/modify/maintain which
> separates logic from display code, and compare it to some other
> applications done in other languages. I have experience building large
> sites in other languages, but not in Perl. Some thoughts I have had are
> WebGUI, YaBB and YAWP.
>
Moveable Type. It's written entirely in Perl, makes excellent use of
Perl OOP and modules and uses my personal favorite web templating system
-- HTML::Template. You can download the full source from
http://www.moveabletype.org.
I would consider any web site written in Perl that made use of
HTML::Template or Template Toolkit to be at least a step in the right
direction and for the author of such to have some understanding of
separating logic from presentation layer which I consider absolutely
necessary. I seldom write *test* code in Perl apart from HTML::Template
for that very reason. I would think you would definitely want to look
at those two tools.
There was also very recently -- within the last year -- a sample web
application in Perl written up in either _Linux Magazine_ or _Linux
Journal_ that made use of Template Toolkit that looked pretty good too.
If I have a chance to look it up later I will and report here.
Randall Schwartz uses Template Toolkit also so you might check out his
StoneHenge site: http://www.stonehenge.com
Chris
-----
Chris Olive
chris -at- --this-is-bogus-- technologEase -dot- com
http://www.technologEase.com
(pronounced "technologies")
------------------------------
Date: Sun, 15 Feb 2004 22:39:10 GMT
From: thumb_42@yahoo.com
Subject: Re: Example of web application done right?
Message-Id: <iySXb.43206$_44.39503@attbi_s52>
Glen Pfeiffer <glen_ap@noyahoospam.com> wrote:
> Hi all. I am building a new web application and am evaluating different
> technologies. I was wondering if anyone can recommend a large web
> application in Perl that was "done right" so I can look at the source
> code to evaluate it and determine if I want to use Perl.
>
> This is not a "What is the best language?" question. I merely want to
> look at an application that is easy to extend/modify/maintain which
> separates logic from display code, and compare it to some other
> applications done in other languages. I have experience building large
> sites in other languages, but not in Perl. Some thoughts I have had are
> WebGUI, YaBB and YAWP.
I can't give you the code, as it was proprietary :-( But I can explain the
design:
We used an 'N'-tier model, with perl daemon(s) running on several machines.
The web portion used a distributed directory to look for a list of back-ends
that were currently available, contacted the backend, submitted the
operation(s) and processed the results. (here operations would refer to
database inserts, user add, queries, fetching mirrored file data, etc..)
The idea was that these back-ends would do all the heavy lifting, provide
additional scale (need more processing? add more machines) and completely
abstract the database from the web front.
The back-end contacted a database for a great deal of it's work. To
accomplish portability (and improve maintenance) we used an XML format for
each SQL statement the system used. (this was of course, cached. we didn't
parse the document every time we needed a database operation) this XML
document of SQL statements proved very useful, we were able to port
everything from postgresql to DB2 in about 45 minutes. :-) It also proved
extremely useful for tuning later on as the database grew in size, the
SQL was clearly visable and easily modified by altering this one document.
Keeping database handles around on the web side proved to be very
problematic, even with mod_perl. I would not recommend it. We ended up
ripping every bit of code that referred to a database handle out of the web
front.
We were successfully able to take down any machine for maintenance without a
service outage, with the exception of the database server. (and we did take
down the servers 1 by one on a few occassions w/out service outages)
This was a very important feature for this project, because as you know,
servers need upgrades and maintenance. Having redundancy is important, but
everything has to be designed to work in that type of environment.
In theory, we would have been able to take down the database server too
if we had the license and hardware to mirror it, and/or had designed some
of these back-ends to "queue" data inserts.
As far as the web front.. I would really not recommend perl for this
portion. (at this time) But, if you're going to do it, keep it a very simple
model-view-controller, and use a templating system that makes sense for your
needs. Be very wary of any session handling, as soon as you need session
data you'll have a mess in keeping synchronized sessions across multiple web
hosts. (session handling was by far the biggest issue we had with this
thing)
Jamie
------------------------------
Date: 15 Feb 2004 12:38:26 -0800
From: kewlkarun@yahoo.com (KK)
Subject: how to download part of a pdf file
Message-Id: <c8fd5039.0402151238.3bc85beb@posting.google.com>
Hi there, Just wondering if any of the perl modules allow me to
download only a part of a pdf file (infact, I need only the first
page)?
Regards,
-KK
------------------------------
Date: 15 Feb 2004 13:59:36 -0800
From: hans@deragon.biz (Hans Deragon)
Subject: Quoting does not work in replace?
Message-Id: <c7427279.0402151359.59d3006d@posting.google.com>
Greetings.
I want to parse a file and replace a string with another, in my
example, replace @sysconfdir@ with /etc. The command:
perl -wp -e "s/\@sysconfdir\@/\Q/etc\E/;" <file>
...and off course, the error (else I would not be writing here ;) ):
Bareword found where operator expected at -e line 1, near
"s/\@sysconfdir\@/\Q/etc"
Unquoted string "tc" may clash with future reserved word at -e line 1.
Backslash found where operator expected at -e line 1, near "tc\"
syntax error at -e line 1, near "s/\@sysconfdir\@/\Q/etc"
Execution of -e aborted due to compilation errors.
Anybody would care to explain why \Q does not work here, and what I
can do to fix it? I would like a one liner solution. Manually
backquoting / ("\/") does not work either.
If / in /etc is removed, it works as expected. / is simply not
quoted.
Best regards,
Hans Deragon
--
Consultant en informatique/Software Consultant
Deragon Informatique inc. Open source:
http://www.deragon.biz http://autopoweroff.sourceforge.net
mailto://hans@deragon.biz (Automatically poweroff home servers)
------------------------------
Date: 15 Feb 2004 22:33:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Quoting does not work in replace?
Message-Id: <c0os44$dvk$1@mamenchi.zrz.TU-Berlin.DE>
Hans Deragon <hans@deragon.biz> wrote in comp.lang.perl.misc:
> Greetings.
>
>
> I want to parse a file and replace a string with another, in my
> example, replace @sysconfdir@ with /etc. The command:
>
> perl -wp -e "s/\@sysconfdir\@/\Q/etc\E/;" <file>
>
> ...and off course, the error (else I would not be writing here ;) ):
>
> Bareword found where operator expected at -e line 1, near
> "s/\@sysconfdir\@/\Q/etc"
> Unquoted string "tc" may clash with future reserved word at -e line 1.
> Backslash found where operator expected at -e line 1, near "tc\"
> syntax error at -e line 1, near "s/\@sysconfdir\@/\Q/etc"
> Execution of -e aborted due to compilation errors.
>
> Anybody would care to explain why \Q does not work here, and what I
> can do to fix it? I would like a one liner solution. Manually
> backquoting / ("\/") does not work either.
It should. In fact, it does for me.
/Q and friends work in double-quotish context, but in substitutions like
yours "/" delimits that context, but isn't part of it. Only direct
backwhacking helps with delimiters.
That's why Perl lets you chose the delimiter. Write it
s{\@sysconfdir\@}{/etc}
or, since you don't do interpolation
s'@sysconfdir@'/etc'
with no quoting at all.
Anno
------------------------------
Date: Sun, 15 Feb 2004 17:35:20 -0500
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: Quoting does not work in replace?
Message-Id: <kevin-CEEF2A.17352015022004@news101.his.com>
In article <c7427279.0402151359.59d3006d@posting.google.com>,
hans@deragon.biz (Hans Deragon) wrote:
> Greetings.
>
>
> I want to parse a file and replace a string with another, in my
> example, replace @sysconfdir@ with /etc. The command:
>
> perl -wp -e "s/\@sysconfdir\@/\Q/etc\E/;" <file>
>
> ...and off course, the error (else I would not be writing here ;) ):
>
> Bareword found where operator expected at -e line 1, near
> "s/\@sysconfdir\@/\Q/etc"
> Unquoted string "tc" may clash with future reserved word at -e line 1.
> Backslash found where operator expected at -e line 1, near "tc\"
> syntax error at -e line 1, near "s/\@sysconfdir\@/\Q/etc"
> Execution of -e aborted due to compilation errors.
>
> Anybody would care to explain why \Q does not work here, and what I
> can do to fix it? I would like a one liner solution.
It looks like \Q plain doesn't work on the replacement side.
> Manually
> backquoting / ("\/") does not work either.
This works for me:
perl -c -w -e "s/\@sysconfdir\@/\/etc/"
at least it gets no syntax errors. But I'd be more likely to do this as
s{\@sysconfdir\@}{/etc}
to avoid having to escape the slash at all.
--
Found Poetry (_Science News_, 14-Jun-2003): oldest _homo sapiens_ find
+-----------------------------------------+ ocean eddies' far-flung effects;
| Kevin Michael Vail <kevin@vaildc.net> | superior threads spun
+-----------------------------------------+ the pox from prairie dogs.
------------------------------
Date: Sun, 15 Feb 2004 17:27:12 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Quoting does not work in replace?
Message-Id: <0nSXb.2534$Cd6.75412@news20.bellglobal.com>
"Hans Deragon" <hans@deragon.biz> wrote in message
news:c7427279.0402151359.59d3006d@posting.google.com...
> Greetings.
>
>
> I want to parse a file and replace a string with another, in my
> example, replace @sysconfdir@ with /etc. The command:
>
> perl -wp -e "s/\@sysconfdir\@/\Q/etc\E/;" <file>
>
> ...and off course, the error (else I would not be writing here ;) ):
>
> Bareword found where operator expected at -e line 1, near
> "s/\@sysconfdir\@/\Q/etc"
> Unquoted string "tc" may clash with future reserved word at -e line 1.
> Backslash found where operator expected at -e line 1, near "tc\"
> syntax error at -e line 1, near "s/\@sysconfdir\@/\Q/etc"
> Execution of -e aborted due to compilation errors.
>
> Anybody would care to explain why \Q does not work here, and what I
> can do to fix it? I would like a one liner solution. Manually
> backquoting / ("\/") does not work either.
>
Works fine for me if I escape the slash. And \Q doesn't escape the slash
because the slash is also your delimiter. You might think it would make
sense to escape it, but the \E is optional in a regex, so if it didn't
recognize the delimiter as a delimiter, well then the \E would no longer be
optional would it...
Matt
------------------------------
Date: Sun, 15 Feb 2004 16:42:40 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Quoting does not work in replace?
Message-Id: <slrnc2vtf0.1tq.tadmc@magna.augustmail.com>
Hans Deragon <hans@deragon.biz> wrote:
> perl -wp -e "s/\@sysconfdir\@/\Q/etc\E/;" <file>
> Bareword found where operator expected at -e line 1, near
> "s/\@sysconfdir\@/\Q/etc"
> Anybody would care to explain why \Q does not work here,
Perl never got far enough in its parse to recognize the \Q.
It was looking for the extent of the 2 parts of the s///,
_then_ it would turn to interpolating whatever ended up
in the parts.
> and what I
> can do to fix it?
It should have never even happened. :-)
You should consider choosing alternate delimiters for m// and s///
where one of the parts is to contain a literal slash.
I like s### for one-liners:
perl -wp -e "s#\@sysconfdir@#/etc#"
> Manually
> backquoting / ("\/") does not work either.
perl -wp -e "s/\@sysconfdir@/\/etc/"
It works for me. Are you sure you were backslashing the right slash?
(that confusion is not even possible with alternate delimiters...)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 15 Feb 2004 21:54:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Understanding 'scope'
Message-Id: <c0opr0$bjm$1@mamenchi.zrz.TU-Berlin.DE>
Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> >>>>> "DKW" == David K Wall <dwall@fastmail.fm> writes:
> DKW> Somewhat more facetiously: Perl gives you the freedom to program however
> DKW> you like. It's up to you to choose between Good and Evil. :-)
>
> perl supporting package globals is needed. using them is not always
> needed. is that helpful?
Add to that:
Early in Perl 6 development there were (of course) quite a few requests
to make the default variable type lexical. Larry's reply: "Oh no".
Anno
------------------------------
Date: 15 Feb 2004 14:54:34 -0800
From: use63net@yahoo.com (Unknown Poster)
Subject: Re: Why is Perl losing ground?
Message-Id: <c62e93ec.0402151454.3cfa5eec@posting.google.com>
Bart Lateur <bart.lateur@pandora.be> wrote in message news:<19lu20hccgbhcs4qngakbg6r5jk05dltvo@4ax.com>...
> Ben Morrow wrote:
>
>
> Which reminds me... The motto for Perl is TIMTOWTDI, there's more than
> one road to Rome, which some people think is a bad thing, because other
> languages enforce the One True Way to do something. So Perl gives you
> the freedom, while the other languages don't. *shrug*
>
Just look at chapter 12 of Programming Perl.
TIMTOWTDI simply ain't gonna work with object oriented analysis, design,
and programming.
The large software projects that will be developed through a complete OO
process can't be done 20% the way Bob likes it, 25% Ann likes it,
15% Raoul likes it, and 40% the only way the project manager knows
how to do it.
------------------------------
Date: Sun, 15 Feb 2004 22:59:19 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Why is Perl losing ground?
Message-Id: <c0otk7$gfa$2@wisteria.csv.warwick.ac.uk>
use63net@yahoo.com (Unknown Poster) wrote:
> Bart Lateur <bart.lateur@pandora.be> wrote in message news:<19lu20hccgbhcs4qngakbg6r5jk05dltvo@4ax.com>...
> >
> > Which reminds me... The motto for Perl is TIMTOWTDI, there's more than
> > one road to Rome, which some people think is a bad thing, because other
> > languages enforce the One True Way to do something. So Perl gives you
> > the freedom, while the other languages don't. *shrug*
> >
>
> Just look at chapter 12 of Programming Perl.
>
> TIMTOWTDI simply ain't gonna work with object oriented analysis, design,
> and programming.
>
> The large software projects that will be developed through a complete OO
> process can't be done 20% the way Bob likes it, 25% Ann likes it,
> 15% Raoul likes it, and 40% the only way the project manager knows
> how to do it.
Right... so for such a project, you write a set of coding guidelines
that standardises how it's going to be done. And everyone follows
them. Where's the problem?
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Sun, 15 Feb 2004 19:13:38 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: XML::Parser Style => Object
Message-Id: <06hv20975o7bvi2djkljtbviilqbii7df6@4ax.com>
Ben Morrow wrote:
>I was under the impression that XML::Parser was more-or-less
>deprecated now, in favour of SAX... is that not correct?
That was what Matt Sergeant, maintainer of most of the XML modules,
seems to be wanting, yes. I'm not sure I agree.
--
Bart.
------------------------------
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 6137
***************************************