LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-04-2010, 12:18 PM   #76
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454

Quote:
Originally Posted by MTK358 View Post
I want to replace the 'Neck{SomeBody}' part in your example. Except in my case the keyword will be 'pstruct' instead of 'Neck'.
First of all, I wrote 'HeadOnLongNeck', not just 'Neck'. So, you want to replace part of "prefix", i.e.part of 'HeadOnLongNeck', and the '{SomeBody}' ?

Or you want to replaced the whole 'HeadOnLongNeck{SomeBody}' ?
 
Old 02-04-2010, 12:21 PM   #77
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
I want to replace the "prefix" and the contents of the brackrts, including the brackets themselves.
 
Old 02-04-2010, 12:37 PM   #78
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post
I want to replace the "prefix" and the contents of the brackrts, including the brackets themselves.
So, assuming that initially you have

Code:
my $s = 'HeadOnLongNeck{SomeBody}Tail';
you want $s to become

Code:
FooTail
where 'Foo' is the text you want to have instead of 'HeadOnLongNeck{SomeBody}', correct ?

If it's the case, why not simply use Perl 's' operator - you gave an advice on it in a recent thread.

I think I've already written, read:

perldoc -f s
perldoc perlretut
perldoc perlre
.
 
Old 02-04-2010, 01:02 PM   #79
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
How is the s operator gonna help? "Foo" is generated by a subroutine and cannot be known beforehand. It is not stored in a variable or can be generated by pure regex (as far as I know).
 
Old 02-04-2010, 01:17 PM   #80
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post
How is the s operator gonna help? "Foo" is generated by a subroutine and cannot be known beforehand. It is not stored in a variable or can be generated by pure regex (as far as I know).
Read

perldoc perlop
.

The answer is there.

And/or you may try the substr/length way. I.e. read

perldoc -f substr
perldoc -f length
.

And if you want the substr/length way, first write code which does the job using hard-coded numbers, and then I'll "drive" you step by step to the generic (not hard coded) way.

Unfortunately, as this thread has proved many times, you do not read the documentation when told so. Before telling you to read something I am rechecking myself to make sure the documentation I suggest to read does have the needed answers.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for XML::Parser... configure: error: XML::Parser perl module is required for kornerr Linux - General 11 11-16-2008 07:24 AM
perl xml::parser dirhandle problem theshark Linux - Software 0 03-16-2006 06:45 PM
XML::Parser perl module is required for intltool, for LogJam GT_Onizuka Linux - Newbie 7 06-30-2005 07:49 AM
XML::Parser perl module is required farzan Linux - Software 8 09-26-2004 05:54 AM
XML::Parser perl mod is req 4 intltool error BorisMcHack Slackware 4 06-23-2004 07:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration