Re: One liner to change one line

2007-08-16 Thread Chas Owens
On 8/16/07, John W. Krahn <[EMAIL PROTECTED]> wrote: snip > The object created by qr// *is* a compiled regex: snip Yeah my bad, the stringification confused me for a minute. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: One liner to change one line

2007-08-16 Thread Gunnar Hjalmarsson
Chas Owens wrote: qr// is just a fancy double quote that adds a non-capturing group and sets the appropriate options (in case you did something like qr/foo/i). The string "(?:-xism:foo)" is no more or less a regex than the string "foo". Let's look into that. C:\home>type test.pl $re1 = '(?i-x

Re: One liner to change one line

2007-08-16 Thread John W. Krahn
Chas Owens wrote: On 8/16/07, Paul Lalli <[EMAIL PROTECTED]> wrote: snip Silly rhetorical-ness aside, you seem unfamiliar with the term you introduced to this thread: "string form of a regexp": $ perl -le' $a = q{foo}; $b = qr{foo}; print $a; print $b; ' foo (?-xism:foo) My assertion is that y

Re: One liner to change one line

2007-08-16 Thread Chas Owens
On 8/16/07, Paul Lalli <[EMAIL PROTECTED]> wrote: snip > Silly rhetorical-ness aside, you seem unfamiliar with the term you > introduced to this thread: "string form of a regexp": > > $ perl -le' > $a = q{foo}; > $b = qr{foo}; > print $a; > print $b; > ' > foo > (?-xism:foo) > > My assertion is tha

Re: One liner to change one line

2007-08-16 Thread Paul Lalli
On Aug 16, 10:19 am, [EMAIL PROTECTED] (Chas Owens) wrote: > On 8/16/07, Paul Lalli <[EMAIL PROTECTED]> wrote: > > > On Aug 16, 5:12 am, [EMAIL PROTECTED] (Chas Owens) wrote: > > > Basically > > > it all comes down to this: always use quotemeta unless the variable is > > > known to contain the stri

Re: One liner to change one line

2007-08-16 Thread Chas Owens
On 8/16/07, Paul Lalli <[EMAIL PROTECTED]> wrote: > On Aug 16, 5:12 am, [EMAIL PROTECTED] (Chas Owens) wrote: > > Basically > > it all comes down to this: always use quotemeta unless the variable is > > known to contain the string form of a regex. > > No. It comes down to: "always use quotemeta un

Re: One liner to change one line

2007-08-16 Thread Paul Lalli
On Aug 16, 5:12 am, [EMAIL PROTECTED] (Chas Owens) wrote: > Basically > it all comes down to this: always use quotemeta unless the variable is > known to contain the string form of a regex. No. It comes down to: "always use quotemeta unless the variable is known to contain the string form of a re

Re: One liner to change one line

2007-08-16 Thread Paul Lalli
On Aug 16, 4:37 am, [EMAIL PROTECTED] (Dr.Ruud) wrote: > Paul Lalli schreef: > > > s/$h1_sec/$mod_sec/; #replace the pattern found with the > > modified version > > Many s/$search/replace/ constructs should have been written with > quotemeta, so that they look like: > > s/\Q${search}/repl

RE: One liner to change one line

2007-08-16 Thread Andrew Curry
Apologies I miss read the original remark. -Original Message- From: Chas Owens [mailto:[EMAIL PROTECTED] Sent: 16 August 2007 10:12 To: Andrew Curry Cc: Dr.Ruud; beginners@perl.org Subject: Re: One liner to change one line On 8/16/07, Andrew Curry <[EMAIL PROTECTED]> wrote

Re: One liner to change one line

2007-08-16 Thread Chas Owens
On 8/16/07, Andrew Curry <[EMAIL PROTECTED]> wrote: snip >> Many s/$search/replace/ constructs should have been written with quotemeta, >> so that they look like: >> >> s/\Q${search}/replace/ snip > Why? snip given my $search = "file.txt"; What do you want matched? Without the quotemeta it

RE: One liner to change one line

2007-08-16 Thread Andrew Curry
Why? -Original Message- From: Dr.Ruud [mailto:[EMAIL PROTECTED] Sent: 16 August 2007 09:37 To: beginners@perl.org Subject: Re: One liner to change one line Paul Lalli schreef: > s/$h1_sec/$mod_sec/; #replace the pattern found with the > modified version Many s/$search/r

Re: One liner to change one line

2007-08-16 Thread Dr.Ruud
Paul Lalli schreef: > s/$h1_sec/$mod_sec/; #replace the pattern found with the > modified version Many s/$search/replace/ constructs should have been written with quotemeta, so that they look like: s/\Q${search}/replace/ -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe,

Re: One liner to change one line

2007-08-15 Thread Xavier Noria
On Aug 15, 2007, at 7:04 PM, Xavier Noria wrote: perl -0777 -pi.bak -we 's{()(.*?)()}{$x = $2; $x =~ tr:-: :; "$1$x$3"}geis' *.html A small improvement, groups are unnecessary because the elements are guaranteed not to have hyphens (in general they could, for instance in a class name, b

Re: One liner to change one line

2007-08-15 Thread Paul Lalli
On Aug 15, 12:45 pm, [EMAIL PROTECTED] (Dennis G. Wicks) wrote: > Greetings; > > I have, conservatively, dozens of html files to change. > > I can find them and pass the file name to perl and > do the usual s/// changes but there is one change I can't > figure out. > > There is a line in each file

Re: One liner to change one line

2007-08-15 Thread Xavier Noria
On Aug 15, 2007, at 6:45 PM, Dennis G. Wicks wrote: Greetings; I have, conservatively, dozens of html files to change. I can find them and pass the file name to perl and do the usual s/// changes but there is one change I can't figure out. There is a line in each file that looks like Th

One liner to change one line

2007-08-15 Thread Dennis G. Wicks
Greetings; I have, conservatively, dozens of html files to change. I can find them and pass the file name to perl and do the usual s/// changes but there is one change I can't figure out. There is a line in each file that looks like This-Is-The-Title of course, they are all different! Ho