Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Will regex work here?

by chorg (Monk)
on Apr 25, 2001 at 00:43 UTC ( [id://75260]=note: print w/replies, xml ) Need Help??


in reply to Will regex work here?

If you are using XML, you should be able to avoid the regex stuff. We all love regex, but the whole point of XML is to allow standardized(eventually) access to files and the like.

My point here is that you should probably look to an XML solution. XML::Parser may be needlessly low level for what you want to do, which is perform an operation on a whole xml file, as opposed to doing tag by tag. This sounds like a job for a DOM type parser to me. check out T.J. Mather's modules Since you want to slurp in the whole file, memory is not an issue.

Also, if you really want to use XML::Parser, you coud read in the file to your string, transform it SAX style on the fly into another variable and do whatever you want to do with it.

Comment?
_______________________________________________
"Intelligence is a tool used achieve goals, however goals are not always chosen wisely..."

Replies are listed 'Best First'.
Re: Re: Will regex work here?
by Sherlock (Deacon) on Apr 25, 2001 at 00:52 UTC
    Well, I'm able to parse the entire XML document already using XML::Parser. For this operation, I don't really need to view the contents of the file as XML at all - just as a single big string. I'd like to simply do a one-shot removal of all the old data and then read it in as XML.

    The option of using an XML based solution had occured to me, and quite possibly be what I end up using, but I was just interested if a regex could be used here or not. (Like I said, I'm still just learning regex's.)

    Thanks for the link to Mather's modules - I haven't looked through them closely yet, but they look as if they might be very useful.

    - Sherlock

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-19 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found