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: Regular Expressions:
Make-Your-Own-Tags?

 



tallest1
Deleted

May 7, 2000, 8:49 AM

Post #1 of 4 (3060 views)
Make-Your-Own-Tags? Can't Post

I know this is 100% possible but I haven't been able to pull it off. Lets say I have a text file that had the following text:

" {variable name="name"}Jesse{/variable}
{variable name="age"}?{/variable}"

Using regexes how would I have a script read that and create the variables?
$variable{'name'} = Jesse
$varisble{'age'} = ?

would the regex go like this?:
open (MYFILE, "$file.txt");
$line = join( '', <MYFILE> );
close (MYFILE);

while ($line = m/{variable name="([^"]*)"}([^{]*){\/variable}/g) {
$variable{$1} = $2;
}
Thanks in advance


turkscripts
Deleted

May 7, 2000, 6:45 PM

Post #2 of 4 (3059 views)
Re: Make-Your-Own-Tags? [In reply to] Can't Post

Did you try your code, to see if it works properly?

By the way, take a look at my article in the
learning center, for reading files to a variable at one step..


[This message has been edited by turkscripts (edited 05-07-2000).]


summer
Deleted

May 12, 2000, 7:39 AM

Post #3 of 4 (3059 views)
Re: Make-Your-Own-Tags? [In reply to] Can't Post

I wouldn't write this sort of thing from scratch: there are many modules that allow you to create your own tags and which provide means of extracting their values and processing them.

If you go to search.cpan.org (note no leading www.) and search for 'template' you will find a list of such modules, I'd look in particular at Text::Template and HTML::Template
If you search for 'macro' you'll find two other modules that do macro processing which will also do the same sort of job.


tallest1
Deleted

May 12, 2000, 8:04 AM

Post #4 of 4 (3059 views)
Re: Make-Your-Own-Tags? [In reply to] Can't Post

Another question: Can I use CPAN modules on a commercial script?

 
 


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

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