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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



kunwar
New User

Mar 22, 2011, 3:40 AM

Post #1 of 4 (696 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\@ksplice.com>/'

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

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


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

Code
 
> 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
Regds,
KunwarSmile


BillKSmith
Veteran

Mar 22, 2011, 6:11 AM

Post #2 of 4 (688 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,
Bill


kunwar
New User

Mar 22, 2011, 7:35 AM

Post #3 of 4 (683 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:

http://blog.ksplice.com/2010/05/top-10-perl-one-liner-tricks/

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.


Karazam
User

Mar 22, 2011, 8:06 AM

Post #4 of 4 (680 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.
http://perldoc.perl.org

 
 


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

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