Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


In reply to Re: Search and Replace Text File by Schemer
in thread Search and Replace Text File by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-24 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found