4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Contructing variable names from variables.
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
brendanarnold
Junior WebHelper
Junior WebHelper


Joined: 04 Feb 2002
Posts: 5

PostPosted: Sun Feb 10, 2002 2:33 am (15 years, 8 months ago) Reply with QuoteBack to Top

I am a novice perl programmer. I am working on a script that updates news items on a webpage from a webpage interface.

It uses a load of variables carried over from a previous operation that relates to the 'news' id number i.e. $title1,$text1 for the first news item, $title2,$text2 for the second etc.

I need to use, within a regex, a variable found from a parentheses on the left hand side to construct the variable name used on the right hand side.

Perhaps if I showed my first attempt (which failed) it may become more clear.

s/<!--NEWS(\d+)START-->.*?<!--NEWS(\1)END-->/<!--NEWS$1START--><h2>$title(?:$1)<\/h2><p>$text(?:$1)<\/p><!--NEWS\1END-->/e;

So on the right hand side, I want perl to refer to a variable called $title3 say, after it matched <!--NEWS3START-->

I would really appreciate some help as this is my first hefty piece of regex.

Thanks

Brendan.
OfflineView User's ProfileFind all posts by brendanarnoldSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.045826 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme