Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Search and Replace Text File

by Schemer (Scribe)
on Oct 21, 2002 at 20:30 UTC ( #206919=note: print w/ replies, xml ) Need Help??


in reply to Search and Replace Text File

I guess the problem you are looking into solving revolves around your regexp not extracting your data as you would like.

Maybe you should consider putting your data is a less half-assed format (yours looks like XML, but it's not even XML, so it's even worse).

Use a simpler file format, don't reinvent XML badly. If you really need XML, use a module that will help you work with _real_ XML.

Here is an example of what you could have used:

Instead of: <?--1-News1--> <b>This is option News 1 of 1</b> </?--1-News1--> <?--3-Third1of3--> <b>Option Third 1 of 3</b> </?--3-Third1of3--> what about: 1,News,1,1 3,Third,1,3 Then you can do something like: ($num, $name, $index, $total) = split /,/, $data;

Use simple data representation for simple stuff, if it get more complex look into using a database. Don't overwhelm yourself with <,>,--,/ and friends. Aim for simplicity, your problems will resolve themselves.

And finally, if you don't know what a particular piece of code in your program does (because, say, you've done some ctrl-c and some ctrl-v), remove it for now. Later, if you have a problem and you need to put it back in, you'll understand what it does.


Comment on Re: Search and Replace Text File
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://206919]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2014-10-21 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (98 votes), past polls