CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
\K in perl not working


New User

Mar 22, 2011, 3:40 AM

Post #1 of 4 (4524 views)
\K in perl not working Can't Post

Hi All,
I have just started learning perl and was working on my one-liners tips and tricks.

Instead of using the below command :
perl -lape 's/(^From:).*/$1 Nelson Elhage <nelhage\>/'

i tried using the \k command using the below command but it gave no results:

perl -lape 's/^From:\K.*/ Nelson Elhage <nelhage\>/'

Is there some problem with the perl version on my unix box. Please find some of details of the platform i am using:

> uname -a
HP-UX hpxi017 B.11.23 U ia64 1433056900 unlimited-user license

> perl -v i

This is perl, v5.8.8 built for IA64.ARCHREV_0-thread-multi
(with 33 registered patches, see perl -V for more detail)

Sorry if it is a very basic question Smile


Mar 22, 2011, 6:11 AM

Post #2 of 4 (4516 views)
Re: [kunwar] \K in perl not working [In reply to] Can't Post

I have searched all of perlre and perlreref for documentation on \K or \k and cannot find it. I doubt that there is such a 'command' in perl 5.8.8. Sorry if I have overlooked something. BTW, all the special characters in regular expressions are case sensitive.
Good Luck,

New User

Mar 22, 2011, 7:35 AM

Post #3 of 4 (4511 views)
Re: [BillKSmith] \K in perl not working [In reply to] Can't Post

Hi Bill, Thanks for replying .

I was practicing the one-liners given on the below link:

See the Trick #7: \K for the doubt which i am asking.
Looking at the comments which author has received on this , it seems that there does exist such a option.


Mar 22, 2011, 8:06 AM

Post #4 of 4 (4508 views)
Re: [kunwar] \K in perl not working [In reply to] Can't Post

The \K seems to have been introduced in Perl 5.10.0. It is not available in 5.8.8, as Bill said.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives