Ian Marlier wrote:
I'm in the process of writing a script to migrate from one wiki
package to another.
<snip>
The old wiki help articles in a series of flat text files. The new
one holds everything in MySQL, so I need to parse the text files
into a single SQL import script. I've got most of it, but there's
one place where I'm getting stuck and could use some help.
The old wiki holds links in one of these formats:
[WikiLink]
Or
[Text That Links|WikiLink]
Or
[Text That Links|http://someurl.com/]
The new one holds them in the form
((WikiLink))
Or
((WikiLink|Text That Links))
Or
((http://someurl.com/|Text That Links))
Replacing the individual characters is easy.
But how can I grab the "link" and "text" parts out (IF there is a
"|" in the middle), and reverse them?
You can use the s/// operator and have the right side evaluated as an
expression:
s{\[([^\]|]+)(?:(\|)([^\]|]+))?\]}
{ '((' . ($2 ? "$3$2$1" : $1) . '))' }eg;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>